As an experiment, I wish to write a manuscript in core TeX, which typesets the text "Hello, world!", and compile it without any format.

If I was using the Plain TeX format, this program would be

Hello, world!

So to make this program independent of the format, I've copied all the missing definitions from plain.tex, and arrived at the following:

Hello, world!

When I compile this manuscript with tex -ini, the compilation proceeds successfully, and a dvi file is created. However, the dvi is empty. Why?

  • 7
    Nice hobby :) -- you seem to try to learn LaTeX from the scratch. Commented Aug 26, 2017 at 14:45
  • 14
    You haven't specified any fonts.
    – cfr
    Commented Aug 26, 2017 at 14:56
  • 8
    Don't you mean tex -ini rather than tex -init? You can run dvitype on the DVI to see what it contains; the DVI format is actually pretty cool. Commented Aug 26, 2017 at 15:30
  • 2
    try \hsize=10cm \vsize=10cm \parfillskip=0pt plus 1fil %\lineskip=1pt %\baselineskip=12pt %\lineskiplimit=0pt \font\myfont=cmr10 \myfont Hello world \end
    – touhami
    Commented Aug 26, 2017 at 15:36
  • 4
    See tug.org/TUGboat/tb36-2/tb113gregorio.pdf for some examples of shooting one's own foot.
    – egreg
    Commented Aug 27, 2017 at 8:36

3 Answers 3


Firstly, let's start with a simpler plain TeX file that does not use the \bye macro:

Hello, world!

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:


  % \showboxbreadth\maxdimen\showboxdepth\maxdimen}


Hello, world!

(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:

Hello, world!

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}
% \normalbaselines\rm % select roman font
\rm % select roman font

Hello, world!

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


\parfillskip=0pt plus 1fil

\font\tenrm=cmr10 % roman text

\def\line{\hbox to\hsize}

\countdef\pageno=0 \pageno=1 % first page is number 1

\def\pagebody{\vbox to\vsize{\boxmaxdepth\maxdepth \pagecontents}}
\def\makeheadline{\vbox to0pt{\vskip-22.5pt \line{\vbox to8.5pt{}\hfil}\vss}}

\tenrm % select roman font
Hello, world!

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.)

  • 1
    Thanks. If you know why, can you please spell out the reason the pdf is 2 pages? There are enough mysteries out there for me to figure out on my own...
    – Evan Aad
    Commented Aug 26, 2017 at 17:30
  • 2
    @EvanAad You've not set \hsize, so it's 0pt and TeX breaks into pages at every piece of whitespace. You probably want to set that and \parfillskip too.
    – Joseph Wright
    Commented Aug 26, 2017 at 17:52
  • 2
    @EvanAad I've gone further and produced a minimal .tex file for running with tex -ini, that produces the same output (including the positions on the page, and the page number at the bottom) as the hello-world plain-TeX file. Commented Aug 26, 2017 at 18:59

Skip TeX, write a PDF directly, it's a compiler-free solution. (just compiled the examples that I've learned from this blog). Paste it in a text editor and save it as a PDF file.


1 0 obj
  << /Type /Catalog
     /Pages 2 0 R

2 0 obj
  << /Type /Pages
     /Kids [3 0 R]
     /Count 1
     /MediaBox [0 0 100 15]

3 0 obj
  <<  /Type /Page
      /Parent 2 0 R
       << /Font
           << /F1
               << /Type /Font
                  /Subtype /Type1
                  /BaseFont /Times-Roman
      /Contents 4 0 R

4 0 obj
  << /Length 55 >>
    /F1 18 Tf
    0 0 Td
    (Hello World) Tj

0 5
0000000000 65535 f 
0000000018 00000 n 
0000000077 00000 n 
0000000178 00000 n 
0000000457 00000 n 
  <<  /Root 1 0 R
      /Size 5

enter image description here

  • 3
    Whats's the %¥±ë for? Commented Aug 26, 2017 at 17:27
  • 4
    @Dr.ManuelKuehner They are the high bit chars. You need at least 4 of them for the header.
    – percusse
    Commented Aug 26, 2017 at 17:30
  • 5
    @Dr.ManuelKuehner Not really. It's the bizarre PDF specification If a PDF file contains binary data, as most do (see 7.2, "Lexical Conventions"), the header line shall be immediately followed by a comment line containing at least four binary characters—that is, characters whose codes are 128 or greater. This ensures proper behaviour of file transfer applications that inspect data near the beginning of a file to determine whether to treat the file’s contents as text or as binary.
    – percusse
    Commented Aug 26, 2017 at 17:32
  • 4
    I've upvoted it because writing PDFs by hand is really cool. :-) Commented Aug 26, 2017 at 17:48
  • 8
    It might take a while to typeset War and peace, but it will be probably done before my thesis... 😁 Commented Aug 26, 2017 at 20:00

Here's a minimal core TeX manuscript that typesets "Hello, world!".

    % When the font is unspecified, it defaults to the nullfont,
    % in which glyphs have no visual representation.
    % Without this line the dvi page will appear empty.
    % When \hsize is unspecified, it defaults to 0pt,
    % which causes TeX to break page at every whitespace.
    % Without this line the words will be placed on separate pages.
\parfillskip=0pt plus 1fil
    % When \parfillskip is unspecified,
    % the whitepasce between words will stretch
    % to fill up as much line space as possible
    % while keeping all words on a single line.
    % The total line width is given by \hsize.
    % Without this line the two words will be positioned
    % at the opposite sides of a line that is 10cm wide.
Hello, world!

* This answer is based on the contributions of cfr's comment, touhami's comment, ShreevatsaR's answer, and Joseph Wright's comment.

  • 3
    what about \catcode\{=1 \catcode\}=2 \font\myfont=cmr10 \myfont \hbox{Hello world} \end
    – touhami
    Commented Aug 27, 2017 at 7:46
  • 1
    try to type the catcode correctly
    – touhami
    Commented Aug 27, 2017 at 7:49
  • 1
    @touhami: Yes, very nice, but it should be \catcode`, no? I don't know why you never wrote an answer.
    – Evan Aad
    Commented Aug 27, 2017 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .