jérôme gilles - san diego state university · latex tutorial needs the package graphicx two...

Post on 24-May-2020

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LATEX tutorial

Jérôme Gilles

Department of Mathematics, UCLAjegilles@math.ucla.edu

LATEX tutorial

Generalities - What is LATEX?

LATEX tutorial

LATEX is a “high level” programming language over TEX

⇒ source file (.tex) + “compiler” = document

Generalities - What is LATEX?

LATEX tutorial

LATEX is a “high level” programming language over TEX

⇒ source file (.tex) + “compiler” = document

LATEX

TEX

DVIPDF

Postscript

tex

latexpdflatex

pdftex

pdf2ps

ps2pdf dvi2ps

dvipdfm

Generalities - Tools

LATEX tutorial

Unix/Linuxcommands: latex, dvi2ps, ps2pdf, bibtex, pdflatexIDE: Kilehttp://kile.sourceforge.net/

WindowsMikTEX+ TEXnicCenter + Ghostview (freeware)http://www.miktex.orghttp://www.texniccenter.org/

http://www.cs.wisc.edu/~ghost/

MacMacTEX+ TEXshop + TEXnicscopehttp://www.tug.org/mactex/http://www.uoregon.edu/~koch/texshop/

http://www.software112.com/products/texniscope.html

IPE: http://lamut.informatik.uni-wuerzburg.de/mediawiki/ipe7/index.

php/Main_Page

General structure of a LATEXfile

LATEX tutorial

% is a comment\documentclass[11pt,letterpaper]article\usepackageamsmath\usepackageamssymb\usepackageepsfig

% define used "variables"\titleMy revolutionary algorithm\authorJ\’er\^ome Gilles\dateSummer 2012

% content of the paper\begindocument\maketitle

Here is the content of my paper\enddocument

My revolutionary algorithm

Jerome Gilles

Summer 2012

Here is the content of my paper

1

Document Class

LATEX tutorial

\documentclass[options]type of document

Document typearticleletterreportbookspecific (IEEE, SPIE, SIAM,...)

Optionsfont size (10pt,11pt,12pt)paper size (letter,a4paper)twocolumntwoside

Packages

LATEX tutorial

\usepackage[options]package name

Common packages:

global:babel,url,array,fancyheadings,fancybox,fancyhdr,. . .mathematics:amsmath,amsfonts,amssymb,theorem,vector,. . .graphics:graphicx,epsfig,psboxit,pstricks,rotating,. . .

Merging LATEX files

LATEX tutorial

ex2.tex

\documentclass[11pt,letterpaper]report\usepackageamsmath\usepackageamssymb\usepackageepsfig

% define used "variables"\titleMy revolutionary algorithm\authorJ\’er\^ome Gilles\dateSummer 2012

% content of the paper\begindocument\maketitle\includechapter1\includechapter2\enddocument

chapter1.tex

\chapterIntroductionHere is the text corresponding to

my introduction.

chapter2.tex

\chapterOur new approachHere I describe my new amazing

algorithm!

See ex2.pdf

Basics

LATEX tutorial

Reserved symbols

% Comments \ Command. . . Processing block ~ Nonbreaking space

$ Math mode & Alignment tag in arrays# Macro parameter ^ and _ upperscript and subscript

Basics

LATEX tutorial

Reserved symbols

% Comments \ Command. . . Processing block ~ Nonbreaking space

$ Math mode & Alignment tag in arrays# Macro parameter ^ and _ upperscript and subscript

% \% \ \textbackslash. . . \. . .\ ~ \textasciitilde

$ \$ & \&# \# ^ and _ \textasciicircum and \_

Basics: spaces and carriage return

LATEX tutorial

\documentclass[11pt,letterpaper]article

% define used "variables"\titleMy revolutionary algorithm\authorJ\’er\^ome Gilles\dateSummer 2012

% content of the paper\begindocument\maketitle

Thisis a test

on spaces

This is an example of carriage return\\

