An introduction to L A TEX for students Christopher Hanusa February 17, 2011 Christopher.Hanusa@qc.cuny.edu http://people.qc.cuny.edu/chanusa/ > Talks
Pros and Cons of L A TEX Why use L A TEX? Ideal for typesetting mathematics. Automatic numbering and citations! Gives the user control of page formatting. Separates the writing of content from the formatting. Free to use; support of the open source community. The output is a pdf; readable by all. It s standard. It s pretty. When NOT to use L A TEX: Creating flyers. When you have only text. (No figs, tables, eqns, references) If you don t want to be in charge of the formatting.
Typesetting Mathematics 9 1 ( yx 5 + e xy) dx y 1 n 2 = π 6 a 2 + b 2 n=1 αβγδ ω ABC Z ABC Z (A B) C =(A C) (B C) ( )( ) 1 2 1 0 3 4 3 1 = ( ) 5 2 9 4
Automatic numbering I am able to reference theorems, figures, and equations even if their numbers change. Theorem 1. Iamatheorem. Proof. Some pretty, distracting equations: { z if z 0 z = z if z < 0 z =14x 7y (1) 10x =17y (2) By Equations (1) and (2), we have proved Theorem 1.
Structure of a.tex file Always begins with \documentclass Next, import necessary packages. Insert user-created commands. File content starts with \begin{document} To break into sections, use \section and \subsection Use%towritecommentsortohelp with the visual structure. File content ends with \end{document}
Typing text and using fonts To type text, type normally; extra whitespace does not matter. To go to a new paragraph, skip a line. Use a pair of left quotes to open a quote; use a pair of right quotes to close. The following characters are reserved: # $ % & ˆ {}><\ \ is what tells L A TEX that you are entering a command. % is for entering comments. $ is for writing in math mode. For fonts, surround the text you wish with braces and insert \bf (bold), \em (emphasized), \rm (roman), \tt (fixed width), as in {\bf Hello} to produce Hello.
Including equations L A TEX excels at integrating the writing of mathematics into text. To include math symbols or equations inline, use $ to begin and to end; for example, type $a 1^2 + b 1^2$ to get a 2 1 + b2 1. Certain symbols everyone uses: 10 $\sqrt{10}$ 10 1 $\int {1}ˆ{10}$ n=1 $\sum {n=1}ˆ\infty$ 1 n 2 $\frac{1}{nˆ2}$ α $\alpha$... $\hdots$; alsouseful $\cdots$ and $\vdots$ Each mathematician has their own symbol needs; either peruse tables of symbols or use Detexify (detexify.kirelabs.org)
Referencing equations, figures, theorems Alternatively, create equations on their own lines using \begin{equation} and \end{equation}, asin \begin{equation} \frac{a}{b}+1=\frac{a+b}{b} \end{equation} a b +1= a + b b (3) Include a \label{name} to reference it later with \ref{name}. Same goes with defining figures and theorems: \begin{figure} (figure here) \label{fig:name1} \end{figure} \begin{theorem} (theorem here) \label{thm:name2} \end{theorem}... Figure \ref{fig:name1} exhibits Theorem \ref{thm:name2}...
Lists and Tables Lists are pretty simple; use itemize (bullets) or enumerate (numerals). 1. Item 1. 2. Item 2. Item 2a. Item 2b. \begin{enumerate} \item Item 1. \item Item 2. \begin{itemize} \item Item 2a. \item Item 2b. \end{itemize} \end{enumerate} Tables are pretty complicated; use tabular.
Miscellaneous To include graphics, use the package epsfig or graphicx. \epsfig{figure=residual4.eps,height=1in} 3 Residual Plot 2 1 2 4 6 8 10 x 1 2 3 Tousecolor,usethepackagexcolor. For example, {\color{red} xcolor}. To organize citations, use BibTEX To create slide shows, use Beamer LaTeX integrates with the editor emacs.
Installation So you re hooked! How to get L A TEX foryourself? On a Mac Distribution: MacTeX (tug.org/mactex/) Viewer: TeXShop (texshop.org) On a PC Distribution: MiKTeX (miktex.org) Viewer: TeXnicCenter (texniccenter.org) On Linux Like everything else, it s possible.
Tips and help This is one academic exercise where I say: PLAGIARIZE! Read other people s files to see what they do; then copy. Search the web! Example: latex tabular Helpful reference sheets (condensed): Typing Math: Short Math Guide for L A TEX ftp://ftp.ams.org/pub/tex/doc/amsmath/short-math-guide.pdf Find symbols: detexify.kirelabs.org or search. Helpful for getting started (some reading): http://www.tug.org/begin.html www.ctan.org/tex-archive/info/mil/mil.pdf
Let s get hands on! 1. Download Empty.tex and NotEmpty.tex from my website. 2. Open each using TeXShop on your computer. 3. Start typing. 4. When you want to see the output, click on the Typeset button or click Cmd-S (save) Cmd-T (typeset). 5. This will pop up a small window which runs the latex command, and (if you have no errors), will pop up a window with the output in pdf format. 6. If you have errors, you need to decode them, fix them, and typeset again. (often: mismatched {}or misspelled command)