[texhax] Question about cwebmac.tex

David Carlisle d.p.carlisle at gmail.com
Mon Feb 1 10:53:14 CET 2016

On 27 January 2016 at 22:52, Igor Liferenko <igor.liferenko at gmail.com>

> Hi all,
> Following are three occurrences of using \pdfoutline in cwebmac.tex
>     \pdfoutline goto name {NOS} count -\secno {\outsecname}
>     \pdfoutline goto num \the\toksA \expandafter{\the\toksE}}
>     \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}
> Why \expandafter is used in the second case specifically (in
> comparison with other cases)?

without looking at the context in cwebmac, the difference is that
without \expandafter the outline will contain the (unexpanded)
tokens from the token register as \the on a token register
suppresses further expansion.

With the \expandafter the token register is expanded before being passed
to the whatsit so the resulting tokens are then fully expanded as in
edef or write. The other two cases are not involving \the so \expandafter
would make no difference there

You can see this in the following plain (pdf)tex file

\pdfoutline goto num 2 \expandafter{\the\toksE}
\pdfoutline goto num 3 {\the\toksE}

The resulting pdf is

% 1 0 obj
<< /S /GoTo /D 3 0 R >>
% 5 0 obj
% 6 0 obj
<< /S /GoTo /D 7 0 R >>
% 9 0 obj
(\foo )
% 11 0 obj

note how the first outline is (bar) but the second is (\foo) as \foo did
not expand
while writing the outline.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20160201/fdd45410/attachment.html>

More information about the texhax mailing list