Jérôme Gilles - Jegilles.sdsu.edu

Transcription

LATEX tutorialJérôme GillesDepartment of Mathematics, UCLAjegilles@math.ucla.eduLATEX tutorial

Generalities - What is LATEX?LATEX is a “high level” programming language over TEX source file (.tex) “compiler” documentLATEX tutorial

Generalities - What is LATEX?LATEX is a “high level” programming language over TEX source file (.tex) “compiler” FDVIpdflatexLATEXlatexdvipdfmLATEX tutorial

Generalities - ToolsUnix/Linuxcommands: latex, dvi2ps, ps2pdf, bibtex, pdflatexIDE: Kilehttp://kile.sourceforge.net/WindowsMikTEX TEXnicCenter Ghostview nter.org/http://www.cs.wisc.edu/ ghost/MacMacTEX TEXshop regon.edu/ exniscope.htmlIPE: /ipe7/index.php/Main PageLATEX tutorial

General structure of a LATEXfile% is a epsfig}My revolutionary algorithmJérôme GillesSummer 2012Here is the content of my paper% define used "variables"\title{My revolutionary algorithm}\author{J\’er\ ome Gilles}\date{Summer 2012}% content of the paper\begin{document}\maketitleHere is the content of my paper\end{document}1LATEX tutorial

Document Class\documentclass[options]{type of document}Document typearticleOptionsletterfont size (10pt,11pt,12pt)reportpaper size (letter,a4paper)booktwocolumnspecific (IEEE, SPIE, SIAM,.)twosideLATEX tutorial

Packages\usepackage[options]{package name}Common ybox,fancyhdr,. . or,. . g,. . .LATEX tutorial

Merging LATEX ymb}\usepackage{epsfig}\chapter{Introduction}Here is the text corresponding tomy introduction.% define used "variables"\title{My revolutionary algorithm}\author{J\’er\ ome Gilles}\date{Summer 2012}chapter2.tex% content of the include{chapter2}\end{document}\chapter{Our new approach}Here I describe my new amazingalgorithm!See ex2.pdfLATEX tutorial

BasicsReserved symbols%{. . .} #CommentsProcessing blockMath modeMacro parameter\ & andCommandNonbreaking spaceAlignment tag in arraysupperscript and subscriptLATEX tutorial

BasicsReserved symbols%{. . .} #CommentsProcessing blockMath modeMacro parameter%{. . .} #\%\{. . .\}\ \#\ & and\ & andCommandNonbreaking spaceAlignment tag in arraysupperscript and circum and \LATEX tutorial

Basics: spaces and carriage return\documentclass[11pt,letterpaper]{article}% define used "variables"\title{My revolutionary algorithm}\author{J\’er\ ome Gilles}\date{Summer 2012}% content of the paper\begin{document}\maketitleThisis a teston spacesThis is an example of carriage return\\This is the beginning of a new paragraph.\end{document}LATEX tutorial

Basics: document appendixCommentavailable only for report or bookavailable only for report or bookindicate the beginning of appendicesNb: if you want to remove the numbering put a star between thecommand and the brackets: \chapter*{}LATEX tutorial

Basics: font \large\Largethis text is tinythis text is scriptsizethis text is footnotesizethis text is smallthis text is normalsizethis text is largethis text is Large\LARGEthis text is LARGE\hugethis text is huge\Hugethis text is HugeCan be use as \large{text} or in an environment:\begin{large}text\end{large}LATEX tutorial

Basics: font \emph\textup\textsl\textsc{\normalfont . . . }{\bfseries . . . }{\itshape . . . }{\rmfamily . . . }{\sffamily . . . }{\ttfamily . . . }{\em . . . }{\upshape . . . }{\slshape . . . }{\scshape . . . }NormalBoldItalicRoman fontSans Serif fontTypewriter fontEmphasizeUprightSlantedS MALL CAPITALLATEX tutorial

Basics: environmentsSome part of the code is specific or must have a temporary property: environment:\begin{} . \end{}\begin{center}This text egin{flushleft}This text is\\\textit{aligned on left}\end{flushleft}This text iscenteredThis text isaligned on leftThis text isALIGNED ON RIGHT\begin{flushright}This text is\\\textsc{aligned on right}\end{flushright}LATEX tutorial

