<- previous    index    next ->

Lecture 38, Open Tutorial on LaTeX


You can prepare high quality math and engineering
papers using LaTeX, pronounced lah tech.

This is not intended to cover all or even most of LaTeX.

You will prepare a LaTeX file  foo.tex

running LaTeX

On UMBC GL machines you have several options to get output: latex foo.tex latex foo.tex # this is needed for TOC, bibliography, etc dvips -o foo.ps foo.dvi # compiling produces a .dvi and other files lpr foo.ps # print high quality PostScript # your browser can view foo.ps, lower quality print ps2pdfwr foo.ps foo.pdf # optional to also produce a .pdf pdflatex foo.tex # generate a .pdf acroread foo.pdf # use acroread to view and print evince foo.pdf # use evince to view and print # your browser can view and print foo.pdf and, many other auxiliary programs are available. Use your favorite editor to create foo.tex Best on-line reference is: http://en.wikibooks.org/wiki/LaTeX

Getting LaTeX on your computer

Linux: sudo apt-get install texlive MacOSX: get mactex Windows: get protext or miktex

First example

Here is a simple, complete, .tex file hello.tex hello.ps hello.pdf % hello.tex absolute minimum to get output \documentclass[12pt]{letter} % could be paper, article, report, book, slides ... \begin{document} % start of document Hello world from LaTeX. \end{document} % end of document, nothing after this line The Makefile commands to generate hello.ps and hello.pdef are: latex hello.tex latex hello.tex dvips -o hello.ps hello.dvi ps2pdfwr hello.ps hello.pdf

Note some syntax "\" and "{ }"

"\" starts a command, there are many. You can define new commands to save on typing. More commands can be brought in from packages "{ }" are for grouping or enclosing. Usually REQUIRED! e.g. \frac {numerator equation} {denominator equation} Generally, arbitrary nesting is allowed, just use lots of { { {} {} } { } } one or mode spaces is a space. carriage return and tab are a space. lines automatically formatted unless you interfere No semicolons at end of lines or statements

Printing equations

equation.tex equation.ps % equation.tex just a few samples \documentclass[12pt]{article} \begin{document} % start of document For subscript use underscore $A_1 \; \; A_i \; \; A_{i,j} $ % \; for more spaces For power, superscript use hat % $ your equation $ $x^2 \; \; x^{p+q} \; \; x^{y^z} $ ${n \choose k} = \frac{n!}{k!(n-k!)}$ $z = \sqrt {x^2 + y^2}$ \[ \int _{i=0} ^{\infty} \frac {1}{{(x+1)}^2} dx \] \( \sum _{j=1} ^{10} A_j \) \end{document} % end of document, nothing after this line

printing matrices and vectors

Using \matrix pdemat.tex pdemat.ps pdemat.pdf % pdemat.tex \documentclass[11pt,fleqn]{article} % preamble follows \setlength{\textheight}{8.5in} \setlength{\topmargin}{0.5in} \setlength{\textwidth}{6.5in} \setlength{\headheight}{0.0in} \setlength{\headsep}{0.0in} \setlength{\oddsidemargin}{0in} \newcommand{\LL}{\mit L} \begin{document} % start of document System of simultaneous equations that are too wide for paper $$\left| \matrix{ \int_{\Omega} \LL \left( \phi_1(x,y) \right) \phi_1(x,y) dx \, dy \ \int_{\Omega} \LL \left( \phi_2(x,y) \right) \phi_1(x,y) dx \, dy \ \ldots \ \int_{\Omega} \LL \left( \phi_{nxy}(x,y) \right) \phi_1(x,y) dx \, dy \cr \int_{\Omega} \LL \left( \phi_1(x,y) \right) \phi_2(x,y) dx \, dy \ \int_{\Omega} \LL \left( \phi_2(x,y) \right) \phi_2(x,y) dx \, dy \ \ldots \ \int_{\Omega} \LL \left( \phi_{nxy}(x,y) \right) \phi_2(x,y) dx \, dy \cr \ldots \cr \int_{\Omega} \LL \left( \phi_1(x,y) \right) \phi_{nxy}(x,y) dx \, dy \ \int_{\Omega} \LL \left( \phi_2(x,y) \right) \phi_{nxy}(x,y) dx \, dy \ \ldots \ \int_{\Omega} \LL \left( \phi_{nxy}(x,y) \right) \phi_{nxy}(x,y) dx \, dy \cr } \right| \times $$ $$ \left| \matrix{ U_1 \cr U_2 \cr \ldots \cr U_{nxy} \cr } \right| = \left| \matrix{ \int_{\Omega} f(x,y) \phi_1(x,y) dx \, dy \cr \int_{\Omega} f(x,y) \phi_2(x,y) dx \, dy \cr \ldots \cr \int_{\Omega} f(x,y) \phi_{nxy}(x,y) dx \, dy \cr } \right| $$ \end{document} % end of document, nothing after this line

Drawings that have a lot of math symbols

