Up and Running With LaTeX
May 13, 2010
Recently I've had the pleasure of getting acquainted with LaTeX. For those that don't know, LaTeX is a typesetting system that turns marked-up text files into precise, readable, print-ready documents. LaTeX is specialized for creating technical documents containing math and equations, but it's also well-suited for any structured document. LaTeX is not just the command-line tool for procesing @.tex@ files, though--it's an entire ecosystem consisting of libraries, packages and tools for myriad purposes. The size of this ecosystem is staggering. At times, it's frustrating. But I've grown to appreciate it the more I've learned. What's so great about LaTeX? I love that it demands explicitness. It doesn't try to guess what you mean. Want a hyphen? Use ==-==. Want a slightly longer dash, suitable for numerical ranges? That's ==--==. Using a dash for punctuation? ==---== inserts an em dash. The same explicitness applies to quotes. How does LaTeX know what is an opening quote and what is a closing quote? You tell it. Use two backticks (``) for an opening quote and two apostrophes for a closing quote (==''==). These are two examples of the attention to detail that LaTeX promotes. Some things are more automatic. Hyphenation, for example, is handled by LaTeX. And it's smart.[1] The system sometimes misses possible hyphenation points, but it's very good at avoiding incorrect hyphenation, such as "new-spapers." It also allows manual control of hyphenation. For example, put @\-@ in the middle of a word to identify a possible hyphenation point. I also found some of these "line breaking commands":http://www.personal.ceu.hu/tex/breaking.htm helpful. LaTeX excels at working with tables, references, bibliographies, footnotes, indexes (and math, of course)--features whose use ranges from tedious to hellish in word processing software. Perhaps its greatest strength is that unlike word processing software, LaTeX forces authors to focus on the content and structure of a document, rather than its presentation. LaTeX takes care of what it looks like. It's the anti-WYSIWYG(What You See Is What You Get). h3. Installing LaTeX The easiest way to get started with LaTeX on Mac OS X is to install "MacTeX":http://www.tug.org/mactex/2009/. Once you have MacTeX installed, take a look in @/usr/local/texlive@ (MacTeX is a specialized version of the TeX Live distribution) to see what was installed. You'll want to add @/usr/local/texlive/2009/bin/universal-darwin@ to your @$PATH@. Also make note of @/usr/local/texlive/2009/texmf-local/tex/latex@--this is where you'll install additional LaTeX packages. h3. The Memoir Class You can get far with LaTeX's built in document classes: book, report, article, etc. But for my document, I needed a bit more flexibility. I turned to the Memoir document class. The goal of this class is to combine LaTeX's built-in book class with some of the more common packages that help customize the design of a document. The result is a large class, but one that offers convenience, since it reduces the need for installing additional packages. It's difficult to summarize what Memoir offers because it does so much. Instead, I'll just share my own experience: Memoir made laying out my document a breeze. I continually got the impression that the creators of Memoir had thought of everything. Refer to "Memoir's exhaustive, 500-page manual":http://mirror.ctan.org/macros/latex/contrib/memoir/memman.pdf (PDF) to learn about what it offers. It's epic. To install Memoir (or any document class or package), "download it from CTAN (download the memoir document class)":http://www.ctan.org/tex-archive/macros/latex/contrib/memoir/, compile it using the instructions in the README, and then copy the entire @memoir@ directory to the installation directory mentioned above. Then, after running @texhash@, you should be able to compile documents using the Memoir class. h3. Printing 2-Up The document I was preparing was a long packet of reading. I wanted to print this document with two pages per sheet, as a photocopied packet from a book would be layed out. Although there are ways to bend LaTeX's strong desire to print one logical page per physical sheet of paper (among these are "@booklet@":http://www.ctan.org/tex-archive/macros/latex/contrib/booklet/ and "@twoup@":http://www.ctan.org/tex-archive/macros/latex/contrib/twoup/), a more prudent alternative is pdfpages. pdfpages is a package for embedding--you guessed it--PDF pages into LaTeX documents. Conveniently, it has the ability to embed multiple pages of a PDF document into a single page of a LaTeX document. The end result: multiple logical pages per physical sheet. After producing a PDF of your original document, create another LaTeX document which embeds the compiled PDF, manipulating it to render two PDF pages on one LaTeX page. Some code might make this clearer:\documentclass[landscape]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[nup=2x1,pages=-]{my-document.pdf}
\end{document}
% Set inner and outer margins to .5 and 1 inch, respectively
\setlrmarginsandblock{.5in}{1in}{*}
% Set top and bottom margins to .8 inches
\setulmarginsandblock{.8in}{.8in}{*}
% The {*} parameter tells LaTeX to use the measurements
% provided rather than attempt to calculate a ratio