Created
March 10, 2012 14:56
-
-
Save tommorris/2011656 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LaTeX Cheatsheet | |
---------------- | |
Common mistakes. | |
Never use "", use `` and ''. | |
endash = -- | emdash = --- | minus sign will appear in formulae | |
In URLs, use $\sim$ rather than ~. | |
"he/she" should be "he\slash she" | |
Simple Formatting. | |
\newline or \\ or \\* | |
\newpage | |
\linebreak[n] \nolinebreak[n] \pagebreak[n] \nopagebreak[n] | |
(where n is int 0 to 4, where 4 requires compiler to follow rule) | |
\ldots for ellipsis. | |
\underline{text} | |
\emph{text} - emphasis is nestable | |
Environments | |
Environments are nestable a bit like HTML or XML tags. | |
description = a definition list | |
e.g. | |
\begin{description} | |
\item[Cheese] A tasty food. | |
\item[Vomit] A not so tasty food. Not really food at all. | |
\end{description} | |
itemize = a bulleted list, like a ul in HTML. | |
\begin{itemize} | |
\item Foo | |
\item Bar | |
\item Baz | |
\end{itemize} | |
enumerate = a numbered list, like an ol in HTML. | |
\begin{enumerate} | |
\item Slice the weevil. | |
\item Cook at gas mark five. | |
\item Serve. | |
\end{enumerate} | |
flushleft, flushright and center - for alignment. | |
quote - for short quotes. | |
quotation - for longer quotes | |
verse - for poetry, separate lines of poem with \\ | |
abstract - an abstract, usually for a scientific paper | |
verbatim - basically <pre>, useful for code listings etc. | |
can be used inline with \verb+code goes here+ | |
verbatim* - verbatim, plus marks spaces with a space character | |
tabular - for laying out tables | |
figure, table - CSS-style floating. | |
Accents. | |
\"o = ö | |
\o = ø | |
\'e = é | |
\`a = à | |
\~n = ñ | |
for i and j, \i and \j - e.g. \"\i to give ï. | |
\ss for ß | |
! before a word gives ¡ | |
Hyphenation | |
Pop a \hyphenation{words...} command in the preamble, add words that | |
should not be hyphenated. | |
Hyphenation points in words can be set like this: | |
onto\-logical | |
Want something to not break across lines or be hypthenated? | |
\mbox{01234 567890} | |
Sections | |
\section{title} | |
\subsection{title} | |
\subsubsection{title} | |
\paragraph{...} | |
\subparagraph{...} | |
\part{title} | |
\chapter{title} for books | |
Add a \tableofcontents at the start. | |
Add a * to a section, subsection, subsubsection, part, chapter etc. | |
to exclude it from the numbering and TOC. e.g. | |
\section*{title} | |
\frontmatter, \mainmatter, \appendix, \backmatter are used to demarcate | |
sections of books. | |
References | |
Mark anchors with \label{name} where name is a unique ID for that anchor. | |
Refer to anchors with \ref{name} which will insert the last section num. | |
Page number of the anchor is \pageref{name} | |
e.g. "See further description in section \ref{bla} on page \pageref{bla}." | |
Footnotes | |
\footnote{Text of the footnote bla bla bla.} | |
BibTeX (Natbib): | |
Add Natbib to preamble: | |
\usepackage{natbib} | |
Parenthetical citations: | |
\citep{Botham:2003-PFME} -> (Botham 2003) | |
\citep[p. 436--439]{Botham:2003-PFME} -> (Botham 2003, p.436–469) | |
\citep[see][]{Botham:2003-PFME} -> (see Botham 2003} | |
\citep[see][p. 437]{Botham:2003-PFME} -> (see Botham 2003, p. 437) | |
\citep{Botham:2003-PFME,Dawson:1992-PFABA} -> (Botham 2003, Dawson 1992) | |
\citeyearpar{Botham:2003-PFME} -> (2003) | |
Textual citations: | |
\citet{Botham:2003-PFME} -> Botham (2003) | |
see above for before and after text. | |
\citeyear{Botham:2003-PFME] -> 2003 | |
\citeauthor{Botham:2003-PFME] -> Botham | |
Bibliography section: | |
\bibliographystyle{oxford} | |
\bibliography{my-bibfile} | |
see http://www.charlietanksley.net/philtex/natbib-cheat-sheets/ | |
for a nice Natbib-only cheatsheet | |
Indexing | |
In the preamble: | |
\usepackage{makeidx} | |
\makeindex | |
\index{key@formatted_entry} | |
key = the sorting key | |
formatted_entry = lets you format the entry | |
e.g. | |
\index{cheese} = adds the word cheese to the index | |
\index{cheese!Cheddar} = Cheddar, subentry of cheese | |
\index{Plantinga@\textfb{Plantinga}} = formatted entry | |
\index{ecole@\'ecole} = formatting for accent | |
Put \printindex where you want the index. | |
For debugging, add \usepackage{showidx} before \makeindex. | |
Textcomp package. | |
\usepackage{textcomp} | |
\textdegree{} gives you the degree symbol. | |
\textcelsius{} gives you degree symbol plus C. | |
\texteuro{} gives you €. You may prefer \euro{}. | |
Polyglossia | |
in preamble: | |
\usepackage{polyglossia} | |
\setdefaultlanguage[babelshorthands]{english} | |
\usepackage[Ligatures=TeX]{fontspec} | |
\setdefaultlanguage{english} | |
add another language to preamble: | |
\setotherlanguage[babelshorthands]{german} | |
a span of German text: | |
\textgerman{Gesundheit} | |
a paragraph of German text: | |
\begin{german} | |
Ich mag Hacking! | |
\end{german} | |
Useful tricks. | |
\today prints the date in the form "March 10, 2012" | |
Don't want ligatures? Pop an \mbox{} in-between characters. | |
When you have a full stop and it isn't the end of a sentence, replace | |
the space afterwards with a ~ or put a \@ before the full stop. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background: I've created this for myself. I've used LaTeX for a while, and this is intended for humanists, specifically philosophers, who aren't writing mathematically-heavy papers but want to use LaTeX because it's a version-controllable way of writing with footnotes and all that.