Upload
awverret
View
421
Download
1
Embed Size (px)
DESCRIPTION
Contains info on Latex, a motivation for using it, and everything you need to know in order to create your first document.
Citation preview
LaTeX Basics
Aubry Verret
October 22, 2013
What is LATEX?
Definition
La-tex [lah-tek or lay-tek]-nounA powerful document markup system that uses theTeX typesetting program. The current version isLaTeX2e.
LATEXPhilosophy
Content and Styling should remain separate.
The author writes the content. LaTeX takes care offormatting details like margins, indentation, andlayout.
Who uses LATEX?
Users include:
I Journals and conferences primarily in scientificand technical disciplines
I Researchers publishing in a scientific, technicalfield(mathematics, physics, computer science,engineering), or humanities field
I Students studying in a scientific, technical, orhumanities discipline
How does it work?
Why use LATEX?
LATEXis:
I Free and easy to get
I Platform independent
I Flexible
I Capable of superior typographical output
I Well suited to typesetting mathematics
When should you use LATEX?
Getting LaTeX
I Windows - Miktex(http://www.miktex.org/ or ProTeXhttp://www.tug.org/protext/)
I Mac - MacTeX(http://www.tug.org/mactex/2009/)
I Linux - TeX Live(http://www.tug.org/texlive/)
Getting LaTeX
I Windows - Miktex(http://www.miktex.org/ or ProTeXhttp://www.tug.org/protext/)
I Mac - MacTeX(http://www.tug.org/mactex/2009/)
I Linux - TeX Live(http://www.tug.org/texlive/)
Getting LaTeX
I Windows - Miktex(http://www.miktex.org/ or ProTeXhttp://www.tug.org/protext/)
I Mac - MacTeX(http://www.tug.org/mactex/2009/)
I Linux - TeX Live(http://www.tug.org/texlive/)
Specialized Editors
Many free editors are available:
I LED (http://www.latexeditor.org/)
I TeXnicCenter (http://www.texniccenter.org/)
I TeXWorks (http://www.tug.org/texworks/)
I TeXMaker (http://www.xm1math.net/texmaker/)
I Winedt (http://www.winedt.com/)
I TeXlipse-Eclipse plug-in(http://texlipse.sourceforge.net/)
LED
TeXWorks
Lyx
The Lyx document processor:
I Utilizes the TeX language
I Offers a graphical user interface
I Offers full support for document features such as equations,bibliographies, indexes, etc.
I Is designed for those who prefer to use LaTeX like a wordprocessor
www.lyx.org
Lyx
Getting Started
To open the TeXnic Center program go to:
Start → Programs → TeXnic Center
Open a new document and save it.
TeX files
Download tex files here:http://www2.lib.virginia.edu/brown/
rescomp/latex/practice.zip
TeXnicCenter
LATEXCommands
Example: \documentclass[10pt]{article}
Example: \begin{document}
LATEXCommands
Example: \documentclass[10pt]{article}
Example: \begin{document}
LATEXCommands
Example: \documentclass[10pt]{article}
Example: \begin{document}
Preamble - particle.tex
Building the project
Preamble Output
Document Classes
I article - shorter works such as papers for class,conference submissions, and journal articles
I report - longer works such as dissertations,theses, or short books
I book - long works with many sections orchapters
I letter - provides special structure for variousaspects of a letter
Adding Text - particle2.tex
Output
Sectioning Commands
\section{}\subsection{}\subsubsection{}
\paragraph{}\subparagraph{}\subsubparagraph{}
\chapter{}\part{}
Sectioning Commands Example - particle3.tex
Output
Itemized Lists
\begin{itemize}
\item One
\item Two
\item Three
\end{itemize}
I One
I Two
I Three
Enumerated Lists
\begin{enumerate}
\item One
\item Two
\item Three
\end{enumerate}
1. One
2. Two
3. Three
List Example - particle4.tex
Output
Footnotes
\footnote[number]{text}
I Automatically numbered
I Provides an optional argument for overridingautomatic numbering
Footnote Example - particle5.tex
Output
Table of Contents
\tableofcontents
I Requires no input
I Is placed where you want the ToC to appear
I Utilizes sectioning commands
ToC Example - particle6.tex
ToC Output
Bibliographies
BibTeX is used with LATEXto generate bibliographies.
1. Place bib entries in a separate .bib file
2. Reference the entries in the .tex file
3. Compile both files to generate the bibliography and references
Bib Entries
Bib file entry
@Book{Brooks 03 ,a u t h o r = {Max Brooks } ,t i t l e = {The Zombie S u r v i v a l Guide } ,p u b l i s h e r = {Three R i v e r s P r e s s } ,y e a r = {2003} ,i s b n = {1400049628} ,note = {Complete p r o t e c t i o n from t he l i v i n g dead .}}
Citations
Tex file citation
For more information on attack methods, please consult TheZombie Survival Guide\cite{Brooks03}.
Include these commands at the end of the tex file:
\bibliography{bib file name}\bibliographystyle{style name}
Building the Bibliography
Output
Bibliography Example - particle7.tex
Bibliography Example - particle.bib
Running BibTeX in TeXnicCenter
Output
Bibliography Assistance
External bibliography software:
I Jabref - free, easy to use with BibTeX
I RefWorks
I Endnote
Jabref
Mathematics
LATEXmust be put into math mode before usingmathematical symbols
Math environments:
I Math - short in-line equations
I Displaymath - equations set apart in text
I Equation - numbered and centered equations
Mathematics
LATEXmust be put into math mode before usingmathematical symbols
Math environments:
I Math - short in-line equations
I Displaymath - equations set apart in text
I Equation - numbered and centered equations
Mathematics
LATEXmust be put into math mode before usingmathematical symbols
Math environments:
I Math - short in-line equations
I Displaymath - equations set apart in text
I Equation - numbered and centered equations
Mathematics
LATEXmust be put into math mode before usingmathematical symbols
Math environments:
I Math - short in-line equations
I Displaymath - equations set apart in text
I Equation - numbered and centered equations
Math Environments
Math
I \begin{math}...\end{math}I $...$
Displaymath
I \begin{displaymath}...\end{displaymath}I $$...$$
Equation
I \begin{equation}...\end{equation}
Mathematical Notation
Example:
∮∂S
B · dl = µo IS + µoεo∂ΦE ,S
∂t
$$\ o int {\ p a r t i a l S}B\cdotp d l = \mu o I S + \mu o\ e p s i l o n o \ f r a c {\ p a r t i a l \Phi {E , S}}{\ p a r t i a l t } $$
More Examples
Example:
∞∑n=0
f n(a)
n!(x − a)n
$$\sum^{\infty}_{n=0} \frac{f^{n}(a)}{n!}(x - a)^n$$
¬(p ∨ q)⇐⇒ (¬p) ∧ (¬q)
$$\neg (p \vee q) \Longleftrightarrow (\neg p)
\wedge (\neg q) $$
More Examples
Example (Matrices)a11 a12 · · · a1na21 a22 · · · a2n
......
. . ....
an1 an2 · · · ann
x1x2...xn
=
00...0
$$\left[ \begin{array}{cccc}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & \cdots & a_{nn} \end{array} \right]
\left[ \begin{array}{c}
x_1 \\ x_2 \\ \vdots \\
x_n \end{array} \right] = \left[ \begin{array}{c}
0 \\ 0 \\ \vdots \\ 0 \end{array} \right]$$
Math Assistance
You can find:
I Binary operators
I Trig functions
I Set notation
I Greek Symbols
I Delimeters
and more here : http://web.ift.uib.no/
Fysisk/Teori/KURS/WRK/TeX/symALL.html
Math Example - particle8.tex
Output
Amsmath Package
If you use mathematics heavily in your documents,you might consider using the amsmath package. Itprovides some enhancements to the normal LaTeXmath capabilities which make typesetting formulaseasier and more attractive.
Go here for more info:
http://www.ams.org/tex/amslatex.html
Packages
LATEXpackages are add-ons that provide added ormodified styling features to your document
I color- enables you to typeset in color
I babel- offers support for other languages
I hyperref- provides support for url’s in adocument
Include the following command in the preamble:
\usepackage{package name}
Graphics
LATEXuses the package graphicx to manage graphics
\include{graphicx}
This package allows you to:
I Use several file formats
I Scale images
I Crop images
I Rotate images
Image formats
Using the latex command:
I EPS format
Using the pdflatex command:
I JPG
I PNG
I PDF
Inserting Graphics
Insert graphics using:
\includegraphics[options]{image file}
Options include:
I width and height
I scale
I rotation angle
I trim
Example Graphic:
\includegraphics[scale = .5]{science cat}
Example Graphic:
\includegraphics[scale = .5, angle = 90]{science cat}
Figures
Include figures using the figure environment:
\begin{figure}...\end{figure}
Placement options:
I h - here
I t - top of page
I b - bottom of page
I p - separate page
Example Figure
\begin{figure}
\centering
\includegraphics{graphics/participants-pie}
\caption{Registrants for this class}
\end{figure}
Output
Figure: Registrants for this class
Example Figure - particle9.tex
Output
Referencing Figures
Inside the figure environment include:\label{fig:Figure name}
\begin{figure}
\centering
\includegraphics{figure}
\caption{Place caption here}
\label{fig:figure}
\end{figure}
Reference the figure in text with:\ref{fig:Figure name}
Referencing Figures
Inside the figure environment include:\label{fig:Figure name}
\begin{figure}
\centering
\includegraphics{figure}
\caption{Place caption here}
\label{fig:figure}
\end{figure}
Reference the figure in text with:\ref{fig:Figure name}
Referencing Figures
Inside the figure environment include:\label{fig:Figure name}
\begin{figure}
\centering
\includegraphics{figure}
\caption{Place caption here}
\label{fig:figure}
\end{figure}
Reference the figure in text with:\ref{fig:Figure name}
How to Make A Table
To make a table in LATEX use the tabular environment:
\begin{tabular}...\end{tabular}
Separate columns with the ”&” symbol
Separate rows with the double backslash ”\\”
How to Make A Table
To make a table in LATEX use the tabular environment:
\begin{tabular}...\end{tabular}
Separate columns with the ”&” symbol
Separate rows with the double backslash ”\\”
Tabular Layout
Specify the column layout when you call tabular:
\begin{tabular}{l|l|l}
Vertical bars produce vertical lines between columns.
Alignment Symbols
I l - align left
I r - align right
I c - centered
Tables
\begin{tabular}{ l | l | l }
Class & Species & Lays eggs? \\
mammal & lion & \XSolidBrush \\
mammal & tiger & \XSolidBrush \\
mammal & platypus & \Checkmark \\
reptile & iguana & \Checkmark \\
reptile & snake & \Checkmark \\
aves & flamingo & \Checkmark \\
\end{tabular}
Class Species Lays eggs?
mammal lion %
mammal tiger %
mammal platypus !
reptile iguana !
reptile snake !
aves flamingo !
TablesChange alignments:
\begin{tabular}{| l | r | c | }
Class & Species & Lays eggs? \\
mammal & lion & \XSolidBrush \\
mammal & tiger & \XSolidBrush \\
mammal & platypus & \Checkmark \\
reptile & iguana & \Checkmark \\
reptile & snake & \Checkmark \\
aves & flamingo & \Checkmark \\
\end{tabular}
Class Species Lays eggs?
mammal lion %
mammal tiger %
mammal platypus !
reptile iguana !
reptile snake !
aves flamingo !
TablesAdd horizontal lines:
\begin{tabular}{| l | r | c | } \hline
Class & Species & Lays eggs? \\ \hline\hline
mammal & lion & \XSolidBrush \\ \hline
mammal & tiger & \XSolidBrush \\ \hline
mammal & platypus & \Checkmark \\ \hline
reptile & iguana & \Checkmark \\ \hline
reptile & snake & \Checkmark \\ \hline
aves & flamingo & \Checkmark \\ \hline
\end{tabular}
Class Species Lays eggs?
mammal lion %
mammal tiger %
mammal platypus !
reptile iguana !
reptile snake !
aves flamingo !
TablesNot so many:
\begin{tabular}{| l | r | c | } \hline
Class & Species & Lays eggs? \\ \hline\hline
mammal & lion & \XSolidBrush \\
& tiger & \XSolidBrush \\
& platypus & \Checkmark \\ \hline
reptile & iguana & \Checkmark \\
& snake & \Checkmark \\ \hline
aves & flamingo & \Checkmark \\ \hline
\end{tabular}
Class Species Lays eggs?
mammal lion %
tiger %
platypus !
reptile iguana !
snake !
aves flamingo !
TablesPartial hlines
\begin{tabular}{| l | r | c | } \hline
Class & Species & Lays eggs? \\ \hline\hline
mammal & lion & \XSolidBrush \\ \cline{2-3}
& tiger & \XSolidBrush \\ \cline{2-3}
& platypus & \Checkmark \\ \hline
reptile & iguana & \Checkmark \\ \cline{2-3}
& snake & \Checkmark \\ \hline
aves & flamingo & \Checkmark \\ \hline
\end{tabular}
Class Species Lays eggs?
mammal lion %
tiger %
platypus !
reptile iguana !
snake !
aves flamingo !
Tables
The table enviroment:
\begin{table} ... \end{table}
allows you to:
I Turn a table into a float
I Add a caption
I Number the table for referencing
Tables
table environment
Table: Who lays eggs?
Class Species Lays eggs?
mammallion %
tiger %
platypus !
reptileiguana !
snake !
aves flamingo !
Example Table - particle10.tex
Table Output
Decoding Error Messages
Steps to decode error messages:
I Begin with the first error message
I Look for line numbers (l.43 for example)
I Line number indicates where error was firstdetected
I Check spelling!
Common Errors
I Undefined control sequence - you used acommand that doesn’t exist
I Runaway argument - you left off a ”}”I Missing $ inserted - some of your text needs to
be in math mode
I Paragraph ended before \end was complete -missing ”}”
I LATEXWarning: Reference ... undefined on -recompile so LATEXcan get all of your references
Where To Get Help
I Books - LATEXConcisely by Adrian Johnstone
I Online - numerous manuals available
I Research Computing Lab -www2.lib.virginia.edu/brown/rescomp/
help/index.html
Most Commonly Used Commands
Figure: Top 10 Commands Out of 37,400 .tex Files
Special Characters
Some characters have a special significance in LATEX
\ # $ % & ˆ { }
They must be preceded by the escape character ”\”
For example:\ $
Special Characters
Some characters have a special significance in LATEX
\ # $ % & ˆ { }
They must be preceded by the escape character ”\”
For example:\ $
Fonts
Default Font: Computer modern
Default font size: 10pt
How to change the default font:
I Additional fonts are available for installation(http://www.tug.dk/FontCatalogue/)
How to change the default font size:
I \documentclass command accepts [11pt] and [12pt] as options
I fix-cm package overrides font size defaults
I special commands
Fonts
Default Font: Computer modern
Default font size: 10pt
How to change the default font:
I Additional fonts are available for installation(http://www.tug.dk/FontCatalogue/)
How to change the default font size:
I \documentclass command accepts [11pt] and [12pt] as options
I fix-cm package overrides font size defaults
I special commands
Font Size Commands
\tiny(5pt)
\scriptsize(7pt)
\footnotesize(8pt)
\small(9pt)
\normalsize(10pt)
\large(12pt)
\Large(14pt)
\LARGE(18pt)
\huge(20pt)\Huge(24pt)