put(x,y){\} note that x and y and dimensions are in "points" 1/72 of inch \line \vector \circle \oval \qbezier draw2.tex draw2.pdf draw2.ps % draw2.tex \documentclass[11pt,fleqn]{article} % preamble follows \setlength{\textheight}{8.5in} \setlength{\topmargin}{1in} \setlength{\textwidth}{7.5in} \setlength{\headheight}{0.0in} \setlength{\headsep}{0.0in} \setlength{\oddsidemargin}{0in} \begin{document} % start of document \thicklines Polynomial Hierarchy based on quantifiers \begin{picture}(468,576) % basic hierarchy lines \put(70,110){\framebox(288,432)} % \hbox overfull, NOT \put(70,182){\line(4,-1){288}} % slope and length \put(70,182){\line(4,1){288}} \put(358,182){\line(-4,-1){288}} \put(358,182){\line(-4,1){288}} \put(70,326){\line(4,-1){288}} \put(70,326){\line(4,1){288}} \put(358,326){\line(-4,-1){288}} \put(358,326){\line(-4,1){288}} % labeling \Large \put(210,122){\mbox{${\rm P}$}} \put(80,140){\mbox{${\Sigma_1^{\rm P}}={\rm NP}$}} \put(265,140){\mbox{$\Pi_1^{\rm P}={\rm co\mbox{-}NP}$}} \put(50,140){\mbox{${\exists}$}} \put(370,140){\mbox{${\forall}$}} \put(205,176){\mbox{$\Delta_2^{\rm P}$}} \put(80,212){\mbox{${\Sigma_2^{\rm P}}={\rm DP}$}} \put(265,212){\mbox{$\Pi_2^{\rm P}={\rm co\mbox{-}DP}$}} \put(42,212){\mbox{${\exists\forall}$}} \put(370,212){\mbox{${\forall\exists}$}} \put(205,248){\mbox{$\Delta_3^{\rm P}$}} \put(80,284){\mbox{${\Sigma_3^{\rm P}}$}} \put(265,284){\mbox{$\Pi_3^{\rm P}$}} \put(34,284){\mbox{${\exists\forall\exists}$}} \put(370,284){\mbox{${\forall\exists\forall}$}} \put(205,320){\mbox{$\Delta_4^{\rm P}$}} \put(80,356){\mbox{${\Sigma_4^{\rm P}}$}} \put(265,356){\mbox{$\Pi_4^{\rm P}$}} \put(26,356){\mbox{${\exists\forall\exists\forall}$}} \put(370,356){\mbox{${\forall\exists\forall\exists}$}} \put(205,392){\mbox{$\Delta_5^{\rm P}$}} \put(120,474){\mbox{${\rm PH}={\bigcup_{i=1}^{\infty}{\Sigma_i^{\rm P}}} ={\bigcup_{i=1}^{\infty}{\Pi_i^{\rm P}}}$}} \normalsize \end{picture} \end{document} % end of document, nothing after this line For more information and examples see: http://en.wikibooks.org/wiki/LaTeX/Creating_Graphics

Graphs using qbezier

qbezier.tex qbezier.ps % qbezier.tex absolute minimum to get a plot \documentclass[12pt]{article} \begin{document} % start of document \setlength{\unitlength}{1mm} \begin{picture}(90,32) \put(0,15){\vector(1,0){57}} \put(60,14){$\chi$ = Rapidit\"at} \put(25,0){\vector(0,1){32}} \put(27,29){$\beta=v/c$} \multiput(0,5)(4,0){13}{\line(1,0){2}} \multiput(0,25)(4,0){13}{\line(1,0){2}} \put(60,24){$\displaystyle\beta=\frac{v}{c}=\tanh\chi$} \qbezier(25,15)(34,24)(45,24.6) \qbezier(25,15)(16, 6)( 5,5.4) \end{picture} \end{document} % end of document, nothing after this line

Automatic generation of table of contents and title page, chapters, sections, appendices.

simplepaper.tex simplepaper.ps % simplepaper.tex using automatic table of contents \documentclass[12pt]{report} % preamble follows \title{My Title} \author{Me \\ Other \\ \\ More \\ \\ } \date{September 15, 1999} % put in or uses date generated \begin{document} % start of document \maketitle % uses parameters from above \title \author \date \begin{abstract} Just an abstract here. \end{abstract} \tableofcontents % will be generated and put here \chapter{Introduction} This is just text in the open. A blank line makes a new paragraph, indented. Stuff in this paragraph, automatically fills lines. Force end of short line \\ Another short line \\ \begin{verbatim} Verbatim text left lots of spaces Indented and skipped two lines Unindent. \end{verbatim} \chapter{More stuff} \begin{verbatim} Hi there Line two, col 1 \end{verbatim} \newpage \appendix \chapter{This appendix covers xyz} Start of appendix \section{append section first} Just next section of appendix \section{more append sections} more appendix stuff end of my text \end{document} % end of document, nothing after this line For all Math symbols and notation http://en.wikibooks.org/wiki/LaTeX/Mathematics
    <- previous    index    next ->