This page has several purposes: It contains a (very brief) general introduction to LaTeX, a couple of example files, some recent links to web-resources that I’ve found, and some tips and tricks that I thought were noteworthy.
Since I seem not to be adding to this at the rate that I’d originally hoped, here’s a link to UIUC’s TeX resources page, which is most excellent and full of tips.
The National Science Foundation has recently published its new, updated, Proposal and Award Policies and Procedures Guide. One paragraph in particular comes as a bit of a surprise:
For mathematicians and other LaTeX users, this is irritating, to say the least. I’ve put together a little page on Using NSF Fonts in LaTeX.
LaTeX is a typesetting program. Its history is pretty interesting, but outside what I want to talk about here. For me, what really matters is that LaTeX:
Since LaTeX is a typesetting program, not a WYSIWYG word-processing program, you have to interact with it differently. There are two parts: the input file, maybe called myfile.tex, and the latex program, which is run on myfile.tex and produces the output file myfile.dvi, as well as a couple of other auxiliary files myfile.aux and myfile.log (and maybe others).
Here’s the canonical sample input file. It might not display in your browser, so you’ll have to save it to your hard drive. Here’s the output in the output DVI format that LaTeX produces, and in PDF format for reading in your browser. There are lots of comments in the input file to explain what’s going on.
The basic unit of the LaTeX input file is the environment. There are lots of different flavors of environments, and they can nest however you like (mostly). For example, every document must begin with \begin{document} and end with \end{document}. In your document, you might have a Theorem (\begin{theorem} … \end{theorem}), and in that theorem a list of assertions (either \begin{enumerate} … \end{enumerate} or \begin{itemize} … \end{itemize}, depending whether you want a numbered list or a bulleted one). Environments cannot overlap, and must be closed before the end of the document.
I hope to continue to update this quite a bit in the next few weeks. Some topics I should cover:
There are lots of web resources for learning LaTeX; here are a few I’ve come across lately. See del.icio.us for more.
I have strong opinions about some matters of LaTeX “best practices”. Many of them are in line with general wisdom about avoiding manual commands in favor of letting LaTeX handle the fine-tuning of spacing, while others are my own personal orneriness.
--. Among other things, this clarifies the confusing “Birch—Swinnerton-Dyer Conjecture.” Ranges of numbers (“pages 4—125″) also get en-dashes. Pseudo-parenthetical phrases -— like this one here -— get set off by em-dashes ---. I like leaving a space on each side.
\footnote command. Put the footnote after the punctuation mark it is next to, not before it. Footnotes need not be complete sentences. In fact, their ontological status is somewhere between parenthetical comment, down-stage aside, and those “extra dimensions” the physicists keep telling us are curled up very small inside our visible four.
\emph{...} for emphasis. If you use {\it ...}, you need to add an adjustment space \/ at the end.
align/align* instead of eqaligh/eqalign*.
\left and \right to get larger versions of parentheses, brackets, etc., rather than \big, \bigg, and so on. One caveat: \left and \right have to come in pairs. Luckily, they don’t have to address the same symbol, so you can use \right. (period) to omit an unwanted right symbol.
ker, or Spec, etc) with \DeclareMathOperator{\Spec}{Spec} in the preamble. Making it a math operator will ensure that the font and spacing come out right.
To prevent mathematics in section headings from messing up hyperref’s internal references in the PDF output, use
\texorpdfstring{TeX version}{PDF version}
If you refer to a certain lemma, say, as “Lemma~\ref{keylemma}”, and later decide that it should be a Theorem instead, then you have to go back and repair all your references. Instead, use “\autoref{keylemma}”, which will automatically insert “Lemma”, or “Theorem”, or whatever the label refers to at the moment. (This requires the hyperref package, which you should be using anyway; see below.)
(Unfortunately, if you have all your theorems and lemmas numbered together, \autoref isn’t smart enough to tell the difference. A couple of people have written to ask if I know how to get around this, but I have no idea. The closest I’ve seen to a solution is )
There is now (Nov. 2006) a solution to the vexing problem noted above. If one uses the aliascnt.sty package, and in the document put:
\newtheorem{theorem}{Theorem}
\newaliascnt{lemma}{theorem}
\newtheorem{lemma}[lemma]{Lemma}
\aliascntresetthe{lemma}
then \autoref works correctly for both lemmas and theorems. Many thanks to Martin Osborne for letting me know.
hyperref packageDocumentation is here. I use it like so:
\usepackage[colorlinks=true,pagebackref,hyperindex]{hyperref}
This (1) makes all my internal links (to theorems, etc.) clickable and pretty-colored (2) adds page numbers to the bibliography entries linking to where each is cited, and (3) links index entries to the page they point to. Super groovy.
“texify”, don’t “latex”. It’s changed my life.
You know how sometimes you’ve got a theorem that only consists of an enumerate environment? And the first \item is on the same line as “Theorem 1.23″, while the others are over on the left margin? And that looks ugly? Here’s how to fix that. Immediately after \begin{theorem}, type “\ \\” or “\ \par” (without the quotes). Better!
Something amazing I just learned. Suppose:
Solution!
Paste the following at the bottom of the file sub1.tex:
%%% Local Variables: *** %%% mode:latex *** %%% tex-main-file: "main.tex" *** %%% End: ***
This tells emacs to compile the main file (which may not even be open!) rather than the subfile. Joy!