ICS 54 Klefstad Document Preparation Correcting Spelling Errors LaTeX Previewing and Printing TeX output Correcting Spelling Errors . % spell document.tex prints misspelled words on the standard output . % look word_prefix prints all dictionary words matching word_prefix . /usr/dict/words database of correctly spelled words . % ispell document.tex interactive spelling checker with correction LaTeX . TeX is a typesetting program developed by Don Knuth at Stanford . features high-level constructs which may be composed and nested . resulting documents can look very nice . LaTeX is a macro package developed by Lesley Lamport . LaTeX provides for several general types of documents Document and Page Styles . \documentstyle[options]{style} % declare the style of document style = article report book letter slides options = 11pt,12pt,twoside,twocolumn,titlepage,openbib,leqno,fleqn . \pagestyle{style} % declare the style of head and foot style = plain empty headings myheadings . \pagenumbering{style} % declare the style of page numbering style = arabic roman alph Roman Alph Title Page and Abstract . \title{First title line \\ Second title line} . \author{Author Name \And Other Name} . \date{Optional Date (defaults to today)} . \maketitle % make title page of default format using title, author, date . \begin{titlepage} ... \end{titlepage} % do-it-yourself title page . \begin{abstract} ... \end{abstract} % make abstract Line Breaking . \linebreak[n] % force [or encourage N in 0..4] a line break . \nolinebreak[n] % forbid [or discourage N in 0..4] a line break . \\[len] % start new line and leave len vertical space . \- % permit hyphenation (specified within a word) . \begin{sloppypar} ... \end{sloppypar} % allow loose lines in a paragraph . \sloppy % allow loose lines Page Breaking . \pagebreak[n] % force a page break . \nopagebreak[n] % forbid a page break . \samepage % forbid page breaking except between paragraphs . \newpage % start a new page . \clearpage % print all figures and tables and start a new page Figures and Tables . \begin{figure} ... \end{figure} % make a floating figure . \begin{table} ... \end{table} % make a floating table . \caption{...} % make figure or table caption Tabbing Environment . Rows separated by \\; columns separated by : . \= % set tab stop . \> % go to next tab stop . \kill % throw away line Array and Tabular Environments . Alternatives . \begin{array}[pos]{cols}...\end{array} . \begin{tabular}[pos]{cols}...\end{tabular} . \multicolumn{n}{col}{...} % span next n columns with col format use array for formulas, tabular for text items separated by & and rows by \\ pos aligns with top (t), bottom (b), or center (default) 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 ... . Lines . \hline % draws horizontal line between rows . \cline{i-j} % draws horizontal line across columns i-j Definitions . \newcommand{cmd}[n]{...} % defines new command cmd with n arguments . $i references the value of the ith parameter . \newenvironment{name}[n]{beg}{end} % define a new env name with n args . \newtheorem{name}{caption} % defines a theorem-like env Type Styles . \rm Roman . \it Italics . \sc Small capitols . \em Emphasis . \sl Slant . \tt Typewriter . \bf Boldface . \sf Sanserif Type Sizes . \tiny . \scriptsize and \footnotesize . \small . \normalsize . \large, \Large, and \\LARGE . \huge and \Huge Sectioning and Table of Contents . \part . \chapter . \section . \subsection and \subsubsection . \paragraph and \subparagraph . \appendix % start appendix . \tableofcontents % make table of contents Displayed Paragraphs . \begin{quote} ... \end{quote} % short displayed quotations . \begin{quotation} ... \end{quotation} % long displayed quotations . \begin{center} ... \end{center} % center lines separated by \\ . \begin{verbatim} ... \end{verbatim} % in typewritter font as formated Lists . Begin each item with \item or \item[label] . \begin{itemize} ... \end{itemize} % bulleted items . \begin{enumerate} ... \end{enumerate} % numbered items . \begin{description} ... \end{description} % labeled items . eg \begin{itemize} \item point 1 \item point 1 \end{itemize} Cross-Reference . \label{key} % assign current counter value to key . \ref{key} % print value assigned to key Bibliography and Citations . \bibliography{...} % make bib and tell bibtex names of bib files . \bibitem[label]{key} % begin bib entry for citation key with label . \cite[note]{keys} % cite references matching keys with added note Sentences and Paragraphs . quotes single `...' double ``...'' . dashes intra-word: - number ranges: -- punctuation: --- . spacing small: \, inter-word: \_ (space, not an underscore) unbreakable: ~ sentence-ending period: \@ . special characters (must be backslashed) \$ \& \% \# \{ \} \_ Boxes . \makebox[wid][pos]{...} % make a box wid wide; pos puts text at left(l), right(r), or center(default) . \framebox[wid][pos]{...} % same but draws a frame around box Length . units: cm em ex in pc pt mm . \newlength{cmd} % define cmd to be a length . \setlength{cmd}{len} % set length cmd to len . \addtolength{cmd}{len} % add len to length cmd . \settowidth{cmd}{txt} % set cmd to width of txt Space . Blank lines separate paragraphs of text. . \hspace{len} % make len horizontal space . \hfill % make infinitely stretchable horizontal space . \vspace{len} % make len vertical space . \vfill % make infinitely stretchable vertical space Mathematical Formulas . ... or \(...\) % formula within text . \[...\] % displayed formula . \begin{equation}...\end{equation} % numbered equation . _{...} subscript . ^{...} superscript . ' prime . \frac{n}{d} print fraction n/d . \sqrt[n]{arg} print n root arg . \ldots % ellipsis . \cdots % centered dots . \vdots % vertical dots . \alpha, ..., \Omega % Greek letters . \overline{exp} print a line over expr Pictures . pictures are created with xfig or picturetool . % xfig foo # to create the foo.pic . % tpic foo.pic # converts foo.pic to foo.tex . \input foo.tex % include the file containing the graph . \box{\graph} % to insert the picture defined by tpic Miscellaneous . Footnotes . \footnote{...} . File Input . \input{file} % reads specified file . often followed by \relax in case of errors in input . Numbering . \setcounter{ctr}{n} % set counter ctr to n . \addtocounter{ctr}{n} % add n to counter ctr Examples book style . main document (one chapter per file) \documentstyle[]{book} \def\harmlessunderscore{\ifmmode\def\next{\sb}\else\let\next=\_\fi\next} \catcode`\_=\active \let _=\harmlessunderscore \catcode`\~=12 \title{{\Huge \bf How To Make Money \\ Without Really Trying} } \author{Raymond Klefstad} \begin{document} \maketitle \tableofcontents \input{foreward.tex} \input{overview.tex} \input{how_to_get_started.tex} \input{how_not_to_get_caught.tex} \input{getting_good_legal_help.tex} \input{conclusion.tex} \end{document} . overview.tex \chapter{Overview} \section{My First Section} Blah, blah, ... Example article style \documentstyle[12pt]{article} % Initialize LaTeX to 12pt article style \title{\bf This is My Title } \author{My Name} \begin{titlepage} % print the title page \maketitle \end{titlepage} \begin{document} % directive to begin the document \begin{titlepage} % print the table of contents \tableofcontents \end{titlepage} \section{My First Section} \subsection{First Subsection} % A few example paragraphs... Now is the time for all good men to come to the aid of their country. The small brown fox jumped into the quick green river. \subsection{Another Subsection} Now is the time for all good men to come to the aid of their country. The small brown fox jumped into the quick green river. \section{My Second Section} \end{document} % this is necessary, it ends the document Example letter style \documentstyle[11pt]{letter} \signature{Betty Anteater\\ Student} \address{714-856-6064\\Internet: klefstad@ics.uci.edu} % \renewcommand{\baselinestretch}{1.4} % double space \renewcommand{\baselinestretch}{1.0} % normal linespacing \begin{document} \begin{letter} { Joe Programmer\Department of Computer Programming\Computer Software, Inc. } \opening{Dear Mr. Programmer:} Blah, blah, blah. Blah, blah, blah. \closing{Sincerely,} \cc{Betty Anteater} \encl{resume} \end{letter} \end{document} Unix commands . latex file.tex formats file.tex to create file.dvi . dviselect list-of-pages infile outfile . selects the listed pages from infile and puts them in outfile . eg % dviselect 1:10 29 50:\* my_doc.dvi subset.dvi . selects 1-10,29,50 to the end into the file subset.dvi . texx dvi_file . allows you to view TeX under X windows . texsun dvi_file . allows you to view TeX under sunview . dvisp dvi_file . sends the dvi_file to your default printer . LPRINTER environment variable defines your default printer