Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduktion til LaTeX Bent Thomsen Institut for Datalogi.

Similar presentations


Presentation on theme: "Introduktion til LaTeX Bent Thomsen Institut for Datalogi."— Presentation transcript:

1 Introduktion til LaTeX Bent Thomsen Institut for Datalogi

2 2 Introduktion TeX –opfundet af Donald Knuth i 70’erne –Revolutionerede bogtrykning LaTeX er en overbygning til TeX –Oprindeligt udviklet af Lesley Lamport –LaTeX en macro package som gør det nemmere at bruge TeX Tex og LaTeX er Markup Sprog –i stil med HTML, XML og RTF

3 3 LaTeX sales pitch Høj typografi kvalitet – bogtryk kvalitet Nemt at inkludere matematiske formler Nemt at lave krydsreferencer Nemt at lave litteratur liste Source filer er plain text og derfor OS uafhængigt Der findes LaTeX implementationer til all operativ systemer (Unix, Linux, Dos, Windows, MacOS, …) LaTeX er gratis

4 4 Word vs. Latex WordLatex Små dokumenterStore dokumenter Flere personer  …  Flere personer WYSIWYGCompile Knapper/menuerKommandoer Svært at skifte udseendeNemt at skifte udseende Editors til entiteterIn-text entiteter Ingen/dårlige auto. ref.Automatiske referencer

5 5

6 6 Latex er ikke WYSIWYG –Dokumenter skal kompileres Kompilering.tex latex .dvi.log.ps dvips xdvi lp Mit dokument gostview smtp Internet

7 7 LaTeX Al tekst er ren ASCII tekst –Kan skrives i Edit, notepad, WinEdt, emacs, vi.... –Men IKKE direkte i Word Brug ”save as” – ”plain text”

8 8 LaTeX og pdf-filer.tex latex .dvi.log.ps dvips ps2pdf.pdf

9 9 Latex-dokument Dokument opbygges med kommandoer Kommandoer –Starter med \ Efterfulgt af bogstaver, f.eks \bf og \section Termineret med mellemrum Tager sommetider parametre i { … } Speciel-karakter er også kommandoer – f.eks. æ som skrives \ae eller {\ae} Du kan definere dine egne kommandoer –Nye kommandoer skal overholde de regler

10 10

11 11 LaTeX dokumentets struktur Preamble –Document Class Predefined formats: article, letter, report, book, … –Packages used Added Functionality Main Body –Text –Bibliography references

12 12 Preamble – et must Primær funktionalitet –Layout: dokumenttype, punktstørrelse,... Fordele: –Nemt at skifte layout Styres fra eet sted –Nemmere at være flere personer Selvdefinerede kommandoer Preamble scope \documentclass... \begin{document}

13 13 Body of Text Start with \begin{document} End with \end{document} Typesetting Text –\\ or \newline and \newpage –Quotations –Bold \textbf{……………} or \bf –Italics \emph{…………} or \textit{………} or \it –Underline \underline{…………} or \ul

14 14 Format Sections –\section{…} = 1. Latex is Great –\subsection{…} = 1.1 Why Latex is Great –\subsubsection{…} = Reason One –\appendix - changes numbering scheme –\chapter{…} - To be used with book and report document classes Titles, Authors and others –\title{…} \author{…} –\footnote{…}

15 15 Format Contd. \maketitle - Display Title and Author \tableofcontents - generates TOC \listoftables - generates LOT \listoffigures - generates LOF Labels –\label{marker} - Marker in document. –\pageref{marker} - Displays page no. of marker. –\ref{marker} - Displays section location of marker. Itemize –Use either enumerate, itemize or description. –see handout for example.

16 16 Lists Source –\begin{itemize} –\item Apple –\item Orange –\end{itemize} Result –Apple –Orange

17 17 Lists Enumerate instead of itemize gives a numbered list Lists can be nested

18 18 Environment Something between –\begin{name} –\end{name} Many command, for example \bf affect the text until the end of environment Environments can be nested Examples: – itemize, center, abstract

19 19 Group Group is some text between { and } Many commands work until the end of the group Code –put {one word \bf in bold} here Result –put one word in bold here

20 20 Alignment Environments center, flushleft, flushright Example –\begin{flushright} –Right aligned –\end{flushright} Result Right aligned

21 21 Font size \tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge

22 22 Tabular Columns –\begin{tabular}{|…|…|} –\end{tabular} Rows –& - Split text into columns –\\ - End a row –\hline - Draw line under row –e.g & 34.00\\ \hline Two Columns l = automatically adjust size, left justify r = automatically adjust size, right justify p = set size e.g p{4.7cm} c = centre text

23 23 Example of table \begin{tabular}{|l|r|c|} \hline Date & Price & Size \\ \hline Yesterday & 5 & big \\ \hline Today & 3 & small \\ \hline \end{tabular}

24 24 Floating Objects Floating objects can stop splitting of tables and images over pages. \begin{figure}[options] \end{figure} \begin{table}[options] \end{table} They will now appear in the –List of Figures (LOF) and –List of Tables (LOT). Options (recommendations) h = place table here t = place at top of page b = place at bottom of page

