LATEX Quick Reference
Total Page:16
File Type:pdf, Size:1020Kb
LATEX quick reference Mark Gates November 19, 2012 This guide is available from http://web.eecs.utk.edu/∼mgates3/ Copyright ©2007{2011 by Mark Gates. You may freely copy and modify this document under the Creative Commons Attribution-ShareAlike license. When distributing modified versions, please include your Latex file. Purpose. This document was initially made as a quick reference to all the commands that I typically use, organized so I can understand it, with examples and without clutter. It also includes many shortcuts that I have defined in my mgates.sty file. It is not intended to be exhaustive, nor overly descriptive. Most of the general LATEXcommands can be found in the Not So Short Introduction to LATEX 2" [4]; most of the math in the Short Math Guide to LATEX [2]; most of the bibliography information in the BibTeX tutorial [3] and the natbib documentation [1]. I also wrote a separate Latex fonts guide. 1 Contents 1 Commands3 1.1 Document structure................................3 1.2 Page format....................................4 1.3 Chapters and Sections..............................5 1.4 Fonts........................................6 1.5 Reserved characters................................7 1.6 Special characters.................................7 1.7 Accented characters................................8 1.8 Special spaces...................................8 1.9 Special phrases..................................8 1.10 Line and page breaks...............................9 1.11 References, citations, footnotes......................... 10 1.12 Hyperlinks..................................... 10 2 Environments 11 2.1 Text alignment.................................. 11 2.2 Boxes....................................... 11 2.3 Block quotes.................................... 12 2.4 Verse........................................ 12 2.5 Verbatim...................................... 12 2.6 Lists........................................ 13 2.7 Tables (tabular).................................. 13 2.8 Figures and Tables................................ 14 3 Math 16 3.1 Equation numbering............................... 17 3.2 Sub/superscripts................................. 17 3.3 Fractions and binomial coefficient........................ 18 3.4 Math Fonts.................................... 18 3.5 Functions..................................... 19 3.6 Accents and over/under commands....................... 20 3.7 Greek....................................... 21 3.8 Hebrew...................................... 21 3.9 Symbols...................................... 22 3.10 Brackets and delimiters.............................. 24 3.11 Matrices...................................... 25 4 Bibliography using BibTeX 26 4.1 Enabling BibTeX................................. 26 4.2 Bibliography formats............................... 27 4.3 Citation formats and natbib........................... 28 4.4 BibTeX database................................. 29 4.5 Manually formatted bibliographies........................ 29 2 1 Commands 1.1 Document structure \documentclass[options]{class} Common classes article articles without chapters proc proceedings, based on article minimal minimal formatting report reports with chapters book real books Common options 10pt, 11pt, 12pt main font size a4paper, letterpaper, ... paper size fleqn equations left-aligned instead of centered leqno equation numbers on left instead of right titlepage, notitlepage start new page after title onecolumn, twocolumn one or two columns twoside, oneside landscape paper orientation openright, openany chapters begin on right page, or any page Preamble \usepackage[options]{package} \includeonly{filenames} skip \include with listed files Document \begin{document} \include{filename} start new page with contents of file \input{filename} include contents of file, without starting a new page \end{document} 3 1.2 Page format \pagestyle{ plain | headings | empty } plain page number in footer headings page number and chapter in header empty no header or footer \thispagestyle{ plain | headings | empty } override \pagestyle on a single page % set 1" margins on 8.5" x 11" paper % top left is measured from 1", 1" \topmargin 0in \oddsidemargin 0in \evensidemargin 0in \headheight 0in \headsep 0in \topskip 0in \textheight 9in \textwidth 6.5in % set these after the TOC \setlength{\parindent}{0em} \setlength{\parskip}{1em} \setlength\arraycolsep{2pt} 4 1.3 Chapters and Sections \title{...} \author{John Doe \and Jane Doe} \date{\today} \maketitle \frontmatter % (book only) starts roman numeral page numbering, unnumbered sections \setcounter{tocdepth}{1} % whether to display sub- or subsubsections in toc \tableofcontents \mainmatter % (book only) starts arabic page & section numbering \part{...} \chapter{...} \chapter*{...} % (book only) \section{...} \section*{...} \subsection{...} \subsection*{...} \subsubsection{...} \subsubsection*{...} \paragraph{...} \paragraph*{...} \subparagraph{...} \subparagraph*{...} \appendix % (book only) starts alphabetic section numbering \backmatter * Starred versions are unnumbered and not in the table of contents. Examples: 1 section 1.1 subsection 1.1.1 subsubsection paragraph Run-in paragraph header. Lorem ipsum dolar blah blah blah blah blah blah blah blah blah blah blah blah blah blah subparagraph Run-in paragraph header. Lorem ipsum dolar blah blah blah blah blah blah blah blah blah blah blah blah blah blah 5 1.4 Fonts Font sizes Point size Latex cmd User-defined * Sample 5 6 \tiny \xxxsmall the quick brown fox 7 8 \scriptsize \xxsmall the quick brown fox 8 10 \footnotesize \xsmall the quick brown fox 9 11 \small \small the quick brown fox 10 12 \normal \normal the quick brown fox 12 14 \large \large the quick brown fox 14 17 \Large \xlarge the quick brown fox 17 20 \LARGE \xxlarge the quick brown fox 20 25 \huge \xxxlarge the quick brown fox 25 25 \Huge \xxxxlarge the quick brown fox * see mgates.sty file Fonts Command Sample \textrm roman \textsf sans serif \texttt typewriter \textup upright \textsl slanted \emph emphasized \underline underline \textit italic \textmd medium \textbf bold font \textsc Small Caps \textnormal normal In math mode (e.g. inside $...$), use the math fonts listed in the math section. 6 1.5 Reserved characters Char Special meaning Command # ? \# $ math mode \$ % comment \% ^ math superscript \^{} & tab stop \& _ math subscript \_ { start parameter \{ } end parameter \ ~ nonbreaking space \~{} \ start command $\backslash$ These can also be typed in the verbatim environment or with \verb. 1.6 Special characters Symbol Command Symbol Command Symbol Command \ `` " " or '' ` ` ' ' in-law in-law 13{67 (en) 13--67 yes|no (em) yes---no yes . no yes \ldots no >No? ?`No? <No! !`No! † \dag ‡ \ddag § \S ¶ \P © \copyright ® \textregistered £ \pounds € \texteuro * * in textcomp package 7 1.7 Accented characters Char Command Char Command Char Command Char Command `o \`o ´o \'o ^o \^o ~o \~o ¯o \=o _o \.o ¨o \"o ¸c \c c ˘o \u o ˇo \v o }o \H o o \d o o \b o oo \t oo . ¯ œ \oe Œ \OE æ \ae Æ \AE ˚a \aa A˚ \AA ø \o Ø \O l \l L \L The first 4 lines can be applied to appropriate characters. To put accent over i or j, use \i (ı) or \j (). 1.8 Special spaces Command Size 1 space 10 spaces \, 3=8 quad ( ) [ ] \: 4=8 quad ( ) [ ] \; 5=8 quad ( ) [ ] \ en? space ( ) [ ] \quad em space ( ) [ ] \qquad 2 quad ( ) [ ] \! −3=8 quad () [] In math mode, phantom reserves space for text without printing it, for example x + x = 2; 1 3 x_1 \phantom{+ x_2} + x_3 = 2, \\ x1 + x2 = 5; x_1 + x_2 \phantom{+ x_3} = 5, \\ x1 + x2 + x3 = 7: x_1 + x_2 + x_3 = 7. 1.9 Special phrases Command Sample \today November 19, 2012 \TeX TEX \LaTeX LATEX \LaTeXe LATEX 2" 8 1.10 Line and page breaks \\ or \newline line break, without new paragraph. \\* also prohibts page break. \linebreak[n] \nolinebreak[n] line break, keeping line justified. n ranges from 0 to 4 (most insistent). For example, here is a paragraph with a newline in it, lorem ipsum dolar blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah, \newline. It also has a linebreak in it for comparison, lorem ipsum dolar blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah, \linebreak[4]. Notice the difference in justification. Using \linebreak can cause \underfull hbox" warn- ings. \newpage page break \pagebreak[n] \nopagebreak[n] page break, keeping line justified. n ranges from 0 to 4 (most insistent). \hyphenation{ fortran hy-phen-a-tion } list of words and where they may be hyphenated (in preamble). \- where a word may be hyphenated (in text). Example: su\-per\-scal\-ar \ space not to enlarge ~ space not to enlarge or line break \Mr. Smith" (Mr.\ Smith) or \Mr. Smith" (Mr.~Smith) instead of \Mr. Smith" (Mr. Smith) \@ between capital letter and punctuation that really does end a sentance \. FORTRAN. But. " (FORTRAN\@. But) instead of \. FORTRAN. But. " (FORTRAN. But) 9 1.11 References, citations, footnotes \label{name} assigns a unique name to an equation, figure, table, or section. For figures and tables, label must be after the caption. \eqref{name} inserts reference to the labeled equation; equivalent to (\ref{name}). \ref{name} inserts reference to the label. You must add the descriptive text such as “figure.” \pageref{name} inserts page number of the label. \cite{name} inserts reference to bibliography citation. Name is assigned by bibitem, not label. \footnote{text} generates a footnote. See also equation numbering on page 17. 1.12 Hyperlinks \usepackage[options]{hyperref} \usepackage[colorlinks, urlcolor=blue,