This is the beginning of a new paragraph.\enddocument

Basics: document structure

LATEX tutorial

Command Comment\part available only for report or book

\chapter available only for report or book\section

\subsection\subsubsection

\paragraph\subparagraph

\appendix indicate the beginning of appendices

Nb: if you want to remove the numbering⇒ put a star between thecommand and the brackets: \chapter*

Basics: font size

LATEX tutorial

\tiny this text is tiny

\scriptsize this text is scriptsize

\footnotesize this text is footnotesize\small this text is small

\normalsize this text is normalsize\large this text is large\Large this text is Large

\LARGE this text is LARGE\huge this text is huge\Huge this text is Huge

Can be use as \largetext or in an environment:

\beginlargetext\endlarge

Basics: font type

LATEX tutorial

\textnormal \normalfont . . . Normal\textbf \bfseries . . . Bold\textit \itshape . . . Italic

\textrm \rmfamily . . . Roman font\textsf \sffamily . . . Sans Serif font\texttt \ttfamily . . . Typewriter font\emph \em . . . Emphasize\textup \upshape . . . Upright\textsl \slshape . . . Slanted\textsc \scshape . . . SMALL CAPITAL

Basics: environments

LATEX tutorial

Some part of the code is specific or must have a temporary property: environment:

\begin ... \end

\begincenterThis text is\\\beginLARGEcentered\endLARGE\endcenter

\beginflushleftThis text is\\\textitaligned on left\endflushleft

\beginflushrightThis text is\\\textscaligned on right\endflushright

This text iscentered

This text isaligned on left

This text isALIGNED ON RIGHT

Listing environments

LATEX tutorial

itemize: unnumbered listing

enumerate: numbered listing

description: description listing

\beginitemize\item[−] first element\item[∗] a star\item a nice bullet\\\enditemize

\beginenumerate\item first property\item second property\\\endenumerate

\begindescription\item[Definition 1:]the first definition\item[Definition 2:]the second definition\enddescription

Crossreferences

LATEX tutorial

Sometimes you want to refer to another section, chapter, equation,figure . . .⇒ \label and \ref commands

\documentclass[11pt,letterpaper]article

% define used "variables"\titleMy revolutionary algorithm\authorJ\’er\^ome Gilles\dateSummer 2012

% content of the paper\begindocument\maketitle\sectionIntroduction\labelsec:introThis is the introduction

\sectionPrincipleAs mentioned in section~\refsec:intro, it

was the introduction.\enddocument

Table and Figure environments

LATEX tutorial

\begintable[!ht]\centering% definition of the table\captionTable legend\labeltab:myTab\endtable

\beginfigure[!ht]\centering% insert your figure\captionFigure legend\labelfig:myFig\endfigure

Option Meaningh “here”: do its best to put the environment closest as possible from the text it is declaredH “HERE”: put the environment exactly heret “top”: put the environment on top of the pageb “bottom”: put the environment on bottom of the pagep “page of float”: put the environment on an extra page without any text

Including images

LATEX tutorial

Needs the package graphicxTwo cases:

use of latex command: accepts only postscript images (.eps)use of pdflatex command: accepts PNG,JPG and PDF files

The 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 degres

Useful variables:

\textwidth,\textheight,\columnwidth

Including images

LATEX tutorial

ex6.tex

\documentclass[11pt,letterpaper]article\usepackagegraphicx

\titleMy revolutionary algorithm\authorJ\’er\^ome Gilles\dateSummer 2012

% content of the paper\begindocument\maketitle

This an example of how we can include figures! (seeFig.~\reffig1 and \reffig2)

\beginfigure[!t]\centering\includegraphics[scale=0.3]lena\captionThis the first figure\labelfig1\endfigure

\beginfigure[!h]\centering\includegraphics[width=\textwidth]latex\captionThis the second figure\labelfig2\endfigure

\enddocument

Figure 1: This the first figure

My revolutionary algorithm

Jerome Gilles

