6

I'd like to try to create a document structure and table of contents in pure TeX. Does anyone know of any resources or examples to do this? My purpose is mainly educational, to learn how to write macros and structure documents in pure TeX.

I know how to define basic commands using \def, and I've written documents in plain TeX but I don't understand enough about programming in TeX to feel able to tackle a big task like this.

  • 2
    You may want to have a look at eplain.tex – egreg Jul 02 '16 at 23:20
  • 1
    this wiki may help, here is the link for the file that egreg mentionned eplain.tex – Cfun Jul 02 '16 at 23:34
  • 1
    For a wide answer about programming on Latex. About defining new commands – Cfun Jul 02 '16 at 23:43
  • eplain.tex looks very interesting to learn from, and thanks for the link to it as well. I'm trying to work using just core TeX (I'm weird like that :) ), so the more specifically LaTeX oriented stuff is less useful. – alter_kaker Jul 03 '16 at 00:16
  • 1
    The TeX Book, of course, and the source of the TeX Book. (Not the bits which rely on the plain format already being defined, but the bits about the primitives and the defining of that format etc.) But this is presumably obvious. – cfr Jul 03 '16 at 00:30
  • The ability to see the obvious is often considered the truest mark of genius. Thank you. – alter_kaker Jul 03 '16 at 01:09
  • 3
    if you'd like to look at a perhaps rather unconventional collection of tables of contents prepared with plain tex, you can look at the tugboat contents. (much of tugboat is now set with latex, but the contents, front matter and calendar are still "plain only".) you can see the typeset contents as part of each issue, linked from http://tug.org/TUGboat , and the input for the contents can be found at ctan; go to http://ctan.org/search and search for "tugboat". these contents files are compiled by hand (it's possible to automate, but easier manual), if questions, please ask. – barbara beeton Jul 03 '16 at 01:40
  • 2
    I'm sure that OPmac has this type of functionality, and it is I believe written in plain TeX http://petr.olsak.net/opmac-e.html – A Feldman Jul 03 '16 at 05:09

1 Answers1

9

If you are willing to use a macro package for that, I can recommend the compact opmac macros. They provide access to a multitude of LaTeX's features in a simple manner.

\input opmac
\maketoc
\sec Hello World
\bye

enter image description here

If you want to implement it on your own, you can just look at opmac.tex to get inspiration. The source is very readable and easy to understand.

Henri Menke
  • 109,596