5

I would like to print a special character to an aux file. In particular, I would like to write the line

\@input{file.aux}

So far, I have achieved the best result with

\write\@auxout{\unexpanded{\@input{file.aux}}}

However, this approach produces an additional whitespace before the first bracket.

What is the appropriate way to print special characters like \ or @ to an (aux) file? The possibly related examples provided here and here appear unnecessarily complicated and I am not quite able to implement them for my purpose.

  • Welcome to TeX.SX! Please use full documents instead of fragments of code ;-) – user31729 Jul 6 '15 at 20:19
  • The additional space is not of a concern, because it will be ignored at reading time. – egreg May 29 '16 at 8:47
4

Use \string\@input{file.aux} to write the stuff literally into the .aux file. As long no further expansion is involved, this is (the best?) way to get TeX commands literally into file output.

The \immediate is not really necessary, I just use it in almost any case, that's the only reason.

\documentclass{article}

\begin{document}

\makeatletter
\immediate\write\@auxout{%
  \string\@input{file.aux}%
}
\makeatother
\end{document}
  • Thank you. This works. I would like to confirm that it can also be used as \write\@auxout{\string\@input{file.aux}}. – LeroyHangard Jul 6 '15 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.