# Can I see a plain TeX source file please?

all the LaTeX-tutorials tell me how LaTeX is an extention simplifying the building of TeX documents. Understandably, no one uses plain TeX anymore, right?

But I seem to learn better when I grasp the link between TeX and LaTeX. Does someone have a link to example files in plain TeX? I'd like to know which commands, macros etc. are LaTeX-specific.

• See now also xcix.tex in What is the most bizarre thing you have seen done with TeX. – Speravir Feb 1 '14 at 3:33
• I never use LaTeX. I've written about a million words in plainTeX and am currently typesetting a collection of notes on learning Japanese with it (using XeTeX for font-handling) with kanji and furigana which needed about three lines of TeX to implement. I've never seen a convincing argument for the complexity and inflexibility of LaTeX. Just saying. – Nagora Oct 25 '16 at 11:20

Here's an example, taken from here.

% Plain TeX for a 1 page document

%% The lines between the two rows of %'s are more or less compulsory.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\magnification=\magstep1
\baselineskip=12pt
\hsize=6.3truein
\vsize=8.7truein
\font\footsc=cmcsc10 at 8truept
\font\footbf=cmbx10 at 8truept
\font\footrm=cmr10 at 10truept
\footline={\footsc the electronic journal of combinatorics
{\footbf 16} (2009), \#R00\hfil\footrm\folio}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The further structure of the front page need not be exactly as below,
%% but the header must contain the names and addresses of the authors
%% as well as the submission and acceptance dates.

\font\bigrm=cmr12 at 14pt
\centerline{\bigrm An elementary proof of the reconstruction conjecture}

\bigskip\bigskip

\centerline{D. Remifa\footnote*{Thanks to
the editors of this wonderful journal!}}
\smallskip
\centerline{Department of Inconsequential Studies}
\centerline{Solatido College, North Kentucky, USA}
\centerline{\tt remifa@dis.solatido.edu}

\bigskip

\centerline{\footrm
Submitted: Jan 1, 2009; Accepted: Jan 2, 2009; Published: Jan 3, 2009}
\centerline{\footrm Mathematics Subject Classifications: 05C88, 05C89}

\bigskip\bigskip

\centerline{\bf Abstract}
\smallskip
{\narrower\noindent
The reconstruction conjecture states that the multiset of unlabeled
vertex-deleted subgraphs of a graph determines the graph, provided it
has at least 3 vertices.  A version of the problem was first stated
by Stanis\l aw Ulam.  In this paper, we show that the conjecture can
be proved by elementary methods.  It is only necessary to integrate
the Lenkle potential of the Broglington manifold over the quantum
supervacillatory measure in order to reduce the set of possible
counterexamples to a small number (less than a trillion).  A simple
computer program that implements Pipletti's classification theorem
for torsion-free Aramaic groups with simplectic socles can then
finish the remaining cases.\par}

\bigskip

\beginsection 1. Introduction.

This is the start of the introduction.

\bye


Result:

• It doesn't even have a \documentclass and it says \bye at the end. Tee hee hee. Thanks :) – Alexander Engelhardt Dec 3 '10 at 17:20
• @Alexx: Well, not that simple! LaTeX introduces a lot of macros into TeX. Obviously, you can't use them in plain TeX. – M.S. Dousti Dec 3 '10 at 17:41

Since TH took the chance to post xii.tex, I take the chance and post my further condensed version (needs almost 14% less key strokes for the same output :-)). This exercise was indeed my first plunge into the inner workings of TeX.

