You are here: Home / Przedsięwzięcia/Projects / TeX Pearls / 2008 Pearls / javier-mugica / bachotex2008-javier-mugica-pearl2.tex


TeX document icon bachotex2008-javier-mugica-pearl2.tex — TeX document, 1 KB (1014 bytes)

File contents

%%% access outer \input level

% Imagine we need to grab the first param from some input file.tex.
% We are lucky, the following works fine:

\def\do#1{\tt <do something with #1>}
\expandafter\do\input file.tex {crazy}

% And what if we would like to execute \do from the file.tex level, catching the parameter that lays just
% after the \input command in the outer level document?

% Well, since \do requires an argument, it cannot occur at the very end of the input file.tex.
% We may try this:

% outer document content (this document):
\def\do#1{#1 indeed}
\input file.tex {crazy}?

% file.tex content
% Isn�t that \expandafter\do\endinput

% But then TeX complains

% 	! File ended while scanning use of \do

% So we don't expand \endinput, but the end of the file itself:

% outer document content the same as before
% file.tex content
% Isn�t that \expandafter\do

% And then it works!
% (The actual example is in my package makepattern, file mkpatter.tex in CTAN.)


Document Actions