10

In latex.ltx, \protected@write is defined as:

\long\def \protected@write#1#2#3{%
      \begingroup
       \let\thepage\relax
       #2%
       \let\protect\@unexpandable@protect
       \edef\reserved@a{\write#1{#3}}%
       \reserved@a
      \endgroup
      \if@nobreak\ifvmode\nobreak\fi\fi
}

Is there any side effect in using \immediate before \write in the definition of \protected@write?

16

If you change this in \protected@write the side effects are severe. For example, \protected@write is used in \label. The page number is not known right away in general. The delay of the \write without \immediate writes the entry at page shipout time, when the page number is known.

Thus do not change \protected@write. If you need immediate writing, use a new macro instead and do not use it for page numbers and such things that are reliably correct at shipout time only.

Your Answer

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