\let~\catcode~76~A13~F1~j00~P2jdefA71F~7113jdefPA;;FP
PA**7172F727171PAKK7172F72r71PAqq71.F71Kse71PAIIFoPAXXFKdiP
AQQFjbigskipDOPAzzFhPAHHFDPATT7172F72a71PAZZFTDDPAUU71,72MF
jpar71ing;jifx:72jelseU72MjfiPABB71W72;73,74:Fjif.74.jelseB
74:jfiQn tJ;z7172tz; TydDIfDCEzs;tTsm;DmWa;y "KKJtDulIY TYg
tI J;mU7173,74:MPB tJlwWf;Wq;Yq K*dmu.,eJYlnW;q Ep"p.,JntW;
lKsGZlTpe,En"nW;eDTJlsE "dTndc,Egz"eW;t Emd"TsZElk"m,JYsnW;
sTnwWo;sZs*mE"w,Ex"sW; Jg*JZsTyl,E"fWf;Y gGlEDng"KsW,fIurW;
TlcEngD"lbXsW,tzWXW;K*J JfKncz JnzsW,WJcsGnW;tWace;wI tKtuJ
DldIYsW,WKsE"ftW;aHAHHFndZPKpTEt"KdJEgn"DZpJTKDtK*J.W,:jbye

• it should be said that this isn't really typical of plain tex docs :-} – wasteofspace Aug 4 '14 at 12:31

There are many examples of plain TeX source files. For example all my books and articles are written in plain TeX:

There is an example of Bachelor thesis written in plain TeX (including sources):

It is not true that plain TeX doesn't give possibility to separate the logical markup from typesetting tasks. I and my students consistently respect this rule. You can verify this in sources of mentioned bachelor thesis, for example.

Unfortunatelly, texbook.tex isn't good example because the typesetting macros are mixed with text here. There are \def's inside document, \eject, etc.

You can create bad document (where the typesetting task is mixed with logical markup) or good document independently off the basic used macro is plain TeX or LaTeX. From this point of view, the accepted answer here is bad example of good practice in plain TeX, because there are \bigskip\bigskip, \centerline \indent etc. inside author's part of the document.

Finally, I disagree, that the example by David Carlisle is the typical example of plain TeX. This is only an example of TeX capabilities. The plain TeX has no common with it. You can create the following document:

