You are here: Home / Przedsięwzięcia/Projects / TeX Pearls / 2006 Pearls / bernd-raichle / bachotex2006-bernd-raichle-pearl3.tex


TeX document icon bachotex2006-bernd-raichle-pearl3.tex — TeX document, 1 KB (1022 bytes)

File contents

%%% Bernd Raichle: \input file inside a macro definition.
% If you have a file and want to read its contents in a macro definition, TeX
% does not allow to simply use
% \edef\foo{\input file }
% because at the end of a file TeX checks if you are inside an incomplete \if
% statement or \def macro definition and outputs the error message
% ! File ended while scanning text/definition of ...
% Nonetheless there is a non-trivial way to avoid this error message:

\immediate\write15{Another TeX}

\edef\foo{Yet \input bt-pp-r4.tex !}

% The primitive \noexpand does all the magic and you will get
% macro:->Yet Another TeX Pearl!
% without any error message.
% {\bf Question:} Why has \noexpand this effect?
% If you are using e-TeX, you can set its new special token list \everyeof to
% \noexpand to achieve this effect without changing the file.


Document Actions