You can read the content of a file into a macro with Heiko Oberdiek's
This will read the file like a normal TeX file, i.e. it can include macros etc. The
<setup> argument can be empty for files read normally but can include special code to e.g. read the file content verbatim or with special handling of line endings etc. A good candidate here is
\makeatletter if the file contains macros with
@ in their names.
Verbatim mode can be set using
\let\do\@makeother\dospecials. You might want also to add
\@noligs to disable ligatures. The text should then be typeset using
\verbatim@font (which is identical to
\normalfont\ttfamily). Otherwise some symbols (like
_) will not be displayed correctly. The above commands need
\makeatletter to be used before the
If you want to preserve line endings use
\obeylines. You should also add
\obeyspaces if you want the spaces being print normally not with a special symbol. Also
\frenchspacing can be added to avoid the larger space after dots.
% Verbatim text requires a suitable font:
Make sure that the last command in
<setup> isn't an assignment like
...\endlinechar=-1}. You need to add an
\relax then, otherwise TeX will expand the internal commands of
\CatchFileDef to look for the rest of the number. I mentioned that to the author already and an internal
\relax will be added in the next version.