3

How can I replicate the style of the quotes in Knuth's "The Art of Computer Programming"?

I mean the quotes found at the beginning and at the end of each chapter, for example see the following one which is a one-liner:

enter image description here

or the following which spans more than one line:

enter image description here

  • 1
    You have the epigraph package. – Bernard Feb 15 '19 at 20:15
  • 2
    Knuth uses plain TeX, not LaTeX. These look like the quotes in the TeXbook, and those are defined in the file manmac.tex. Under the circumstances, it's probably easier to define your own environment using \raggedleft. the epigraph package, I believe, doesn't have quite the same style, although it's otherwise very nice. – barbara beeton Feb 15 '19 at 22:39
14

Well if you literally want to replicate what Knuth did, you could use the same macros. The macros he used/uses for The Art of Computer Programming (TAOCP) are available as taocpmac.tex, and the relevant ones for the examples in the question are \quoteformat and \author. Download taocpmac.tex, comment out the \input figdir.local line at the top (or create a file of that name) and do something like:

\input taocpmac

\beginchapter CHAPTER SIX: SEARCHING.

{\quoteformat{Let's look at the record.}
\author AL SMITH (1928)
}

\medskip

The normal text of the chapter here.

\bigskip

{\quoteformat{I shall have accomplished my purpose if I have sorted out and put in logical order
the gist of the great volume of material which has been generated about sorting
over the past few years.}
\author J. C. HOSKEN (1955)
}

\bye

Compile it with tex or pdftex (or xetex or luatex, i.e. not any *latex):

result

If you don't want to pull in all of taocpmac.tex you could copy over just the relevant macros, and you can even dress them up in superficially LaTeX-ish clothing if you prefer:

\documentclass{article}
\font\eightss=cmssq8
\font\eightssi=cmssqi8
\newcommand\quoteAuthorDate[3]{\begingroup
  \baselineskip 10pt
  \parfillskip 0pt
  \interlinepenalty 10000 % not needed in example
  \leftskip 0pt plus 40pc minus \parindent
  \let\rm=\eightss
  \let\sl=\eightssi
  \everypar{\sl}#1\par
  \nobreak\smallskip
  \noindent\rm--- #2\unskip\enspace(#3)\par
  \endgroup}

\begin{document}
\hsize = 6in %  Wider than default, to illustrate.

\quoteAuthorDate{Let's look at the record.}{AL SMITH}{1928}

\medskip

The normal text of the chapter here.

\bigskip

\quoteAuthorDate{I shall have accomplished my purpose if I have sorted out and put in logical order\par
the gist of the great volume of material which has been generated about sorting\par
over the past few years.}{J. C. HOSKEN}{1955}

\medskip

\end{document}

Adjust the skips and line breaks as desired. Although you may get something passable even without manually chosen breaks, DEK chooses the line breaks manually — that's the reason the definition of \quoteformat has \obeylines in it, and my “LaTeX” example above has \pars in the second quote. LaTeX users tend not to like such things. If you're in the same category, you can try to find a LaTeX package that does what you want. For example, as mentioned in the comments on the question, you can use epigraph:

\documentclass{article}
\usepackage{epigraph}
\begin{document}

\epigraph{Let's look at the record.}{AL SMITH (1928)}

The normal text of the chapter here.

\setlength{\epigraphwidth}{0.9\textwidth}
\epigraph{I shall have accomplished my purpose if I have sorted out and put in logical order
the gist of the great volume of material which has been generated about sorting
over the past few years.}{J. C. HOSKEN (1955)}

\end{document}

but the appearance isn't the same as in TAOCP.


Historical appendix: How do we know that this is how DEK enters the quotes, besides the fact that these macros exist in taocpmac.tex?

Well actually I don't know about the surrounding { and }, but as for the rest (\quoteformat and \author), in fact this is something that hasn't change substantially since the very first “design doc” that DEK wrote for TeX back in May 1977, before a single line of the TeX program had been written. In these (TEXDR.AFT and TEX.ONE, published in Digital Typography) he wrote down what he'd like to type as input, and it's basically the same. Later, the older TeX manual (e.g. the one published in TeX and METAFONT: New Directions in Typesetting) actually went into great detail on how the input to TAOCP was done, in its “Appendix E: Example of a Book Format” where these macros were in a file called acphdr.TEX at the time, and it even says “For quotations you type ...” and gives \quoteformat and \author. (The current TeXbook in its “Appendix E: Example Formats” instead explains manmac.tex which is used to typeset The TeXbook itself, and you can also look at how quotes are done in texbook.tex) There's also mention of acpmac.tex in this TUG 1995 interview, and finally it's now called taocpmac.tex.

  • 1
    Thanks for such a complete historical exposition. – barbara beeton Feb 16 '19 at 17:22
  • I tested with success your first source. I downloaded ftp.cs.stanford.edu/tex/local/lib/taocpmac.tex and I just needed to create a file with name figdir.local with this content \def\figdir{/home/acp/figs}; after that, I compiled with tex and pdftex. I am on pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) kpathsea version 6.2.2 and TeX 3.14159265 (TeX Live 2016/Debian) kpathsea version 6.2.2 . – Alessandro Jacopson Feb 17 '19 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.