I have some big equations that I wanted to separate out of the text of my document to make the source code easier to read. The idea was to declare a command for each equation in a separate file, include the file in the preamble of my document, and then just call the command for that equation in the appropriate place in the text. Here's a single-file example:
\documentclass{article}
\newcommand{\testCommand}{
\begin{equation} \label{eq1}
a = b + c
\end{equation}
}
\begin{document}
\testCommand
\cite{eq1}
\end{document}
The problem with this is that I get undefined reference errors when I try to cite the equation. I'm assuming that the compiler must go through and find labels before it expands commands or something. Anyway, I was just wondering if there is a way to make this work. I would also appreciate some insight on what's going on under the hood that causes this to happen.
\newcommand{\myweirdeq}{a=b+c}
and use\begin{equation}\label{eq1}\myweirdeq\end{equation}
, so your document will be correctly marked up. – egreg Jul 6 '12 at 7:56