[texhax] Why isn't \immediate\write outputting stuff from page 1?

Donald Arseneau asnd at triumf.ca
Mon Nov 18 12:29:35 CET 2013


On Sun, November 17, 2013 5:44 pm, Suresh Govindachar wrote:
>
>
>    % In the following, why doesn't the toc.tex file contain
>    % the line for the sections on the very first page?
>
>    % In case the email messes up long lines, have attached
>    % file test_toc.tex
>
>    \newwrite\contents
>    \openout\contents=toc.tex

You need \immediate\openout if you want to open it immediately.

>    \newcount\sectioncount
>    \sectioncount=0
>    \def\mysection#1{\advance\sectioncount by 1%
>    \vskip3mm%
>    {\noindent\bf \the\sectioncount. #1}\par\noindent%
> \immediate\write\contents{\string\line\string{\string\item\string{\the\sectioncount.\string}
> \string#1
>    \string\dotfill{} \the\pageno\string} }
>    }

By using \immediate\write you will record the wrong page number
sometimes.


Donald Arseneau, TRIUMF CMMS, asnd at triumf.ca



More information about the texhax mailing list