\documentclass{article}
\begin{document}
\def\bye{\end{document}}
\let~\catcode~76~A13~F1~j00~P2jdefA71F~7113jdefPALLF
PA''FwPA;;FPAZZFLaLPA//71F71iPAHHFLPAzzFenPASSFthP;A$$FevP A@@FfPARR717273F737271P;ADDFRgniPAWW71FPATTFvePA**FstRsamP AGGFRruoPAqq71.72.F717271PAYY7172F727171PA??Fi*LmPA&&71jfi Fjfi71PAVVFjbigskipRPWGAUU71727374 75,76Fjpar71727375Djifx :76jelse&U76jfiPLAKK7172F71l7271PAXX71FVLnOSeL71SLRyadR@oL RrhC?yLRurtKFeLPFovPgaTLtReRomL;PABB71 72,73:Fjif.73.jelse B73:jfiXF71PU71 72,73:PWs;AMM71F71diPAJJFRdriPAQQFRsreLPAI I71Fo71dPA!!FRgiePBt'el@ lTLqdrYmu.Q.,Ke;vz vzLqpip.Q.,tz; ;Lql.IrsZ.eap,qn.i. i.eLlMaesLdRcna,;!;h htLqm.MRasZ.ilk,% s;z zLqs'.ansZ.Ymi,/sx ;LYegseZRyal,@i;@ TLRlogdLrDsW,@;G LcYlaDLbJsW,SWXJW ree @rzchLhzsW,;WERcesInW qt.'oL.Rtrul;e doTsW,Wk;Rri@stW aHAHHFndZPpqar.tridgeLinZpe.LtYer.W,:jbye  and process it by LaTeX. Will you claim that this is typical LaTeX document? Edit I'd show the same example as in the accepted answer here (by Sadeq) but with the separated parts: macros and the author's text. The author can be somebody else than the programmer of the macros. The plain TeX file created by the author of the text would be: \input macros \title {An elementary proof of the reconstruction conjecture} \author {D. Remifa\footnote*{Thanks to the editors of this wonderful journal!}} \department {Department of Inconsequential Studies} \address {Solatido College, North Kentucky, USA} \email {remifa@dis.solatido.edu} \edinfo {Submitted: Jan 1, 2009; Accepted: Jan 2, 2009; Published: Jan 3, 2009\nl Mathematics Subject Classifications: 05C88, 05C89} \printdata \abstract The reconstruction conjecture states that the multiset of unlabeled vertex-deleted subgraphs of a graph determines the graph, provided it has at least 3 vertices. A version of the problem was first stated by Stanis\l aw Ulam. In this paper, we show that the conjecture can be proved by elementary methods. It is only necessary to integrate the Lenkle potential of the Broglington manifold over the quantum supervacillatory measure in order to reduce the set of possible counterexamples to a small number (less than a trillion). A simple computer program that implements Pipletti's classification theorem for torsion-free Aramaic groups with simplectic socles can then finish the remaining cases. \section Introduction. This is the start of the introduction. \bye  The macros.tex file declares (1) the markup and (2) the dessign of the document: \magnification=\magstep1 \font\footsc=cmcsc10 at 8truept \font\footbf=cmbx10 at 8truept \font\footrm=cmr10 at 10truept \footline={\footsc the electronic journal of combinatorics {\footbf 16} (2009), \#R00\hfil\footrm\folio} \font\bigrm=cmr12 at 14pt \newtoks\title \newtoks\author \newtoks\department \newtoks\address \newtoks\email \newtoks\edinfo \def\printdata{\par \centerline{\bigrm\the\title}\vskip2\baselineskip \if^\the\author^\else \centerline{\the\author}\medskip\fi \if^\the\department^\else \centerline{\the\department}\fi \if^\the\address^\else \centerline{\the\address}\fi \if^\the\email^\else \centerline{\tt\the\email}\fi \if^\the\edinfo^\else \bigskip {\footrm \leftskip=0pt plus1fill \rightskip=\leftskip \the\edinfo\par}\fi \vskip2\baselineskip } \def\nl{\hfil\break} \def\abstract{\par\centerline{\bf Abstract}\smallskip \bgroup \def\par{\endgraf\bigskip\egroup} \narrower \noindent } \newcount\secnum \def\section#1\par{\global\advance\secnum by1 \csname beginsection\endcsname \the\secnum. #1\par }  The output is exactly the same as in the accepted answer here. • +1 BTW I can't read anywhere that xii.tex were a typical example. @TH. calling it the best source is of course a bit subjective :) – cgnieder Aug 4 '14 at 8:44 • OK, it isn't typical example. But it is mentioned in this thread. Will somebody claim that my example above is the best LaTeX source? – wipet Aug 4 '14 at 8:52 • @wipet I think that was more like a joke. By the way, those are nice links. – Manuel Aug 4 '14 at 8:54 • @wipet my smiley was supposed to indicate that I interpreted “best” as a joke. (IMHO it's a quite obvious one, too, but I may well be mistaken...) – cgnieder Aug 4 '14 at 8:58 • @wipet to me it is funny since xii.tex quite obviously is not the best plain TeX source (sorry David). Of course nobody writes their documents this way. Why would I claim plain TeX to be mysterious? Anyway: all I wanted to say was: good answer. – cgnieder Aug 4 '14 at 9:19 if you really want to be boggled by a plain tex source file, go to the ur-source: http://mirror.ctan.org/tex-archive/systems/knuth/dist/tex/texbook.tex this is what it says it is -- the source of the texbook -- and it has been made available by don knuth so that people can see how he solved various problems. it shouldn't be tex'ed without his permission. of course, it's most meaningful when viewed together with the printed version; try to find someone who can lend you a copy. the formatting depends on a collection of macros created specifically for the purpose; \input manmac.tex makes these available. that file is included in the tex live distribution and it's worth taking a look at it to see how it differs from latex packages. it's my opinion that, whatever the flavor of the input one might be using for a tex job, the first order of business is to decide on (design, if necessary) the basic user interface, and only then embark on the input of the content. from there, they will most often develop in parallel. • I think both the TeXbook and wipet's example elsewhere in this thread are not truly Plain TeX: they use an external [manmac|macros].tex file. In fact, they define alternative markup languages, based on Plain TeX macros. – jarnosz Jun 24 '15 at 19:10 • @elford -- strictly speaking, you are correct. knuth never envisioned use of plain tex as a "final" interface for anything non-trivial. (and i don't know anyone who would disagree with that point of view, except, perhaps, the author of xii.tex.) plain.tex is a useful starting point for building one's own special-purpose interface. i don't think i've come across anything in plain.tex that i've ever had to undefine. – barbara beeton Jun 24 '15 at 19:43 The best plain TeX source is David Carlisle's xii.tex: \let~\catcode~76~A13~F1~j00~P2jdefA71F~7113jdefPALLF PA''FwPA;;FPAZZFLaLPA//71F71iPAHHFLPAzzFenPASSFthP;A$$FevP
AGGFRruoPAqq71.72.F717271PAYY7172F727171PA??Fi*LmPA&&71jfi
Fjfi71PAVVFjbigskipRPWGAUU71727374 75,76Fjpar71727375Djifx
RrhC?yLRurtKFeLPFovPgaTLtReRomL;PABB71 72,73:Fjif.73.jelse
B73:jfiXF71PU71 72,73:PWs;AMM71F71diPAJJFRdriPAQQFRsreLPAI
I71Fo71dPA!!FRgiePBt'el@ lTLqdrYmu.Q.,Ke;vz vzLqpip.Q.,tz;
;Lql.IrsZ.eap,qn.i. i.eLlMaesLdRcna,;!;h htLqm.MRasZ.ilk,%
s\$;z zLqs'.ansZ.Ymi,/sx ;LYegseZRyal,@i;@ TLRlogdLrDsW,@;G
doTsW,Wk;Rri@stW aHAHHFndZPpqar.tridgeLinZpe.LtYer.W,:jbye

