I can properly use a define
\def <command> <parameter-text>{<replacement-text>}
if it is define in the same LaTeX file, which is not the main file, but let's say, it is named 2.intro.tex
which is included with \input{section/2.intro}
.
However, if I put the define in the main.tex
of even in another file which in included before 2.intro
, it does not work. When compiling, it says
! Undefined control sequence.
Any help on how to solve this problem?
main.tex
\documentclass[letterpaper, 10pt]{elsarticle}
\usepackage{lipsum}
\begin{document}
\begin{frontmatter}
\def\mylabel{[My Label in Main2]}
\lipsum[1]
\end{frontmatter}
\input{intro}
\end{document}
intro.tex
\lipsum[1]
Trying to use \mylabel
\input
has no effect on the scope of commands, tex works just as if the contents of the file were copied at that place, so if you get undefined commands the error will be elsewhere. post a small example that shows the problem. – David Carlisle Feb 25 '19 at 15:02begin
andend
, I just realized that now. – Eduardo Reis Feb 25 '19 at 15:39\begin{foo}...\end{foo}
generally comes with an implicit group so that definitions inside the environment stay local to that environment unless they are explicitly made\global
. – moewe Feb 25 '19 at 15:41\newcommand
not\def
and before the\begin{frontmatter}
– David Carlisle Feb 25 '19 at 15:45