Summer 2012

This an example of how we can include figures! (see Fig. 1 and 2)

Figure 2: This the second figure

1

Including tables

LATEX tutorial

Needs the package tabular (array in math mode)A table is defined from the commands:

\begintabular[pos]columns definition \hlinexxx & xxx & ... & \\yyy & yyy & ... & \\ \hline\endtabular

pos⇔ see table environment

columns can be defined by:l: element are left justifiedr: element are right justifiedc: element are centered|: put a vertical barpw: a column of width w

\hline draw an horizontal line

Each column elements on asame row are separated by the &symbol

Including tables

LATEX tutorial

ex6.tex

\documentclass[11pt,letterpaper]article\usepackagearray

\titleMy revolutionary algorithm\authorJ\’er\^ome Gilles\dateSummer 2012

% content of the paper\begindocument\maketitle

\begintable[!h]\centering\begintabular|l|c|p5cm| \hlineA & B & end of first row \\ \hlineCGHIJ & & D \\E & FKL & end of table \\ \hline\endtabular\endtable

\enddocument

My revolutionary algorithm

Jerome Gilles

Summer 2012

A B end of first row

CGHIJ DE FKL end of table

1

Other usefull commands:

\multicolumn,\multirow,\backslashbox

Mathematics in LATEX

LATEX tutorial

Needs (at least) packages amsmath,amsfonts,amssymb

Two cases: equation embedded in ($...$) the text or equation onseparate line (\beginequation ... \endequation).

\documentclass[11pt,letterpaper]article\usepackageamsmath,amsfonts,amssymb

\begindocumentThe Cartesian equation of a straight line is of the form $ax+by+c=0$ where $a,b,c$ are

constants.\enddocument

Mathematics in LATEX

LATEX tutorial

Needs (at least) packages amsmath,amsfonts,amssymb

Two cases: equation embedded in the text ($...$) or equation onseparate line (\beginequation ... \endequation).

\documentclass[11pt,letterpaper]article\usepackageamsmath,amsfonts,amssymb

\begindocumentThe Cartesian equation of a straight line is

of the form\beginequationax+by+c=0\endequationwhere $a,b,c$ are constants.\enddocument

Mathematics in LATEX

LATEX tutorial

Special fonts

\mathbb... blackboard alphabet: A,B,N,R,Z\mathcal... calligraphied alphabet: A,B,N ,R,Z\mathbf... bold alphabet: A,B,N,R,Z\mathit... italic alphabet: A,B,N,R,Z

Special symbols

\hata a \acutea a \bara a \dota a \brevea a\checka a \gravea a \veca ~a \ddota a \tildea a

\overleftarrowabc←−−abc \overrightarrowabc

−−→abc

\overlineabc abc \underlineabc abc\widetildeabc abc \widehatabc abc

\xrightarrow\textabc abc−−→ \xleftarrow\textabc abc←−−

\overbraceabc︷︸︸︷abc \underbraceabc abc︸︷︷︸

Mathematics in LATEX

LATEX tutorial

Greek letters

\alpha α \beta β \gamma γ \delta δ\theta θ \vartheta ϑ \iota ι \kappa κ

\lambda λ \mu µ \nu ν \xi ξ\pi π \varpi $ \rho ρ \varrho %

\sigma σ \varsigma ς \tau τ \upsilon υ\phi φ \varphi ϕ \chi χ \psi ψ

\omega ω \Gamma Γ \Delta ∆ \Theta Θ\Lambda Λ \Xi Ξ \Pi Π \Sigma Σ\Upsilon Υ \Phi Φ \Psi Ψ \Omega Ω

Variable sized symbols

\sum∑

\prod∏

\int∫

\oint∮

\bigcap⋂

\bigcup⋃

Mathematics in LATEX

LATEX tutorial

Standard 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 subscript

x_i xi x^i x i

x_i-1^j-1 x j−1i−1 x_u_n xun

Fraction

