A colleague of mine had a LaTeX-specific issue for which I did not exactly know the cause of the issue. I have distilled a Minimal Working Example to illustrate the issue.
Originally my colleague had several files and used \include in the following way:
Main .tex file: testi.tex:
\documentclass{article}
\usepackage{graphics}
\makeatletter
\newcommand{\test@}{test}
\makeatother
\begin{document}
\scalebox{0.8}{
\input{testii}
}
\end{document}
Included .tex file: testii.tex:
\makeatletter
\test@
\makeatother
This worked without any problems (the included constructs of this form originated from automated generated code to annotate .pdf images). Then, my colleague tried to make a single *.tex file. Hence, he replaced the \input command by including the content of testii.tex in testi.tex:
Single-file testi.tex: testd.tex:
\documentclass{article}
\usepackage{graphics}
\makeatletter
\newcommand{\test@}{test}
\makeatother
\begin{document}
\scalebox{0.8}{
\makeatletter
\test@
\makeatother
}
\end{document}
The file testd.tex did, however, not compile: the error message was:
! Undefined control sequence.
<argument> \makeatletter \test
Hence: LaTeX reads the command \test instead of \test@, which should have been read due to the \makeatletter construct. We found a way to resolve the issue (by placing \scalebox inside a \makeatletter/\makeatother pair), but still I am wondering what the cause (bug?) of the differences in behavior between inlined LaTeX code and \input-ed LaTeX code is.
\scalebox{}{ \input{figure.pdf_t} }I can't find a clean way to put a\makeatletterat the right place automatically. Your solution works well when writing the code manually though, and thanks for the explanation! – Matthieu Moy May 11 '15 at 17:50\makeatletterin the preamble and forget about the issue. – David Carlisle May 11 '15 at 18:19