I have several files in the sub-folder ./tmp -- "a.tex" whose content is \def\aaa{aaa}, "b.tex" whose content is `\def\bbb{bbb}.
Then I input them to my main doc at one time by \foreach, as the following code tries, but it fails to work, and causes error message Undefined control sequence..
What shall I do?
Code:
\documentclass{article}
\usepackage{pgffor}
\foreach \x in {a.tex,b.tex}{
\input{tmp/\x}
}
\begin{document}
\aaa\bbb
\end{document}

\gdef. – Tom Jun 15 '22 at 03:24\gdef\input? Or are there any better methods than\foreach? – lyl Jun 15 '22 at 03:27\gdef\aaa{aaa},\gdef\bbb{bbb}– Tom Jun 15 '22 at 03:28\newcommand, how to make it global? – lyl Jun 15 '22 at 03:31\newcommandwas use\def, you could use\let\olddef\def\let\def\gdef\newcommand...\let\def\olddef– Tom Jun 15 '22 at 03:43\defas it relates many other things. It seems that\foreachin my example is not a good idea. Any other better methods for this question? – lyl Jun 15 '22 at 04:07\global\let\aaa\aaa. There isn't really a non-hacky way I guess. – user202729 Jun 15 '22 at 04:08\foreachand look forward to other better ways. – lyl Jun 15 '22 at 04:22