• So you found your chance to post xii.tex. How do you like my version? :-) – Hendrik Vogt Jan 15 '11 at 20:38
• @Hendrik: Heh. I wondered if anyone would remember that comment. I like your version. One of these days, I'll actually go to the trouble of figuring out more than the first three lines. – TH. Jan 15 '11 at 21:04

To counter your suggestion that nobody uses Plain TeX any more, I recently switched from LaTeX to Plain TeX. It allows much more control over what goes onto the page, whereas LaTeX is a little presumptuous about what the user wants.

In particular, I have a program which stores an internal model which I want to visualise using TeX. LaTeX doesn't quite line up with that model. My program simply serialises the model into a sequence of TeX macro calls, and I \def those macros in another .tex file to appear exactly how I want them.

So here is a generated plain-tex file:

% Generated code
\input model.tex

\modeltitlepage{This is a sweet document dooD}{1 August 2014}

\modelsection{Part A: The start}

Once upon a time there was a document.  It was nice.

\modelitem{0}{1}{
Eggs and ham
\modelitem{1}{1.1}{
Eggs
}
\modelitem{1}{1.2}{
Ham
}
}

\modelsection{Part B: The end}

\modeltable{2}{
\modelrow{
\modelcell{the}
\modelcell{end}
}
}

\bye


LaTeX is only simpler in the circumstances it is designed for.

• latex itself wasn't designed for most of the uses it now serves; it was designed to provide a basis on which software, to produce specific documents, will run — not (in fact) much different from knuth’s aim in designing plain tex. these arguments about which is “best” are members of that subclass of all arguments which generate more heat than light; they're also off-topic for a question about plain tex code samples. (and all of the argument has ignored context, which is another fine contender.) – wasteofspace Aug 4 '14 at 16:01
• I am a little confused about your comment. I gave an answer to the question "Can I see a plain TeX source file please?". I also gave an answer to the question "Understandably, no one uses plain TeX anymore, right?". The original question didn't mention ConTeXt at all. I am pretty new on t.se so I'd appreciate feedback on what I could have done better in my answer! – Luke Worth Aug 5 '14 at 12:26

Here is a reference card for (plain) TeX by J.H. Silverman: http://refcards.com/docs/silvermanj/tex/tex-refcard-a4.pdf

I find it invaluable.

• I think that card looks really useful, but it isn't really what the questioner asked for: an example of a TeX document... – Seamus Dec 3 '10 at 17:13
• @Seamus: OP concluded with his ultimate goal: "I'd like to know which commands, macros etc. are LaTeX-specific." It is far easier to go the other way around: "Which commands are TeX-specific", don't you think? – morbusg Dec 3 '10 at 17:32