I am writing a textbook with multiple chapters, and each chapter has a separate .lyx file. For convenience, I'd like to gather all my symbol definitions, etc. in a separate .tex file which I import just before the end of the preamble with \input. The publisher has a standard macro file, to which I have appended my definitions at the bottom:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Local Definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\global\long\def\bum{\boldsymbol{\muup}}%
\global\long\def\bus{\boldsymbol{\Sigma}}%
\global\long\def\bubeta{\boldsymbol{\betaup}}%
\global\long\def\IntroChapter{Chapter 1}%
\global\long\def\FoundationsChapter{Chapter 2}%
\global\long\def\RelevantEarlierChapters{Chapters 2, 4, and 13}%
I then import it just prior to the end of the preamble as follows:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{C:/Users/XX/YY/myMacros.tex}
\belowsink=90pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end_preamble
Something strange happens when I compile the file: If I insert a piece of TeX code that uses only standard letters and numbers - I have copied the generated TeX code here:
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
**IntroChapter**
\end_layout
\end_inset
\end_layout
it works perfectly; I see the phrase "Chapter 1" exactly where I placed it in LyX. However, if I enter an equation that should result in a bold upright Greek letter mu (TeX code follows)
\begin_layout Standard
\begin_inset Formula $\bum$
\end_inset
\end_layout
I get four identical knitr errors (Undefined control sequence), all with the same description:
$\bum
$
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
If I now click on Show Output Anyway, I see the letter mu, and it is upright, but not bolded.
In contrast, if I define \bum in the main file, right after \begin_body as follows:
\begin_body
\begin_layout Standard
\begin_inset FormulaMacro
\newcommand{\bum}{\boldsymbol{\muup}}
\end_inset
\end_layout
it works beautifully as I expect: no knitr errors and a perfect bold upright mu. What am I doing wrong in or with myMacros.tex and \input, and how can I fix this?
Sincerely and with many thanks in advance
Thomas Philips