\fracnumden, Ex: \frac3x+11-x^2 gives 3x+11−x2

Roots

\sqrt[n]arg, Ex: \sqrt[q]1-x^2 gives q√

1− x2

\sqrtx+3 gives√

x + 3

Mathematics in LATEX: sums, products and integrals

LATEX tutorial

\documentclass[11pt,letterpaper]article\usepackageamsmath,amsfonts,amssymb,wasysym

\begindocument\beginequation\sum_k=1^n k=\fracn(n+1)2\endequation

\beginequation\prod_k=1^m k=m!\endequation

\beginequation\int_0^+\infty x^n e^−xdx=n!\endequation

\beginequation\oiint_\partial \Omega

(\mathbfF\bullet\mathbfn)dS=\iiint_\Omega(\nabla\bullet\mathbfF)dV

\endequation\enddocument

Mathematics in LATEX

LATEX tutorial

Derivatives

\fracdfdx dfdx \fracd^nfdx^n dnf

dxn

\frac\partial f\partial x ∂f∂x \frac\partial^nf\partial x^n ∂nf

∂xn

Absolute values and norms

|x| gives |x | \|x\| gives ‖x‖

Mathematics in LATEX

LATEX tutorial

Matrices

\documentclass[11pt,letterpaper]article\usepackageamsmath,amsfonts,amssymb

\begindocument

\beginequation\beginpmatrixa_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_m,n\endpmatrix\endequation

\beginequation\beginvmatrixa_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_m,n\endvmatrix\endequation

\enddocument

Mathematics in LATEX

LATEX tutorial

Group of equations

\documentclass[11pt,letterpaper]article\usepackageamsmath,amsfonts,amssymb

\begindocument\begingather\fracddx(f(x)+g(x))=\fracdfdx(x)+\fracdgdx(x)\\\fracddx(f(x)g(x))=f(x)\fracdgdx(x)+g(x)\fracdfdx(x)\endgather

\beginalign\fracddx(f(x)+g(x))&=\fracdfdx(x)+\fracdgdx(x)\\\fracddx(f(x)g(x))&=f(x)\fracdgdx(x)+g(x)\fracdfdx(x)\endalign

\beginequation\chi(x)=\begincases0 \qquad \textif \quad x\geqslant 0\\1 \qquad \textif \quad x< 0\endcases\endequation\enddocument

Mathematics in LATEX

LATEX tutorial

TheoremsNeeds the package theorem. We first specify the different kind ofstatements (before the \begindocument) with the command\newtheoremthmTheorem and then we use the command\beginthm. . .\endthm\documentclass[11pt,letterpaper]article\usepackageamsmath,amsfonts,amssymb\usepackagetheorem

\newtheoremthmTheorem

\begindocument

\beginthmThe sum of the angles of a triangle is $\pi$\endthm

\enddocument

Bibliography

LATEX tutorial

Original approach: bibitem

\documentclass[11pt,letterpaper]article

\begindocumentIn \citeles85, the authors propose to ... while in \citedon89 ...

\beginthebibliography99\bibitemles85 Leslie Lamport, 1985. \emph\LaTeX−−A Document Preparation System−−User’s Guide and

Reference Manual,Addison−Wesley, Reading.\bibitemdon89 Donald E. Knuth, 1989. \emphTypesetting Concrete Mathematics, TUGBoat, 10(1):31−36.\endthebibliography

\enddocument

Bibliography

LATEX tutorial

Advanced approach: BIBTEXReferences are contained in an external “mybiblio.bib” file which will be called by thecommand \bibliographymybiblio.We must specify a bibliography style by using \bibliographystylestyle where the most usedstyles are

plain: Standard BIBTEX 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 abbreviated.

\documentclass[11pt,letterpaper]article

\begindocumentIn \citeles85, the authors propose to ...

\bibliographystyleplain\bibliographymybiblio

\enddocument

Steps to generate the bibliography

1 Run LATEX: list of \cite ref in the .aux file,

