LaTeX and Plain TeX are formats for TeX and they ease creating document. But can we create documents using only TeX? I couldn't find any pure TeX sample.
Asked
Active
Viewed 405 times
1 Answers
9
You can write simple documents using only TeX primitives:
\font\rm=ptmr7t
\font\bf=ptmb7t
\font\sl=ptmro7t
\rm
\hrule
\vskip 1in
\hbox to \hsize{\hss\bf A SHORT STORY\hss}
\vskip 6pt
\hbox to \hsize{\hss\sl by A. U. Thor\hss}
\vskip .5cm
Once upon a time, in a distant
galaxy called \accent "7F O\accent "7F o\accent 24 c,
there lived a computer
named R.\penalty10000\ J. Drofnats.
Mr.\penalty10000\ Drofnats---or ``R. J.,'' as
he preferred to be called---%
was happiest when he was at work
typesetting beautiful documents.
\vskip 1in
\hrule
\vfill\penalty-10000
\end
It's however obvious that macros are essential, not only for making our lives better.
Using some canned set of macros helps in communication.
If you want no format, then you need to do more initializations, running the file with pdftex -ini -output-format=pdf
\catcode`\{=1 % left brace is begin-group character
\catcode`\}=2 % right brace is end-group character
\catcode`\$=3 % dollar sign is math shift
\catcode`\&=4 % ampersand is alignment tab
\catcode`\#=6 % hash mark is macro parameter character
\catcode`\^=7 \catcode`\^^K=7 % circumflex and uparrow are for superscripts
\catcode`\_=8 \catcode`\^^A=8 % underline and downarrow are for subscripts
\catcode`\^^I=10 % ascii tab is a blank space
\chardef\active=13 \catcode`\~=\active % tilde is active
\catcode`\^^L=\active \outer\def^^L{\par} % ascii form-feed is "\outer\par"
\pdfpagewidth=8.5in
\pdfpageheight=11in
\hsize=6.5in
\vsize=8.9in
\baselineskip=12pt
\font\rm=ptmr7t
\font\bf=ptmb7t
\font\sl=ptmro7t
\rm
\hrule
\vskip 1in
\hbox to \hsize{\hss\bf A SHORT STORY\hss}
\vskip 6pt
\hbox to \hsize{\hss\sl by A. U. Thor\hss}
\vskip .5cm
Once upon a time, in a distant
galaxy called \accent "7F O\accent "7F o\accent 24 c,
there lived a computer
named R.\penalty10000\ J. Drofnats.
Mr.\penalty10000\ Drofnats---or ``R. J.,'' as
he preferred to be called---%
was happiest when he was at work
typesetting beautiful documents.
\vskip 1in
\hrule
\vfill\penalty-10000
\end
egreg
- 1,121,712
-
1
-
1
-
+1. On the other hand this also shows that macros are not essential, if one is not directly typing the
.texfile but generating it from text written in some other format; i.e. if one is using TeX as just the typesetting tool and not as the complete user interface. – ShreevatsaR Oct 27 '18 at 16:51 -
@ShreevatsaR Some stuff would be very tricky without, for example anything which needs to know which page material appears on – Joseph Wright Oct 27 '18 at 16:54
-
-
@egreg I used the code above with
\vfill\breakand pdfTeX generated a PDF file. Is\breaka TeX macro or a Plain TeX macro? – John webner Oct 27 '18 at 18:30 -
@Johnwebner It's the same
\penalty-10000in both plain TeX and LaTeX (but it is not mentioned in the LaTeX manual and only used internally, because\linebreakor\pagebreakare preferred). – egreg Oct 27 '18 at 20:01 -
@egreg Does it mean pdfTeX loads plain TeX by default? If not why does pdfTeX understand it? – John webner Oct 27 '18 at 20:08
-
@Johnwebner Yes, that's right: plain TeX is assumed. You could run
pdftex -ini, but then some further initialization has to be added. – egreg Oct 27 '18 at 20:35 -
@JosephWright Right, it's not always possible to completely generate a
.texfile offline, for some tasks. But even there IMO there are better ways of interacting with the TeX state than text-substitution macros. E.g. with LuaTeX one has hooks; or even otherwise one could conceive of ways of say pausing and restarting TeX after dumping relevant info. (I did do a fun project last year which did exactly need know which page material appears on… It was tricky sure, but macros wouldn't have made it less tricky AFAICT.) – ShreevatsaR Oct 27 '18 at 21:16