Listing environmentsitemize: unnumbered listingenumerate: numbered listingdescription: description listing\begin{itemize}\item[ ] first element\item[ ] a star\item a nice bullet\\\end{itemize}\begin{enumerate}\item first property\item second Definition 1:]{the first definition}\item[Definition 2:]{the second definition}\end{description}LATEX tutorial

CrossreferencesSometimes you want to refer to another section, chapter, equation,figure . . . \label{} and \ref{} commands\documentclass[11pt,letterpaper]{article}% define used "variables"\title{My revolutionary algorithm}\author{J\’er\ ome Gilles}\date{Summer 2012}% content of the on}\label{sec:intro}This is the introduction\section{Principle}As mentioned in section \ref{sec:intro}, itwas the introduction.\end{document}LATEX tutorial

Table and Figure environments\begin{table}[!ht]\centering% definition of the table\caption{Table in{figure}[!ht]\centering% insert your figure\caption{Figure ”: do its best to put the environment closest as possible from the text it is declared“HERE”: put the environment exactly here“top”: put the environment on top of the page“bottom”: put the environment on bottom of the page“page of float”: put the environment on an extra page without any textLATEX tutorial

Including imagesNeeds the package graphicxTwo cases:use of latex command: accepts only postscript images (.eps)use of pdflatex command: accepts PNG,JPG and PDF filesThe command is:\includegraphics[option]{image filename}Options are:[scale 0.3]: scale the image to 30% of its original size[width 4cm]: fix the width of the image to 4cm[height 50mm]: fix the height of the image to 50mm[angle 45]: rotate the image by an angle of 45 degresUseful variables:\textwidth,\textheight,\columnwidthLATEX tutorial

Including cle}\usepackage{graphicx}\title{My revolutionary algorithm}\author{J\’er\ ome Gilles}\date{Summer 2012}% content of the paper\begin{document}\maketitleFigure 1: This the first figureThis an example of how we can include figures! (seeFig. \ref{fig1} and \ref{fig2})My revolutionary algorithmJérôme GillesSummer cale 0.3]{lena}\caption{This the first figure}\label{fig1}\end{figure}This an example of how we can include figures! (see Fig. 1 and th \textwidth]{latex}\caption{This the second figure}\label{fig2}\end{figure}Figure 2: This the second figure1\end{document}LATEX tutorial

Including tablesNeeds the package tabular (array in math mode)A table is defined from the commands:\begin{tabular}[pos]{columns definition} \hlinexxx & xxx & . & \\yyy & yyy & . & \\ \hline\end{tabular}pos see table environmentcolumns can be defined by:\hline draw an horizontal linel: element are left justifiedr: element are right justifiedc: element are centered : put a vertical barEach column elements on asame row are separated by the &symbolp{w}: a column of width wLATEX tutorial

Including cle}\usepackage{array}\title{My revolutionary algorithm}\author{J\’er\ ome Gilles}\date{Summer 2012}% content of the entering\begin{tabular}{ l c p{5cm} } \hlineA & B & end of first row \\ \hlineCGHIJ & & D \\E & FKL & end of table \\ \hline\end{tabular}\end{table}My revolutionary algorithmJérôme GillesSummer 2012AB end of first rowCGHIJDEFKL end of table\end{document}Other usefull commands:\multicolumn,\multirow,\backslashboxLATEX tutorial

