2

This is a follow up question of this question. Why this plain code (from shreevatsar's answer)

\newwrite\outfile
\openout\outfile\jobname.out
\end

produce a page but this (equivalent) latex code does not?

\documentclass{article}
\newwrite\outfile
\openout\outfile\jobname.out
\begin{document}
\end{document}

1 Answer 1

3

If you insert a \showlists just before the end

\makeatletter
\showoutput


\def\enddocument{%
   \let\AtEndDocument\@firstofone
   \@enddocumenthook
   \@checkend{document}%
   \clearpage
   \begingroup
     \if@filesw
       \immediate\closeout\@mainaux
       \let\@setckpt\@gobbletwo
       \let\@newl@bel\@testdef
       \@tempswafalse
       \makeatletter \@@input\jobname.aux
     \fi
     \@dofilelist
     \ifdim \font@submax >\fontsubfuzz\relax
       \@font@warning{Size substitutions with differences\MessageBreak
                  up to \font@submax\space have occurred.\@gobbletwo}%
     \fi
     \@defaultsubs
     \@refundefined
     \if@filesw
       \ifx \@multiplelabels \relax
         \if@tempswa
           \@latex@warning@no@line{Label(s) may have changed.
               Rerun to get cross-references right}%
         \fi
       \else
         \@multiplelabels
       \fi
     \fi
   \endgroup
   \deadcycles\z@\showlists\@@end}




\documentclass{article}

\newwrite\outfile
\openout\outfile\jobname.out
\begin{document}

\end{document}

You see

### vertical mode entered at line 0
### current page:
\write-{}
\openout3=file.out
\write-{}

prevdepth 0.0

! OK.
\enddocument ...dgroup \deadcycles \z@ \showlists 
                                                  \@@end 
l.47 \end{document}

? 

That is the write node is left on its own.

Essentially the implicit \clearpage at the end of the document has cycled round and knows there is no height in the current page and it has no floats to add, so it stops.


Conversely the plain output routine is

\def\plainoutput{\shipout\vbox{\makeheadline\pagebody\makefootline}%

It is not doing any tests to re-insert floats (Plain TeX uses the \insert mechanism so doesn't handle floats "by hand" the way LaTeX does) so it always ships out something whenever the output routine is called.

You must log in to answer this question.

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