Firstly, let's start with a simpler plain TeX file that does not use the \bye
macro:
Hello, world!
\end
This already works fine when run with tex
(produces a DVI file containing “Hello, world!”), and (as \end
is a TeX primitive and not something defined in plain.tex
) can be run with tex -ini
without (visible) errors, but producing a “blank” DVI file.
To see what's going on, we'd like to turn on tracing, maybe \tracingall
if we don't know what sort of tracing we'd like. This \tracingall
is defined in plain.tex
, and copying the relevant parts from plain.tex
exactly as you did, gives:
\catcode`\{=1%
\catcode`\}=2%
\catcode`@=11%
\chardef\@ne=1
\chardef\tw@=2
\def\loggingall{\tracingcommands\tw@\tracingstats\tw@
\tracingpages\@ne\tracingoutput\@ne\tracinglostchars\@ne
\tracingmacros\tw@\tracingparagraphs\@ne\tracingrestores\@ne
% \showboxbreadth\maxdimen\showboxdepth\maxdimen}
\showboxbreadth100\showboxdepth100}
\def\tracingall{\tracingonline\@ne\loggingall}
\catcode`@=12%
\tracingall
Hello, world!
\end
(I cheated a bit: the commented out line above with \showboxbreadth\maxdimen\showboxdepth\maxdimen
is the original; I just used \showboxbreadth100\showboxdepth100
to avoid having to pull in definitions of \maxdimen
which needs \newdimen
which needs \alloc@
etc.) Anyway, with this it's easier to see the issue in the output: lines like
{the letter H}
{horizontal mode: the letter H}
Missing character: There is no H in font nullfont!
{the letter e}
Missing character: There is no e in font nullfont!
and so on. Actually you can get this output even with a smaller .tex
file:
\tracingonline=1
\tracingcommands=2
\tracinglostchars=1
Hello, world!
\end
Anyway, now that you know that the issue is fonts, you can copy over the relevant bits from plain.tex
(again I've replaced a few lines from plain.tex
(commented out) with simpler equivalents, to avoid copying a whole lot):
\catcode`\{=1 % left brace is begin-group character
\catcode`\}=2 % right brace is end-group character
\font\tenrm=cmr10 % roman text
% \def\rm{\fam\z@\tenrm}
\def\rm{\fam0\tenrm}
% \normalbaselines\rm % select roman font
\rm % select roman font
Hello, world!
\end
Running this with tex -ini
typesets the characters in the output, but causes an interesting issue: the resulting dvi file has two pages, one containing “Hello,” and one containing “world!”
But the original issue is resolved, so I'll leave it to you to figure out this mystery. :-)
Edit: For completeness here is a minimal .tex
file that when run with tex -ini
produces an identical .dvi
file (identical except for the timestamp comment of course) as a .tex
file containing Hello, world!\bye
does when run with tex
:
\catcode`\{=1 % left brace is begin-group character
\catcode`\}=2 % right brace is end-group character
\hsize=6.5in
\vsize=8.9in
\parindent=20pt
\topskip=10pt
\parfillskip=0pt plus 1fil
\font\tenrm=cmr10 % roman text
\def\line{\hbox to\hsize}
\countdef\pageno=0 \pageno=1 % first page is number 1
\output{\plainoutput}
\def\plainoutput{\shipout\vbox{\makeheadline\pagebody\makefootline}}
\def\pagebody{\vbox to\vsize{\boxmaxdepth\maxdepth \pagecontents}}
\def\makeheadline{\vbox to0pt{\vskip-22.5pt \line{\vbox to8.5pt{}\hfil}\vss}}
\def\makefootline{\baselineskip24pt\lineskiplimit0pt\line{\hss\tenrm\number\pageno\hss}}
\def\pagecontents{\unvbox255}
\tenrm % select roman font
Hello, world!
\end
Every line (before the last two) is either from plain.tex
or a simplified version of one, and removing any line makes the DVI output no longer identical. (Of course to make it minimal I've removed a lot that is useful such as the instruction in \plainoutput
that advances the page number, so this will not work when you have more than one paragraph or even more than one line, let alone more than one page.)
tex -ini
rather thantex -init
? You can rundvitype
on the DVI to see what it contains; the DVI format is actually pretty cool.\hsize=10cm \vsize=10cm \parfillskip=0pt plus 1fil %\lineskip=1pt %\baselineskip=12pt %\lineskiplimit=0pt \font\myfont=cmr10 \myfont Hello world \end