2 Run BIBTEX: extract the cited ref from the .bib file,format and save them in the .bbl file,

3 Run LATEX again: read the .bbl file,

4 Run LATEX a third time to resolve all references.

Bibliography

LATEX tutorial

BIBTEX databaseEach reference is described in the following way:

@entry_typekey,field_name = field text,...field_name = field text

article entry for an article from a journal or magazinerequired fields: author, title, journal, yearoptional fields: volume, number, pages, month, note.

book entry for a book with a definite publisherrequired fields: author or editor, title, publisher, yearoptional fields: volume or number, series, address, edition, month, note

conference entry for an article in conference proceedingsrequired fields: author, title, booktitle, yearoptional fields: editor, volume or number, series, pages, address, month, ...

Bibliography

LATEX tutorial

.bib file

@ARTICLEGilles2010a,author = J\’er\^ome Gilles and Yves Meyer,title = Properties of BV−G structures + textures decomposition models. Application

to road detection in satellite images,journal = IEEE Transaction in Image Processing,year = 2010,volume = 19,pages = 2793−−2800,number = 11

@BOOKTriebel3,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/)

Other useful formatting tools

LATEX tutorial

Table of Content (ToC)Just add the command \tableofcontents where you want to seeyour ToC!

Lists of figures or tables

Just add the command \listoffigures or \ listoftables

FootnotesUse \footnoteyour note

Page, line break

Use \newpage or \linebreak

Algorithm - Pseudocode

See packages algorithm, algorithmic,listings

Presentations: the Beamer class

LATEX tutorial

\documentclassbeamer\mode<presentation>

\usethemeWarsaw

\title\LaTeX\ tutorial

\author[]J\’er\^ome Gilles\institute[UCLA]Department of Mathematics, UCLA\\jegilles@math.ucla.edu\date

\begindocument...\enddocument

Presentations: the Beamer class

LATEX tutorial

Slides: the frame environment

\beginframe\titlepage\end frame

\beginframeTitle

\end frame

Group of elements: the block environment

\beginblockblock titleElements of this block\endblock

Presentations: the Beamer class

LATEX tutorial

Positioning: the textblock environment

Need first to define a “virtual” grid (before \begindocument)

\usepackage[overlay,absolute]textpos

\TPGrid2020\textblockorigin0mm0mm\setlength\parindent0pt

\begintextblockwidth(x,y)

\endtextblock

Presentations: Overlays

LATEX tutorial

The pause command

\beginitemize\item First item\pause\item Second item\item Third item\pause\item Forth item\enditemize

General overlay specificationsWe can specify overlay specificationsby associating <spec> to somecommands like:

\textbfAllways bold\textbf<2−>Bold from the second slide

Notations:

<N>⇔ on slide N only,

<-N>⇔ from first slide to slide N,

<N->⇔ from slide N,

<N-M>⇔ from slide N to slide M.

\beginitemize\item<1−> First point\item<2| alert@2> Second

only point\item<3−> Third point\enditemize

Presentations: Overlays

LATEX tutorial

Incremental specifications

\beginitemize\item<+−| alert@+> First item\item<+−| alert@+> Second

item\item<+−| alert@+> Third item\item<+−| alert@+> Forth item\enditemize

. . . equivalent to

\beginitemize[<+−| alert@+>]\item First item\item Second item\item Third item\item Forth item

\enditemize

overlay on a block

\only<1−>\begintextblock15(2,2)\beginblockTop blockHere is the block I want to see from the first slide\endblock\endtextblock

\only<2−>\begintextblock18(6,6)\includegraphics[scale=0.3]lena\endtextblock

Useful links about LATEX

LATEX tutorial

LATEX wikibook: http://en.wikibooks.org/wiki/LaTeX

Symbol list: http://mirrors.ctan.org/info/symbols/comprehensive/symbols-letter.pdf

Beamer manual: http://www.ctan.org/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf

LATEX Tutorial: http://www.tug.org.in/tutorials.html

top related