25 25 Example of floating figure \begin{figure}[ht] \centering\epsfig{file=uni.ps, width=5cm} \caption{Aalborg University} \label{uni} \end{figure} Figure~\ref{uni} shows...

26 26 Cross-references (internal references) \label{key-string} –assigns the key key-string to the current element of the document \ref{key-string} –inserts a string identifying that the element key- string refers to \pageref{key-string} –inserts the number of the page that key-string is on.

27 27 Cross-reference Example Figure \ref{f:figexample} in Section \ref{s:IntroSection} is on page \pageref{f:figexample}. Results in: Figure 1 in Section 1 is on page 1.

28 28 Images Use epsfig package \usepackage{epsfig} Including images in main body \epsfig{file=filename.eps, width=10cm, height=9cm, angle=90} Creating EPS - Use xv and/or xfig. MS Power Point, save as GIF and convert to EPS.

29 29 Matematik & LaTeX Math-mode inde i teksten med $...om variablen $a$ gælder at $a \in [0,\infty[$ og $a \geq b$.... Eksplicit math-mode med $$... om $a$ gælder følgende: $$a \mid a \in [0,\infty[ \;\wedge\; a \geq b$$ Derfor.... I environments som equation \begin{equation} \label{eq:a} a \mid a \in [0,\infty[ \;\wedge\; a \geq b \end{equation}

30 30 Variance Equation Example \documentclass{article} \begin{document} \begin{equation} \label{E:variance} \sigma^{2} = \frac{\sum\limits_{i=1}^{n} \left(x_{i} - \bar{x}\right)^{2}} {n-1} \end{equation} \end{document}

31 31

32 32 Egne kommandoer Ny kommando uden parametre \newcommand{\ny}{.... } \ny Ny kommando med parametre \newcommand{\ny}[2]{..#1... #2.. } \ny{par1}{par2} Nyt environment \newtheorem{proof}{\sc Bevis} \def\theproof{}

33 33 Store Latex-dokumenter Inkludering af filer i en fil: \input Et dokument (master.tex) består af: \input{ preamble.tex } \begin{document} \input{ interessant-tekst.tex } \end{document} Al tekst er ren ASCII tekst –Kan skrives i notepad, WinEdt, emacs, vi.... –Men IKKE direkte i Word Brug ”save as” – ”plain text”

34 34 Store Latex-dokumenter Et dokument i Latex kan bestå af flere filer masterpreamble … fil 1fil n-2 Samler dokumentet

35 35 Håndkodet litteraturliste project.tex...tekst \cite{Hansen:2002}. \begin{bibliography}{1} \bibitem{Hansen:2002} Peter Hansen. \newblock {\em Hansens Bog}. \newblock Gyldendal, \bibitem{... }... \end{bibliography}

36 36 Litteraturdatabase vha. BiBTeX author = {Peter Hansen}, title = {Hansens Bog}, publisher = {Gyldendal}, year = 2002 } project.tex...tekst \cite{Hansen:2002}. \bibliographystyle{plain} \bibliography{project, P0}

37 37 Creating a Bibliography with BibTeX Must create a bibliography database –References.bib file –read by BibTeX Bibliographies can have different formats –e.g., Alphabetical, Numbered, etc. BibTeX formats entries based on the bibliography style chosen –e.g., Plain, Alpha, IEEE, ACM, etc.

38 38 BibTeX Entry Entry Type: book, article, in proceeding, etc. Keyword identifying publication Series of Fields –Author –Journal –Title, etc. title = {Software Engg, A practitioner’s Approach}, author = {Roger S.Pressman}, publisher = {McGraw-Hill}, year = {1997} }

39 39 Referencing a.bib Entry References.bib file must be included in LateX by using \bibliography{References} Cite the reference by using: \cite{cite-key} Example: –In \cite{pressman97}, the characteristics of software are discussed. –Result: In [1], the characteristics of software are discussed.

40 40 Kompilering med BiBTeX.blg LaTeX BiBTeX.bbl.aux.dvi.bib.tex.aux I terminalvindue: latex project bibtex project Eller i emacs: C-c L C-c

41 41 ”Putting it all together” Et komplet projekt... –Punktopstilling –Selvdefineret kommando –Tabel –Figur –Matematik –Litteraturliste

42 42 Latex er ikke WYSIWYG –Dokumenter skal kompileres Kompilering.tex latex .dvi.log.ps dvips xdvi lp Mit dokument gostview smtp Internet

43 43 LaTeX Al tekst er ren ASCII tekst –Kan skrives i Edit, notepad, WinEdt, emacs, vi.... –Men IKKE direkte i Word Brug ”save as” – ”plain text”

44 44 LaTeX og pdf-filer.tex latex .dvi.log.ps dvips ps2pdf.pdf

45 45 Conclusions Latex is optimal for master and phd thesis Latex has a steep learning curve –So start practicing now! Mathematical formulae are easy. Cross references are easy Litterature lists are very easy You may use bibtex search engines –http://liinwww.ira.uka.de/bibliography/index.html Consider converting Postscript files to PDF (more widespread in Windows world) and to conserve space.


Download ppt "Introduktion til LaTeX Bent Thomsen Institut for Datalogi."

Similar presentations


Ads by Google