Epigraphs in LaTeX

There are times when part of the message, the gist, must be communicated to the reader in an out-of-band fashion, so to speak. One way of doing this is to use an epigraph to open a chapter or section, carefully chosen to convey the intended message but in the voice of another author (self-epigraphs are of very bad taste in my opinion).

\LaTeX is the preferred document preparation system of computer scientists, physicists, and mathematicians and if you intend to follow a career into the academia, it’s pretty much unavoidable. One day, you’ll have to learn \LaTeX. The thing is, \LaTeX is pretty much like C++: it can do just about anything, but it’s not going to help you do it. You have to rely on the innumerable packages or, if you really can’t find what you need, you can code it yourself. Let us have a look on how to code an epigraph macro in \LaTeX.

A typical epigraph might look like

This one is somewhat lengthy, but put the classical premature optimization is evil quote in its context, bringing nuances not all authors are careful to bring up.

The basic structure of an epigraph is simple: it has a section for the text, one for the author, and one for the reference such as the book title, end reference number, URL, or any combination of the above. In this case, there’s the article title with an hyper-reffed end reference number. But we may not need all three; maybe just text and author is enough, or even just text. So we need three versions of the epigraph macro.

The first parameter is the width of the text. Then comes the text. Then optionally the author name, then optionally again the reference. I am pretty sure that there’s a better, more \LaTeXish way of implementing these, but that’s what I came up with:

% epigraph with 4 params.
% first is width
% second is text
% third is author
% four is book title
%
\newcommand\bookepigraph[4]{
\vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
\small\noindent\textit{#2}\end{spacing}
\vspace{1em}
\hfill{}{#3}\\

\vspace{-1em}\begin{flushright}{#4}\end{flushright}}\vspace{2em}
\end{minipage}}

% epigraph with 3 params
% first is width
% second is text
% third is author
%
\newcommand\epigraph[3]{
\vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
\small\noindent\textit{#2}\end{spacing}
\vspace{1em}
\hfill{}{#3}}\vspace{2em}
\end{minipage}}

% epigraph with 2 params
% first is width
% second is text
\newcommand\anonymousepigraph[2]{
\vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
\small\noindent\textit{#2}\end{spacing}}
\vspace{1em}
\end{minipage}}

Using bookepigraph produced the epigraph shown above.

*
* *

The \LaTeX document description standard is cumbersome but I still greatly prefer it to, say, Microsoft Word. Word is a very well built piece of software and it is very usable as long as you don’t really try to push the envelope and you need plug-ins to do simple things such as end reference management.

\LaTeX also seems to scale much better than Word of an image- and equation-rich document. If you plan to write a book on a mathematical topic, you just can’t do it with Word. Well, I suppose you could, but I find the basic equation editor clunky and the resulting equations still look like they’ve been hacked with a 1910s typewriter. They’re tweakable, but what requires a lot of work. With \LaTeX, you just rely on the system to produce elegantly typeset equations and you rarely need to tweak things. \LaTeX further more scales much better with large documents, even though you need to “compile” it once in a while to see what it looks like. There’s no problem writing a 1000-page book in latex. Good luck with that with Word.

\LaTeX also have easier cross-referencing than Word, whether chapters, sections, equations, or end references.

But what I like best, is the separation between contents, description, and rendering. With Word, the file is the presentation; you do not have (easy) access to its internal representation. If the file breaks for some reason, you kiss your work goodbye. If a small portion of a \LaTeX file has invalid syntax, you can still open it with any text editor and fix it.

*
* *

The \LaTeX project is the official web site for \LaTeX.

You can also find documentation and packages at the Comprehensive TEX Archive Network, the CTAN.

The \LaTeX wikibook site is fraught with useful information.

Finally, I suggest you get the The \LaTeX Companion book (at Amazon.com). It turns out to be extremely complete and one of those rare exception where it’s far easier to find stuff in the book than by googling. A must-have of the serious \LaTeX user.

5 Responses to Epigraphs in LaTeX

  1. DJL says:

    Really nice epigraph, and I am looking for something very similar. However, I’m afraid that the instructions are not very clear for me (I am a newbie). For starters, where does that text go? In the preamble? After \begin{document}? (I assume the latter) Do you have to load any other packages (like epigraph)? What is the value of #1 that you used? The full code of what you did would have helped a lot, I think. Many thanks in advance.

    • Steven Pigeon says:

      Right! Here’s some code to illustrate its use:

      \documentclass{book}
      
      \usepackage{setspace}
      
      
      
      \newcommand\bookepigraph[4]{
      \vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
      \small\noindent\textit{#2}\end{spacing}
      \vspace{1em}
      \hfill{}{#3}\\
      
      \vspace{-1em}\begin{flushright}{#4}\end{flushright}}\vspace{2em}
      \end{minipage}}
      
      
      \newcommand\epigraph[3]{
      \vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
      \small\noindent\textit{#2}\end{spacing}
      \vspace{1em}
      \hfill{}{#3}}\vspace{2em}
      \end{minipage}}
      
      \newcommand\anonymousepigraph[2]{
      \vspace{1em}\hfill{}\begin{minipage}{#1}{\begin{spacing}{0.9}
      \small\noindent\textit{#2}\end{spacing}}
      \vspace{1em}
      \end{minipage}}
      
      \begin{document}
      
      \bookepigraph{2in}{This is a most excellent epigraph macro for
      \LaTeX.}{some name}{from Some Book}
      
      \epigraph{2in}{This is another most excellent epigraph}{some guy}
      
      \anonymousepigraph{2in}{Well, that's mostly swell}
      
      \end{document}
      
      
    • Steven Pigeon says:

      There was also a syntax error in the anonymous epigraph that I fixed

  2. DJL says:

    thank you very much; much appreciated. the final result is just beautiful.

  3. Jessica says:

    thanks so, so much! i hate the line that appears with the epigraph package. :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: