Say there is an equation e = m * c^2 now I want to define each variable as : where, e = .. m = ... c = ..... This can be achieved using equation environment. But the question is, is there any way to define e, m and c so that they will be automatically added to the glossary when I use \makeglossary ?
Asked
Active
Viewed 2,635 times
1 Answers
4
Using the glossaries package, we can write a command to define a glossary entry at the same time we display it, like so:
\documentclass{report}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
\newcommand{\mathgloss}[2]{
\newglossaryentry{#1}{name={#1},description={#2}}
\gls{#1} = #2
}
\begin{document}
Consider the equation
\begin{equation}
e = m * c^2
\end{equation}
in which\\
\mathgloss{e}{energy}\\
\mathgloss{m}{mass}\\
\mathgloss{c}{speed of light}
\printglossaries
\end{document}
You can edit the \mathgloss
command to match your preferred formatting style.

Phssthpok
- 1,629
- 1
- 14
- 21