TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 17 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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