5

The Tex Book (20th printing, 1991) describes the \shipout<box> primitive as follows (p. 279).

After the <box> is formed — possibly by constructing it explicitly and changing modes during the construction, as explained for \hbox earlier — its contents are sent to the dvi file

Based on this description, I would expect the pdf for the following plain TeX manuscript

\shipout\hbox{Hello, }%
\shipout\hbox{world!}%
\bye

to comprise a single page with the one-liner:

Hello, world!

Instead, it comprises two pages:

  1. Hello,

  2. world!

Why?

  • 3
    Your expectation is wrong: every \shipout operation ships out a page. – egreg Aug 8 '17 at 15:20
  • 3
    \shipout is the only way to make a new page in an output file as far as I know. – David Carlisle Aug 8 '17 at 15:20
  • 1
    Do you mean the TeX Book? – cfr Aug 8 '17 at 15:54
11

Your expectations are not in line with TeX’s, I’m afraid. If you look at page 227, last doubly dangerous paragraph, you can read

Sometimes you don't want TeX to defer a \write or \openout or \closeout. You could say, e.g., ‘\shipout\hbox{\write...}’, but that would put an unwanted empty page in your dvi file.

Every \shipout operation ships out a page in the DVI file (or PDF, in case of pdftex with \pdfoutput=1).

With \shipout<box>, the box is built, then delivered in the proper format to the DVI (or PDF) file and finally removed from memory.

Note that \shipout, by itself, has no effect on the main vertical list: it's normally the output routine that manages it and usually calls \shipout\box255 at the appropriate time, thus outputting a new page. So if you do

ABC

\shipout\hbox{DEF}

GHI

\bye

you will get two pages: one with “DEF” and the other one with the two lines “ABC” and “GHI”.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.