Top Banner
Beginner’s L A T E X Tutorial Imran Rashid lots borrowed from Marius October 2, 2007
73

Latex Tutorials for Beginners

Apr 03, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Latex Tutorials for Beginners

Beginner’s LATEX Tutorial

Imran Rashidlots borrowed from Marius

October 2, 2007

Page 2: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 3: Latex Tutorials for Beginners

caveat

I Goal —Get beginners familiar with using latex

I I am not a Latex expert (but I do use it a lot)

I focus on demos – lots of references online

I I will not cover advanced features

Page 4: Latex Tutorials for Beginners

caveat

I Goal —Get beginners familiar with using latex

I I am not a Latex expert (but I do use it a lot)

I focus on demos – lots of references online

I I will not cover advanced features

Page 5: Latex Tutorials for Beginners

caveat

I Goal —Get beginners familiar with using latex

I I am not a Latex expert (but I do use it a lot)

I focus on demos – lots of references online

I I will not cover advanced features

Page 6: Latex Tutorials for Beginners

caveat

I Goal —Get beginners familiar with using latex

I I am not a Latex expert (but I do use it a lot)

I focus on demos – lots of references online

I I will not cover advanced features

Page 7: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 8: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 9: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 10: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 11: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 12: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 13: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 14: Latex Tutorials for Beginners

Why Use Latex?

I Great for typesetting math

I automated placement of figures & tables

I automatic generation of references to tables, figures,bibliographies

I free and universal

I separate content from layout

I Can create documents, slides, etc.

I Pretend to be a theory student

Page 15: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /

tools(?)

compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 16: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 17: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logically

not WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 18: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout

√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 19: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 20: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 21: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful

steep learning curve

collaborators may not know latex

Page 22: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 23: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

Page 24: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

/ Latex can be very intimidating /

Page 25: Latex Tutorials for Beginners

The Good, The Bad, . . .

, /tools(?) compile, debug, view, edit

write logicallynot WYSIWYG

latex will take care of layout√tβx

λx :Px8

n=1 log(ρ⊗x)

automated content

extremely powerful steep learning curve

collaborators may not know latex

/ Latex can be very intimidating /

, Hopefully this talk will help ,

Page 26: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 27: Latex Tutorials for Beginners

Latex Commands

Two basic forms:

1. \SomeCommand{AnArgument}2. \begin{SomeEnvironment}

. . .\end{SomeEnvironment}

Page 28: Latex Tutorials for Beginners

\documentclass [arguments] {type of document}package importsglobal definitionsother settings\begin{document}

document contents: text, LATEX commands\end{document}

Page 29: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 30: Latex Tutorials for Beginners

Latex Tools

Tools exist for most platforms to make working with latex easier:

I makefile

I mode for emacs

I IDEs for every platform

I will demo TexnicCenter, an IDE for windows

More options listed in Resources at the end

Page 31: Latex Tutorials for Beginners

Latex Tools

Tools exist for most platforms to make working with latex easier:

I makefile

I mode for emacs

I IDEs for every platform

I will demo TexnicCenter, an IDE for windows

More options listed in Resources at the end

Page 32: Latex Tutorials for Beginners

Latex Tools

Tools exist for most platforms to make working with latex easier:

I makefile

I mode for emacs

I IDEs for every platform

I will demo TexnicCenter, an IDE for windows

More options listed in Resources at the end

Page 33: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 34: Latex Tutorials for Beginners

Math Mode

By default, LaTex is in “text” mode. Have to switch to math touse math mode:

I Use $ ... $ in the middle of a text-block

I Use \ [ ... \ ] to insert a block of math

I Use \begin{align} ... \end{align} to have alignedequations

Page 35: Latex Tutorials for Beginners

Math Mode

By default, LaTex is in “text” mode. Have to switch to math touse math mode:

I Use $ ... $ in the middle of a text-block

I Use \ [ ... \ ] to insert a block of math

I Use \begin{align} ... \end{align} to have alignedequations

Page 36: Latex Tutorials for Beginners

Math Mode

By default, LaTex is in “text” mode. Have to switch to math touse math mode:

I Use $ ... $ in the middle of a text-block

I Use \ [ ... \ ] to insert a block of math

I Use \begin{align} ... \end{align} to have alignedequations

Page 37: Latex Tutorials for Beginners

Lists

\begin{itemize}item ...item ...

\end{itemize}

can use enumerate instead of itemize

Page 38: Latex Tutorials for Beginners

Tables

\begin{table}\centering

\begin{tabular}{

|c|r

}

Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 39: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{

|c|r

}

Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 40: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{

|c|r

}

Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}

\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 41: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}

Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}

\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 42: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}Height & Weight \\

\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}

\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 43: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}Height & Weight \\\hline

5.4 & 160 \\6.1 & 234 \\

\end{tabular}

\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 44: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}Height & Weight \\\hline5.4 & 160 \\

6.1 & 234 \\

\end{tabular}

\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 45: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}

\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 46: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 47: Latex Tutorials for Beginners

Tables\begin{table}\centering

\begin{tabular}{|c|r}Height & Weight \\\hline5.4 & 160 \\6.1 & 234 \\

\end{tabular}\caption{Some text that is a caption for the table}\label{tableLabel}

\end{table}

Height Weight

5.4 1606.1 234

Table: Some text that is a caption for the table

Page 48: Latex Tutorials for Beginners

Adding figures to your documents

Use the graphicx package

\begin{figure}\centering

\includegraphics{filename}\caption{the caption text}\label{label for cross-refs}

\end{figure}

I With latex → ps → PDF, can only use postscript graphics

I With latex → pdf, can use anything but postscript (pdf, jpgs,png, tiff)

Page 49: Latex Tutorials for Beginners

Adding figures to your documents

Use the graphicx package

\begin{figure}\centering

\includegraphics{filename}\caption{the caption text}\label{label for cross-refs}

\end{figure}

I With latex → ps → PDF, can only use postscript graphics

I With latex → pdf, can use anything but postscript (pdf, jpgs,png, tiff)

Page 50: Latex Tutorials for Beginners

Use * to control numbering

Often adding a * to the end of a command will turn offauto-numbering:

\begin{align}x &= 1 + 1 \\

&= 2\\\end{align}

x = 1 + 1 (1)

= 2 (2)

vs:\begin{align*}

x &= 1 + 1 \\&= 2\\

\end{align*}x = 1 + 1

= 2

Page 51: Latex Tutorials for Beginners

Use * to control numbering

Often adding a * to the end of a command will turn offauto-numbering:\begin{align}

x &= 1 + 1 \\&= 2\\

\end{align}

x = 1 + 1 (1)

= 2 (2)

vs:\begin{align*}

x &= 1 + 1 \\&= 2\\

\end{align*}x = 1 + 1

= 2

Page 52: Latex Tutorials for Beginners

Use * to control numbering

Often adding a * to the end of a command will turn offauto-numbering:\begin{align}

x &= 1 + 1 \\&= 2\\

\end{align}x = 1 + 1 (1)

= 2 (2)

vs:\begin{align*}

x &= 1 + 1 \\&= 2\\

\end{align*}x = 1 + 1

= 2

Page 53: Latex Tutorials for Beginners

Use * to control numbering

Often adding a * to the end of a command will turn offauto-numbering:\begin{align}

x &= 1 + 1 \\&= 2\\

\end{align}x = 1 + 1 (1)

= 2 (2)

vs:\begin{align*}

x &= 1 + 1 \\&= 2\\

\end{align*}

x = 1 + 1

= 2

Page 54: Latex Tutorials for Beginners

Use * to control numbering

Often adding a * to the end of a command will turn offauto-numbering:\begin{align}

x &= 1 + 1 \\&= 2\\

\end{align}x = 1 + 1 (1)

= 2 (2)

vs:\begin{align*}

x &= 1 + 1 \\&= 2\\

\end{align*}x = 1 + 1

= 2

Page 55: Latex Tutorials for Beginners

Referencing Tables and Figures in the text

1. Use \label{aLabelName} in your figures and tables

2. In the text, reference them with \ref{aLabelName}3. run latex twice

4. Reorganize your figures as much as you want – numbering willalways be correct.

Example: Here is a reference to Table 1.

Page 56: Latex Tutorials for Beginners

Referencing Tables and Figures in the text

1. Use \label{aLabelName} in your figures and tables

2. In the text, reference them with \ref{aLabelName}

3. run latex twice

4. Reorganize your figures as much as you want – numbering willalways be correct.

Example: Here is a reference to Table 1.

Page 57: Latex Tutorials for Beginners

Referencing Tables and Figures in the text

1. Use \label{aLabelName} in your figures and tables

2. In the text, reference them with \ref{aLabelName}3. run latex twice

4. Reorganize your figures as much as you want – numbering willalways be correct.

Example: Here is a reference to Table 1.

Page 58: Latex Tutorials for Beginners

Referencing Tables and Figures in the text

1. Use \label{aLabelName} in your figures and tables

2. In the text, reference them with \ref{aLabelName}3. run latex twice

4. Reorganize your figures as much as you want – numbering willalways be correct.

Example: Here is a reference to Table 1.

Page 59: Latex Tutorials for Beginners

Referencing Tables and Figures in the text

1. Use \label{aLabelName} in your figures and tables

2. In the text, reference them with \ref{aLabelName}3. run latex twice

4. Reorganize your figures as much as you want – numbering willalways be correct.

Example: Here is a reference to Table 1.

Page 60: Latex Tutorials for Beginners

See BibTeX

Page 61: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 62: Latex Tutorials for Beginners

Latex Packages

I LOTS of great functionality in packages (for example,including graphics)

I MikTeX has a built in package manager — very useful.