Mathematics in LATEXNeeds (at least) packages amsmath,amsfonts,amssymbTwo cases: equation embedded in ( . ) the text or equation onseparate line (\begin{equation} . {document}The Cartesian equation of a straight line is of the form ax by c 0 where a,b,c areconstants.\end{document}LATEX tutorial

Mathematics in LATEXNeeds (at least) packages amsmath,amsfonts,amssymbTwo cases: equation embedded in the text ( . ) or equation onseparate line (\begin{equation} . {document}The Cartesian equation of a straight line isof the form\begin{equation}ax by c 0\end{equation}where a,b,c are constants.\end{document}LATEX tutorial

Mathematics in LATEXSpecial kboard alphabet: A, B, N, R, Zcalligraphied alphabet: A, B, N , R, Zbold alphabet: A, B, N, R, Zitalic alphabet: A, B, N, R, ZSpecial htarrow{\text{abc}}\overbrace{abc}áà abcabcgabcabc z} {abc\bar{a}\vec{a}ā ̇ \breve{a}ä\tilde{a} abcabcdabc\xleftarrow{\text{abc}} \underbrace{abc}abc {z}LATEX tutorial\dot{a}\ddot{a}abcăã

Mathematics in LATEXGreek i\varsigma\varphi\Gamma\Xi\PhiVariable sized symbolsP\sum H\ointβϑµ prod\bigcapQTγινρτχ \Omega\int\bigcupLATEX tutorialRSδκξ%υψΘΣΩ

Mathematics in LATEXStandard functions\cos, \sin, \log, \ln, \arg, \inf, \sup, . . .Ex: \cos(\alpha \beta) \cos\alpha\cos\beta - \sin\alpha \sin\betagives cos(α β) cos α cos β sin α sin βSuperscript and subscriptx ix {i-1} {j-1}xij 1xi 1x ix {u Ex: \frac{3x 1}{1-x 2} gives3x 11 x 2 qEx: \sqrt[q]{1-x 2} gives1 x2 \sqrt{x 3} gives x 3LATEX tutorial

Mathematics in LATEX: sums, products and n{document}\begin{equation}\sum {k 1} n k \frac{n(n 1)}{2}\end{equation}\begin{equation}\prod {k 1} m k m!\end{equation}\begin{equation}\int 0 { \infty} x n e { x}dx n!\end{equation}\begin{equation}\oiint {\partial \Omega}(\mathbf{F}\bullet\mathbf{n})dS \iiint end{document}LATEX tutorial

Mathematics in LATEXDerivatives\frac{df}{dx}\frac{\partial f}{\partial x}dfdx f x\frac{d nf}{dx n}\frac{\partial nf}{\partial x n}Absolute values and norms x gives x \ x\ givesLATEX tutorialkxkdnfdxn n f x n

Mathematics in cument}\begin{equation}\begin{pmatrix}a {1,1} & a {1,2} & \dots & a {1,n} \\a {2,1} & a {2,2} & \dots & a {2,n} \\\vdots & \vdots & \ddots & \vdots \\a {m,1} & a {m,2} & \dots & a egin{vmatrix}a {1,1} & a {1,2} & \dots & a {1,n} \\a {2,1} & a {2,2} & \dots & a {2,n} \\\vdots & \vdots & \ddots & \vdots \\a {m,1} & a {m,2} & \dots & a X tutorial

Mathematics in LATEXGroup of nt}\begin{gather}\frac{d}{dx}(f(x) g(x)) \frac{df}{dx}(x) \frac{dg}{dx}(x)\\\frac{d}{dx}(f(x)g(x)) f(x)\frac{dg}{dx}(x) {d}{dx}(f(x) g(x))& \frac{df}{dx}(x) \frac{dg}{dx}(x)\\\frac{d}{dx}(f(x)g(x))& f(x)\frac{dg}{dx}(x) i(x) \begin{cases}0 \qquad \text{if} \quad x\geqslant 0\\1 \qquad \text{if} \quad x 0\end{cases}\end{equation}\end{document}LATEX tutorial

Mathematics in LATEXTheoremsNeeds the package theorem. We first specify the different kind ofstatements (before the \begin{document}) with the command\newtheorem{thm}{Theorem} and then we use the command\begin{thm}. . begin{thm}The sum of the angles of a triangle is \pi \end{thm}\end{document}LATEX tutorial

BibliographyOriginal approach: egin{document}In \cite{les85}, the authors propose to . while in \cite{don89} .\begin{thebibliography}{99}\bibitem{les85} Leslie Lamport, 1985. \emph{\LaTeX A Document Preparation System User’s Guide andReference Manual},Addison Wesley, Reading.\bibitem{don89} Donald E. Knuth, 1989. \emph{Typesetting Concrete Mathematics}, TUGBoat, 10(1):31 36.\end{thebibliography}\end{document}LATEX tutorial

BibliographyAdvanced approach: B IBTEXReferences are contained in an external “mybiblio.bib” file which will be called by thecommand \bibliography{mybiblio}.We must specify a bibliography style by using \bibliographystyle{style} where the most usedstyles areplain: Standard B IBTEX style. Entries sorted alphabetically with numeric labels.unsrt: Similar to plain, but entries are printed in order of citation, rather thansorted.alpha: Similar to plain, but the labels of the entries are formed from the author’sname and the year of publication.abbrv: Similar to plain, but entries are more compact, since first names, month,and journal names are le}\begin{document}In \cite{les85}, the authors propose to teps to generate the bibliography1Run LATEX: list of \cite ref in the .aux file,2Run B IBTEX: extract the cited ref from the .bib file,format and save them in the .bbl file,3Run LATEX again: read the .bbl file,4Run LATEX a third time to resolve all references.\end{document}LATEX tutorial

