Monday, April 11, 2011

Source code of books made with TeX/LaTeX to learn

Some time ago, reading this entry I found a nice image and a pointer to a better book entitled "Thinking Forth". To my surprise, the LaTeX sources of the book were ready to download, with pearls like:

%% There's no bold typewriter in Computer Modern.
%% Emulate with printing several times, slightly moving

\newdimen\poormove
\poormove0.0666pt
\newcommand{\poorbf}[1]{%
\llap{\hbox to \poormove{#1\hss}}%
\raise\poormove\rlap{#1\hss}%
\lower\poormove\rlap{#1\hss}%
\rlap{\hbox to \poormove{\hss}\hbox{#1}}%
#1}

%\let\poorbf=\textbf
\renewcommand{\poorbf}[1]{{\fontencoding{OT1}\fontfamily{cmtt}\fontseries{b}\selectfont#1}}

in which it can simulate the bold stroking of a font that doesn't have it. Since reading that, I was unaware of \llap and such, but now I can use them to define boxes, etc.

So, my question is twofold:

  1. Do you know of sites that show that relatively advanced use of TeX/LaTeX in terms of useful recipes, and
  2. Do you know any books that offer their TeX/LaTeX source to inspect and learn (and that are worth doing so.)?
From stackoverflow
  • Believe it or not, but the source code to the TeXbook is actually freely downloadable:

    TeXbook source code package

    Diego Sevilla : Thanks, lindelof, nice link! I was aware of it, but it is somewhat tough to read, and I was thinking more in the lines of LaTeX instead of TeX.
  • There are two comprehensive reference guides/recipe books for TeX:

    In both cases, the sources are also available.

    As lindelof mentions, the TeXBook is also available, albeit in a form that prevents compilation (Knuth wished people to look at the source for inspiration but not to reproduce the book freely):

    On the LaTeX side of things, resources a little more scarce from the programming point of view. The best free reference that I know of is

    Of course there's also

    but that doesn't cover so much programming "stuff". The LaTeX sources themselves contain some useful nuggets, but the quality of the documentation ranges from excellent to non-existent in parts; this should be available in your distribution with texdoc source2e.

    Other large LaTeX packages obviously have the source to their documentation available; a notable example is the memoir class:


    I'm sure there are many more books with their source available; these are just the first ones that come to mind that happen to also be able TeX and/or LaTeX.

  • Not that I'd recommend it (unless you've got a lot of time and caffeine to spare), but I learned a lot from just reading the latex.ltx file. I learned a lot not only about LaTeX but also of course about TeX. It's a heavy read though and I'd suggest reading a book about TeX first before diving into the latex.ltx file.

    I wanted to know about how "optional" parameters actually worked and reading the latex.ltx file really helped me understand.

  • I found this one that looks really nice, but I was not able to compile it yet. Let me know if you can…

    This is a book by Allen B. Downey:

    Computational Modeling and Complexity Scienc

0 comments:

Post a Comment