Code: Select all
\begin{equation}
T = \frac{1}{2} \sum_{n=1}^N \dot{u}_n^2
\label{eq:Kinetic}
.\end{equation}
Code: Select all
\begin{equation}
T = \frac{1}{2} \sum_{n=1}^N \dot{u}_n^2
\label{eq:Kinetic}
.\end{equation}
NEW: TikZ book now 40% off at Amazon.com for a short time.
equations.tex
-- with a macro \saveequation{<ID>}{<equation code>}
and use those equations in the main file via \useequation{<ID>}
.Code: Select all
\documentclass{article}
% this is the separate file for the sake of this example
% created with {filecontents}:
\usepackage{filecontents}
\begin{filecontents}{equations.tex}
\makeatletter
% \saveequation{<ID>}{<equation>}
\newcommand\saveequation[2]{%
\@namedef{equation@#1}{#2}%
}
% \useequation{<ID>}
\newcommand\useequation[1]{%
\@nameuse{equation@#1}%
}
\makeatother
\RequirePackage{amsmath,bm}
\saveequation{massenergy}{E = mc^{2}}
\saveequation{curlE}{\nabla \times \bm{E} = 0}
\end{filecontents}
% input the file:
\input{equations}
\begin{document}
% usage:
This is Einstein's relation: $\useequation{massenergy}$.
This is the curl of electric field:
\begin{equation}
\useequation{curlE}\label{eq:curlE}
\end{equation}
and without number:
\[
\useequation{curlE}
\]
\end{document}
Code: Select all
\makeatletter
\newcommand\saveequation[2]{\@namedef{equation@#1}{#2}}
\newcommand\useequation[1]{\@nameuse{equation@#1}}
\makeatother
\saveequation{SavedEnergyCalc}{\frac{A^2}{2} \left(N +1 \right) \left( 1 - \cos \frac{\pi}{N+1} \right)}
...
\begin{align}
H(A,N) &= \useequation{SavedEnergyCalc} \label{eq:EnergyCalc}
.\end{align}
saveequation
can be used inside the document body.NEW: TikZ book now 40% off at Amazon.com for a short time.