I see here (http://www.math.uiuc.edu/ hildebr/tex/customstyles.html) for doing itmanually. (sorry this isn’t a very good answer ... if you reallyneed to do this, I’d suggest first trying to find somebody thatdoes this themselves, I always use a package manager.)

Page 63: Latex Tutorials for Beginners

Outline

Why Latex

Basics

Tools

FeaturesMath ModeListsTablesFiguresNumberingReferencesBibliographies with BibTeX

Using Latex Packages

Resources

Page 64: Latex Tutorials for Beginners

Using Make (from Marius)

SOURCES=$(wildcard *.tex)all: pdfpdf: $(SOURCES:.tex=.pdf)ps: $(SOURCES:.tex=.ps)dvi: $(SOURCES:.tex=.dvi)%.dvi: %.tex

latex $<; latex $<%.ps: %.dvi

dvips $< -o $@%.pdf: %.ps

ps2pdf $<

Building PDFs becomes a matter of

$ make hello.pdf

assuming that hello.tex exists.

Page 65: Latex Tutorials for Beginners

Miscellaneous Tips

1. Symbols need to be in math mode — use the $...$.

2. Don’t mess with spacing too much — try to let latex do it foryou.

3. Format your source code.

4. Don’t freak out if you have 100 errors — you probably forgota \end{} or a $.

5. Compile often; if there are a lot of problems, try to narrow itdown piecemeal.

6. Use the other grad students

Page 66: Latex Tutorials for Beginners

Miscellaneous Tips

1. Symbols need to be in math mode — use the $...$.

2. Don’t mess with spacing too much — try to let latex do it foryou.

3. Format your source code.

4. Don’t freak out if you have 100 errors — you probably forgota \end{} or a $.

5. Compile often; if there are a lot of problems, try to narrow itdown piecemeal.

6. Use the other grad students

Page 67: Latex Tutorials for Beginners

Miscellaneous Tips

1. Symbols need to be in math mode — use the $...$.

2. Don’t mess with spacing too much — try to let latex do it foryou.

3. Format your source code.

4. Don’t freak out if you have 100 errors — you probably forgota \end{} or a $.

5. Compile often; if there are a lot of problems, try to narrow itdown piecemeal.

6. Use the other grad students

Page 68: Latex Tutorials for Beginners

Miscellaneous Tips

1. Symbols need to be in math mode — use the $...$.

2. Don’t mess with spacing too much — try to let latex do it foryou.

3. Format your source code.

4. Don’t freak out if you have 100 errors — you probably forgota \end{} or a $.

5. Compile often; if there are a lot of problems, try to narrow itdown piecemeal.

6. Use the other grad students

Page 69: Latex Tutorials for Beginners

Miscellaneous Tips

1. Symbols need to be in math mode — use the $...$.

2. Don’t mess with spacing too much — try to let latex do it foryou.

3. Format your source code.

4. Don’t freak out if you have 100 errors — you probably forgota \end{} or a $.

5. Compile often; if there are a lot of problems, try to narrow itdown piecemeal.

6. Use the other grad students

Page 70: Latex Tutorials for Beginners

Miscellaneous Tips

1. Symbols need to be in math mode — use the $...$.

2. Don’t mess with spacing too much — try to let latex do it foryou.

3. Format your source code.

4. Don’t freak out if you have 100 errors — you probably forgota \end{} or a $.

5. Compile often; if there are a lot of problems, try to narrow itdown piecemeal.

6. Use the other grad students

Page 71: Latex Tutorials for Beginners

Useful Packages

I amsmath — gives the align command plus other useful stuff

I amsthm — lemma, etc.

I algpseudocode, algorithm — code formatting

I graphicx — inserting figures (eps, jpg, png, etc.) into yourlatex documents

I subfig — organizing subfigures

I hyperref — putting links into your pdfs

I beamer — slides.

I prosper — more slides (provides transitions, but I thinkbeamer is easier). here (http://prosper.sourceforge.net/). Nice collectionof documentation (http://amath.colorado.edu/documentation/LaTeX/prosper/).

I multirow — spanning rows and columns in tables

I wasysym — some extra symbols (smileys)

Page 72: Latex Tutorials for Beginners

Useful Resources

I cheat sheet — (http://www.stdout.org/ winston/latex/)

I Latex primer — http://www.maths.tcd.ie/%7Edwilkins/LaTeXPrimer/

I (http://www.math.uiuc.edu/ hildebr/tex/) bunch of tips, mostly focused ontheorems, etc.

I help page #1 — (http://web.image.ufl.edu/help/latex/) good as abeginners reference

I help page #2 —(http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/teTeX/latex/latex2e-html/ltx-2.html) goodif you know the command name

I Bibtex reference —(http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.html)

I Random blog (http://andrewjpage.com/index.php?/categories/2-Latex) with somehandy tips

I Google —

Page 73: Latex Tutorials for Beginners

Useful Tools

I MikTeX — (http://miktex.org/) latex distribution + packagemanager

I TeXnicCenter — (http://texniccenter.sourceforge.net/front content.php) IDE forwindows

I AucTex — (http://www.gnu.org/software/auctex/) mode for latexauthoring in emacs (from Marius)

I TeXShop — (http://www.uoregon.edu/ koch/texshop/) IDE for latex onMac (from Krzysztof et. al)

I Kile — (http://kile.sourceforge.net/) IDE for linux

I JabRef — (http://jabref.sourceforge.net/) for managing yourbibliographies (from Julie)

I Many others out there ... consult your local tex guru