BibliographyB IBTEX databaseEach reference is described in the following way:@entry type{key,field name {field text},.field name {field text}}articlerequired fields:optional fields:entry for an article from a journal or magazineauthor, title, journal, yearvolume, number, pages, month, note.bookrequired fields:optional fields:entry for a book with a definite publisherauthor or editor, title, publisher, yearvolume or number, series, address, edition, month, noteconferencerequired fields:optional fields:entry for an article in conference proceedingsauthor, title, booktitle, yeareditor, volume or number, series, pages, address, month, .LATEX tutorial

Bibliography.bib file@ARTICLE{Gilles2010a,author {J\’er\ ome Gilles and Yves Meyer},title {Properties of BV G structures textures decomposition models. Applicationto road detection in satellite images},journal {IEEE Transaction in Image Processing},year {2010},volume {19},pages {2793 2800},number {11}}@BOOK{Triebel3,title {Theory of Function Spaces III},publisher {Birkhauser Verlag},year {2006},author {Hans Triebel},series {Monographs in Mathematics}}To manage reference databases: JabRef (http://jabref.sourceforge.net/)LATEX tutorial

Other useful formatting toolsTable of Content (ToC)Just add the command \tableofcontents where you want to seeyour ToC!Lists of figures or tablesJust add the command \listoffigures or \ listoftablesFootnotesUse \footnote{your note}Page, line breakUse \newpage or \linebreakAlgorithm - PseudocodeSee packages algorithm, algorithmic,listingsLATEX tutorial

Presentations: the Beamer class\documentclass{beamer}\mode presentation \usetheme{Warsaw}\title{\LaTeX\ tutorial}\author[]{J\’er\ ome Gilles}\institute[UCLA]{Department of Mathematics, t}.\end{document}LATEX tutorial

Presentations: the Beamer classSlides: the frame environment\begin{frame}\titlepage\end{ frame}\begin{frame}{Title}\end{ frame}Group of elements: the block environment\begin{block}{block title}Elements of this block\end{block}LATEX tutorial

Presentations: the Beamer classPositioning: the textblock environmentNeed first to define a “virtual” grid (before y)\end{textblock}LATEX tutorial

Presentations: OverlaysThe pause command\begin{itemize}\item First item\pause\item Second item\item Third item\pause\item Forth item\end{itemize}General overlay specificationsWe can specify overlay specificationsby associating spec to somecommands like:\textbf{Allways bold}\textbf 2 {Bold from the second slide}Notations: N on slide N only, -N from first slide to slide N,\begin{itemize}\item 1 First point\item 2 alert@2 Secondonly point\item 3 Third point\end{itemize} N- from slide N, N-M from slide N to slide M.LATEX tutorial

Presentations: OverlaysIncremental specifications\begin{itemize}\item alert@ First item\item alert@ Seconditem\item alert@ Third item\item alert@ Forth item\end{itemize}. . . equivalent to\begin{itemize}[ alert@ ]\item First item\item Second item\item Third item\item Forth item\end{itemize}overlay on a block\only 1 {\begin{textblock}{15}(2,2)\begin{block}{Top block}Here is the block I want to see from the first slide\end{block}\end{textblock}}\only 2 {\begin{textblock}{18}(6,6)\includegraphics[scale 0.3]{lena}\end{textblock}}LATEX tutorial

Useful links about LATEXLATEX wikibook: http://en.wikibooks.org/wiki/LaTeXSymbol list: /symbols-letter.pdfBeamer manual: ib/beamer/doc/beameruserguide.pdfLATEX Tutorial: http://www.tug.org.in/tutorials.htmlLATEX tutorial

General structure of a LATEXfile LATEX tutorial % is a comment \documentclass[11pt,letterpaper]{article} \usepackage{amsmath} \usepackage{amssymb} \usepackage{epsfig} % define used "variables" \title{My revolutionary algorithm} \author{J\’er\ ome Gilles} \da