The best use of LaTeX is for long, complicated documents with lots of formulas and few pictures. Trust me on this one...
It does a good job for documents that *need* structure, allowing you the flexibility to easily modify the text, without worrying about how it's going to turn out.
LaTeX is actually a set of macros on top of the TeX document preparation system. This describes only the formats of LaTeX.
The format of a document is pretty simple:
\documentstyle{There are, as implied by the comment above, many different 'styles' of documents. The ones that I know of (I haven't bothered to actually create any styles of my own :) are:} ... this is called the preamble .... \begin{document} ... nice text and actual work here .... ... this is called the body ... \end{document}
style: letter article report book slides
There are several nice formatting tricks that LaTeX does, depending upon which format you use.
The following characters are illegal TeX input (except if you know how to use them, of course):
# $ % & ~ _ ^ \ { }
DON'T use these unless you know what you're doing! In order to get what you expect, type a '\' in front of them:
\# \$ \% \& \~ \_ \^ \\ \{ \}
Notice that the comment character in LaTeX is the '%' character. Comments start from the comment character until the end-of-line.
LaTeX also allows free-form text input. This means that it doesn't matter how many tabs, spaces you have, LaTeX has its own idea of what your document will look like. It is important to note that a single newline is NOT enough to make different paragraphs. There has to be at least two of them to separate the paragraphs.
\documentstyle{article} % define a macro \def\texpsfig#1#2#3{\vbox{\kern #3\hbox{\special{psfile=#1}\kern #2}}\typeout{(#1)}} \input epsf % load the epsf library \begin{document} % Insert the graphic and put a border around it \centerline{\texpsfig{test.eps}{4.563in}{3.813in}} \makebox[4.563in]{\rule{0in}{3.813in}} \end{document}For more information on this (at your own risk), see dvips(1).
\renewcommand{\baselinestretch}{2}For other spacing (ie triple) just change the 2. Now doesn't that just seem intuitively obvious? :)
\begin{tabular}{|l|r|c|} Person & Money Owing & Silly Comment \\ \hline Mr. Cairo & $1943.12 & pay him again, Sam \\ \hline Mr. Pink & \$55.55 & what robbery? \\ \hline Mr. Scaramanga & \$666.00 & the golden rule \\ \hline Mr. Capone & \$300.51 & bad accountants \\ \hline \end{tabular}Things to notice:
This ought to fix it:
\special{landscape}Note however, that xdvi(1) currently barfs all over the virtual rugscape, as it does not understand the landscape option.
A voice from the Netherland wilderness yells: "No wait! There is a way:
xdvi -paper a4r filename(Thanks to Peter @ infolab8@kub.nl for this suggestion)
Alternatively, use dvips to do it:
dvips -t landscapeSee dvips(1) for more information and other options.
\documentstyle[options]{style} style: article report book slides options: 11pt 12pt twoside twocolumn titlepage leqn openbib fleqn \pagestyle{style} style: plain empty headings myheadings \pagenumbering{style} style: arabic roman alph Roman Alph
\maketitle \begin{titlepage} ... \end{titlepage} \begin{abstract} ... \end{abstract}
\label{key} assign current counter value to key \ref{key} print value assigned to key
\bibliography{...} \begin{thebibliography}{label} ... \end{...} make bibliography; lable is the widest entry label \bibitem[label]{key} begin bibliography entry for citation key with label as its label \cite[note]{keys} cite reference(s) keys with added note
\input{file} read the file \include{file} read the file unless not in \includeonly{} \includeonly{filelist} exclude any file not in filelist
$ ... $ or \( ... \) in-text formulas \[ .. \] displayed formulas \begin{equation} ... \end{equation} a numbered equation \begin{eqnarray} ... \end{eqnarray} numbered equations, like 3 column array enviroment \nonumber omits one equation number, eqnarray* omits all _{ ... } subscript. NB: don't need the braces for one character ^{ ... } superscript. NB: don't need the braces for one character ' prime \frac{n}{d} print the numerator over the denominator \sqrt[n]{arg} the nth root of the argument arg ellipsis \ldots ... \cdots ... \vdots ... Greek letters \alpha ... \omega and \Alpha ... \Omega delimiters \left or \right followed by delimiters \overline{expression} print a rule over the expression space thin \. medium \: thick \; negative thin \!
\begin{quote} ... \end{quote} short displayed quotation \begin{quotation} ... \end{quotation} long displayed quotation \begin{flushleft} ... \end{flushleft} left flush lines, separated by \\ \begin{center} ... \end{center} centered lines, separated by \\ \begin{flushright} ... \end{flushright} right flush lines, separated by \\ \begin{verse} ... \end{verse} \\ between lines, blank line between stanzas \begin{verbatim} ... \end{verbatim} in fixed-length, typewriter face exactly as formated -- use any characters you like!
\begin{itemize} ... \end{itemize} a 'bulleted' list \begin{enumerate} ... \end{enumerate} a numbered list \begin{description} ... \end{description} a list of labelled items
quotes single ` ... ' and double `` ... '' dashes intra-word: - number range: -- punctuation: --- emphasis {\em } unbreakable text \mbox{ ... } footnotes \footnote{ ... } date \today
\rm roman \em emphasis \bf boldface \it italic \sl slant \sf sans serif \sc small caps \tt monospace typewriter face \boldmath use bold math symbols
\tiny \small \large \huge \scriptsize \normalsize \Large \Huge \footnotesize \LARGE
\'{o} \`{o} \~{o} \v{o} \c{o} \={o} \H{o} \d{o} \^{o} \.{o} \t{o} \b{o} \"{o} \u{o} \dag \ddag \S \P \copyright \pounds
\part \section \paragraph \ chapter \subsection \subsubsection \subparagraph \appendix no output, but the next sectioning commands are in the appendices \tableofcontents create a table of contents
\linebreak[n] force [or encourage] a linebreak; 0 <= n <= 4 \nolinebreak[n] forbid [or discourage] a linebreak; 0 <= n <= 4 \\[len] start new line and leave len vertical space \- permit hyphenation \begin{sloppypar} ... \end{sloppypar} Don't complain about lines that are a bit too long or too short
\pagebreak[n] force [or encourage] a page break; 0 <= n <= 4 \nopagebreak[n] forbid [or discourage] a page break. 0 <= n <= 4. Surprise! \samepage Only break pages in between paragraphs \newpage Begin a new page \clearpage Prints all figures and tables on the page and begins a new page
\mbox{...} \makebox[wd][pos]{...} make box of width wd; pos puts text at (l)eft, (r)ight, or center pos defaults to center \fbox{text} \framebox[wd][pos]{text} Same as \mbox or \makebox except draws a box around the box \newsavebox{cmd} defines cmd as a "bin" for saving boxes into \sbox{cmd}{text} \savebox{cmd}[wd][pos]{text} same as \mbox or \makebox but saves the box in bin cmd \usebox{cmd} Print the box saved in bin cmd \begin{minipage}[pos]{wd} ... \end{minipage} make a parbox of width wd, aligned by pos at (t)op, (b)ottom, or center line. center is the default \parbox[pos]{wd}{...} same as minipage for small amounts of text, no displayed environments.
units: cm, em, ex, in, pc, pt, mm cm Centimetres em The width of the letter M in the current font ex The height of the letter x in the current font in Inches pc Picas (1pc = 12pt) pt Points (1in = 72.27pt) mm Millimetres \newlength{cmd} define cmd to be a length \setlength{cmd}{len} set length of cmd to be len \addtolength{cmd}{len} add len to length cmd \settowidth{cmd}{txt} set cmd to width of txt
\baselinestretch A decimal value for the spacing. Example: To set double-spacing on your document, use the command: \renewcommand{\baselinestretch}{2} \textwidth The normal width of the text on the page Example: To change this, use the command: \setlength{\textwidth}{x} where x is a length. NOTE: If you change the textwidth, you will almost certainly want to change the evenside- and oddsidemargin \textheight The normal height of the body of a page. \oddsidemargin One inch less than the distance from the left edge of the paper to the left margin of the text on right-hand pages \evensidemargin The same as \oddsidemargin except for left-hand pages \marginparwidth The width of marginal notes \marginparsep The amount of horiz. space between the outer margin and a marginal note \topmargin One inch less than the distance from the top edge of the paper to the top of the page's head \headheight The height of a box containing the header \headsep The amount of vertical space between the header and the body of a page \topskip The minimum distance from the top of the body to the bottom of the first line of text \footheight The height of a box containing the page's footer \footskip The distance from the bottom of the last line of text in the body to the bottom of the footer
\hspace{len} Make len horizontal space. NOTE: len can be negative \hfill \hrulefill Fills the current line with space. With \hrulefill, the space is underlined. Example: If you want to create a form that says Name: __________, where the underline is 3 inches long, use this: Name: \makebox[3in]{\hrulefill} \vspace{len} Leave len vertical space.
\begin{picture}(x,y)(x',y') ... \end{ ... } x by y picture with the lower left corner at (x',y') \put(x,y){ ... } put object at point (x,y) \multiput(x,y)(delta-x,delta-y){n}{ ... } make n copies of the picture with the first at (x,y) and others offset by (delta-x,delta-y) \makebox(x,y)[pos]{ ... } make x by y box; pos puts object at top (t), bottom (b), left (l), right (r), and / or centered (default); \framebox and \savebox have analogous forms \dashbox{d}(x,y)[pos]{ ... } like \makebox but puts dashed lines of length d around box \line(h,v){l} line of slope h by v and length l; 0 <= h, v <= 6 \vector{h,v}{l} same as \line but draws arrowhead; 0 <= h, v <= 4 \shortstack[pos]{ ... } like \begin{tabular[pos] ... \circle{d} draw circle of diameter d; * form draws solid disk \oval{x,y}[partial] draw x by y (partial) oval \frame{ ... } draw frame around object line thickness \thinlines or \thicklines
\begin{figure} ... \end{figure} make a floating figure \begin{table} ... \end{table} make a floating table \caption{ ... } make figure or table caption
Rows are separated by \\; columns determined by:\= set tab stop \> go to the next tab stop \kill throw-away line
\begin{array}[pos]{cols} ... \end{array} \begin{tabular}[pos]{cols} ... \end{tabular}Use array for fomulae; tabular for text. Items separated by '&' and rows by '\\'; pos aligns with top (t), bottom (b); cols entries format columns
l left-justified column r right-justified column c centered column | vertical rule @{ ... } text or space between columns *{n}{ ... } equivalent to n copies of ... \multicolumn{n}{col}{ ... } span next n columns with col format \hline draw horizontal rule between rows \cline{i-j} horizontal rule between columns i-j
\newcommand{cmd}[n]{ ... } define new command cmd with n arguments \newenvironment{name}[n]{beg}{end} define new environment name with n arguments \newtheorem{name}{caption} define a theorem-like environment name captioned by caption
\setcounter{ctr}{n} set counter ctr to n \addtocounter{ctr}{n} add n to counter ctr
The following is an example latex session of a document called 'final.tex'. You can see that latex usually complains a lot, for no good reason. Don't worry about it. That's what it does...
cab017% latex final.tex This is TeX, C Version 3.14t3 (final.tex LaTeX Version 2.09 <7 Dec 1989> (/usr/TeX/tex/macros/report.sty Document Style `report' <13 Nov 89>. (/usr/TeX/tex/macros/rep10.sty) (/usr/TeX/tex/macros/titlepage.sty)) (final.aux (budget-mechanical.aux) (budget-electrical.aux) (budget-motor.aux) (budget-sensor.aux)) [0] (final.toc [1]) [2] Chapter 1. [3] Chapter 2. [4] (budget-mechanical.tex Chapter 3. [5] [6] [7] [8]) [9] (budget-electrical.tex Chapter 4. [10] [11] Overfull \hbox (24.54887pt too wide) in paragraph at lines 107--120 [] [12] [13] [14] [15] Overfull \hbox (1.5408pt too wide) in paragraph at lines 356--364 [] [16]) [17] (budget-motor.tex Chapter 5. [18] [19] [20]) [21] (budget-sensor.tex Chapter 6. [22] [23] [24] [25] [26]) [27] [28] Chapter 7. (beam.tex [29] [30] [31] (final.aux (budget-mechanical.aux) (budget-electrical.aux) (budget-motor.aux) (budget-sensor.aux)) ) ) (see the transcript file for additional information) Output written on final.dvi (32 pages, 69940 bytes). Transcript written on final.log.You can view the document by running xdvi:
cab017% xdvi final.dvi &xdvi should be fairly self-explanatory. Note that you can 'page' forward through xdvi with the space bar (or n), backward with p, and quit with q. Those are useful enough, if you find something else, tell somebody.
If you find that you like your document, you can pump out a PostScript file by using the command dvips, a la:
cab017% dvips final.dviThis creates a PostScript file in your current directory called 'final.ps'. You can print it to your local printer using lpr:
cab017% lpr -h -Pcab_sparc1 final.psCAVEAT: DO NOT PRINT THIS TO A DECWRITER!
A PostScript file typically contains about 40 pages of crap, then the actual document. You *really* don't want to kill the printer, your print quota and the eardrums of people in the room beside you, SO DON'T SEND IT TO A DECWRITER!!!!
There are two parts to the process:
...text that needs a reference to the Guide\cite{nopanic}(page 42)Simple enough, eh?
@where the document type is one of:{label,AUTHOR= "",TITLE= "", ... }
book unpublished article misc proceedingsand 'label' is how you want to refer to the entry.
Here is a sample bibliography file:
@book{booklabel, % Used when you \cite{this work} AUTHOR = "First Last Name", TITLE = "Name of the Book", VOLUME = 2, % The volume number -- not needed Publisher = {Publisher}, Address = {City, Province/State,Country}, Year = 1994} % The year the book was published @unpublished{unpublishedlabel, AUTHOR = "First Last Name", TITLE = "Name of the Work", Publisher = {Publisher}, Address = {City, Province/State,Country}, note= {Just to let you know that BibTeX is fairly flexible...}, Year = 1994} % The year the work was published @misc{misclabel, TITLE = "Title of whatever it is"} @article{articlelabel, AUTHOR = "First Last Name", JOURNAL = {The Harvard Journal of Really Stinky Things}, PAGES = {137 -- 142}, TITLE = "Spiritual Aspects of Locker Room Socks", VOLUME = 65, NUMBER = 5, YEAR = 1992} @proceedings{proceedingslabel, EDITOR = "Name of the Editors", TITLE = "Title of whatever it is"} Publisher = {Publisher}, Address = {City, Province/State,Country}, Year = 1994} % The year the proceedings was published
The first file is a wrapper for the second file, which actually contains all of your slides. The first file should look like:
\documentstyle{} \begin{document} \blackandwhite{slideride} \end{document}The second file (which from the file above is called 'slideride.tex') contains your slides, which are formatted as follows:
\begin{slide}{} ... some of your fantastic insightsSome things to note:... \end{slide} \begin{slide}{} ... even more of your fantastic insights ... \end{slide}
\colorslides{slideride} \colors{red,black,blue}This gives you red, black and blue to choose from. You can use the colours like other forms of emphasis. For example,
"... now we need {\red blood} and we can start!" said Papa.Now all you need is a colour printer! :)
\documentstyle{article} \renewcommand{\baselinestretch}{1.5} \setlength{\topmargin}{0pt} \setlength{\textheight}{10in} \setlength{\parindent}{0pt} \setlength{\textwidth}{5.5in} \setlength{\topskip}{0in} \setlength{\headheight}{0in} \setlength{\headsep}{0in} \pagestyle{empty} \setlength{\oddsidemargin}{.5in} \begin{document} \begin{center} {\LARGE \bf UACS EXECUTIVE ELECTIONS NOMINATION FORM} \vspace{.25in} \begin{tabular}{ll} Position running for: & \makebox[2in]{\hrulefill}\\ Name of candidate: & \makebox[2in]{\hrulefill} \\ email: & \makebox[2in]{\hrulefill} \end{tabular} \end{center} \Vspace{.2in} \hspace{0.5in}I, \makebox[2in]{\hrulefill}\hspace{-2in}\makebox[2in]{\raisebox{-0.5em}{\tiny Name (please print)}} nominate \makebox[2in]{\hrulefill}\hspace{-2in}\makebox[2in]{\raisebox{-0.5em}{\tiny Name (please print)}} as\\ a candidate for the position of \makebox[2in]{\hrulefill}.\\ email: \makebox[2in]{\hrulefill}\hspace{.5in}Signature: \makebox[2in]{\hrulefill} \section*{Supporters:} \begin{tabular}{lrr} Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\ email: & \makebox[2in]{\hrulefill} & \\ \ \\ Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\ email: & \makebox[2in]{\hrulefill} & \\ \ \\ Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\ email: & \makebox[2in]{\hrulefill} & \\ \ \\ Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\ email: & \makebox[2in]{\hrulefill} & \\ \ \\ Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\ email: & \makebox[2in]{\hrulefill} &\\ \end{tabular} \section*{Candidate Information} \begin{tabular}{lll} Are you a UACS member? & Yes: $\bigcirc$ & No: $\bigcirc$ \\ Are you in the CS program? & Yes: $\bigcirc$ & No: $\bigcirc$ \\ If no: Are you applying for CS? & Yes: $\bigcirc$ & No: $\bigcirc$ \end{tabular} \vspace{.25in} Current Department: \makebox[1.5in]{\hrulefill}\hspace{.25in}Year: \makebox[.5in]{\hrulefill}\hspace{.25in}ID\#: \makebox[1in]{\hrulefill} \ \\ Date: \makebox[2in]{\hrulefill} \hspace{.5in} Signature: \makebox[2in]{\hrulefill} \end{document}
\documentstyle{letter} \begin{document} \address{Your name (Confused? Check your Student ID :) \\ address \\ postie code} \begin{letter}{ To whomever you're addressing/threatening \\ their address \\ their postie code} \opening{addressee} ... references to pets, burning, and other childhood activities... \signature{Your name (See above)} \closing{Yours untruthfully, and backstabbingly (love),} \end{letter} \end{document}
\documentstyle{article} \begin{document} \title{JFK Assasination: Who Dunnit?} \author{Who Me \and Not U \and Not Me Really} % Optional: LaTeX will put in current date if you don't % put in the \date command \date{November 22, 1963} \maketitle \pagebreak \section{Dallas, Texas Assisination of JFK} ... describe this conspiracy ... \subsection{The ``Magic Bullet'' Theory} ... an alternative physical modelling ... \subsubsection{The Warren Commission's Findings} ... blah, blah, blah .... \section{The Aftershocks} ... Yet Another Section ... \section{Who Gained From the Murder?} ... Even more in-depth stuff ... \end{document}
Notice that this has a table of contents (toc). This means that you have to run latex over the file twice in order for the toc entries to come out correctly.
\documentstyle{book} \begin{document} \tableofcontents \pagebreak \chapter{The First Chapter} \include{number1} % So this chapter includes a file called 'number1.tex' % in the current directory \chapter{Now for the Second Chapter} \include{blah/number2} % So this chapter includes a file called 'number2.tex' % that is in the 'blah' directory \chapter{The One Worth Waiting For} This could have been an interesting bit\footnote{One of eight} except that it has been shown to be injurious to your health \cite{nothealthy}(page 666). \begin{quote} ``NO, YOU FOOL!!! Don't you know that process cheese is {\bf CONDUCTIVE}!!!'' \end{quote} \section{Well, Not Really} \subsection*{Umm, Just a Throwaway, Actually} \subsubsection*{It Only Fills Space Meaninglessly} % Note that when you put the asterisk '*' in front of % the text, that the section, subsection etc DOES NOT appear % in the table of contents \appendix \chapter{And now for the Technical Stuff} \include{appendicitis} \nocite{notseen} % Do this so that something you didn't % reference makes into your bibliography \pagebreak \bibliographystyle{plain} \bibliography{different} % references a file called % 'different.bib' \end{document}
setenv TEXEDIT "/usr/ucb/vi +%d %s"This sets the editor to be 'vi' and tells 'vi' to put the cursor at the '%d'th line of the file. For bash users, the variable can be set by:
export TEXEDIT="/usr/gnu/bin/emacs +%d %s"This will run the 'emacs' editor.
The line that LaTeX found the error on will then be displayed. At this point, you'll have to know what the error is or you can't compile the document. Sorry, you're on your own.
Further note that the LaTeX book by Leslie Lamport was originally used (sigh) without permission to create the Commonly Used Commands section.
For some sample ideas and documents, we have to thank:
Steve Charlton, Andrew Morris and lots of other people who want
their names
HINT!! HINT!! <---- NB. A hint!
In the directory /usr/TeX/tex/macros you find the following files:
SEE ALSO (FILES)
Located in the TeX directory is a set of files which seem to provide
some latex-able documents.
btxdoc.tex lablst.tex psfig.tex tb0cyr.tex
btxhak.tex latex.tex rotate.tex tb0hyf.tex
btxmac.tex lfonts.tex sample.tex testfont.tex
epsf.tex logo.tex sfonts.tex testpage.tex
hyphen.tex lplain.tex slides.tex tryfonts.tex
idx.tex manmac.tex slitex.tex tubguide.tex
idxmac-amstex.tex mftmac.tex slogofonts.tex tugbot.tex
idxmac.tex nul.tex small.tex webmac.tex
ind+.tex null.tex splain.tex
ind-.tex plain.tex story.tex
You can copy these and latex 'em, and read 'em. Won't you? :)SEE ALSO (BOOKS)
Leslie Lamport, LaTeX: User's Guide & Reference Manual
"It's *MUCH* better than nothing..." -- KellsSEE ALSO (PROGRAMS)
tex(1),latex(1),gnuplot(),xpaint(),xdvi(),emacs(),dvips(1),
dviselect(1)
June 19, 1994
pub@cs.ualberta.ca