I am trying to create an easy way to include a number of equations in multiple spots of a report (or reports) without having to retype them each time and keep nomenclature consistent across all equations. I have an "equation library" that I want to include in various files to make the equations available.
% eq.tex
\def \a {\nomenclature{$a$}{Coefficient}}
\def \b {\nomenclature{$b$}{Coefficient}}
\def \c {\nomenclature{$c$}{Coefficient}}
\def \m {\nomenclature{$m$}{Slope}}
\def \x {\nomenclature{$x$}{Variable}}
\def \y {\nomenclature{$y$}{Variable}}
\def \line {
\label{line}
\b \m \x \y
$$y=mx+b$$
}
\def \parabola {
\label{parabola}
\a \b \c \x \y
$$y=ax^2+bx+c$$
}
This way I can just include \line in a file and have the necessary nomenclature available.
% main.tex
\documentclass{article}
\usepackage{nomencl}
\makenomenclature
\input{eq}
\begin{document}
\printnomenclature
\line
\parabola
\end{document}
This produces the nomenclature as you would expect
Nomenclature
a Coefficient
b Coefficient
c Coefficient
m Slope
x Variable
y Variable
However, I would like to have an equation number and label available to reference in the text. When I introduce the equation environment, the nomenclature section has duplicate entries.
I've tried both
\begin{equation}
\line
\end{equation}
\begin{equation}
\parabola
\end{equation}
and
\def \line {
\label{line}
\b \m \x \y
\begin{equation}
y=mx+b
\end{equation}
}
\def \parabola {
\label{parabola}
\a \b \c \x \y
\begin{equation}
y=ax^2+bx+c
\end{equation}
}
which both yield duplicate entries in the nomenclature
Nomenclature
a Coefficient
b Coefficient
b Coefficient
c Coefficient
m Slope
x Variable
x Variable
y Variable
y Variable
Is there something special about the equation environment that is throwing this off? Am I missing some fundamental understanding about defining terms?
I also tried using \newcommand and the document wouldn't compile
\labelhas no anchor. Using of$$is obsolete: http://tex.stackexchange.com/questions/40492/what-are-the-differences-between-align-equation-and-displaymath – Marco Daniel Mar 21 '17 at 21:37