4

This is a continuation of my question question.

For a given code I would like to add symbol. For example:

\mathgloss{m}{mass}{kg}

MWE:

\documentclass{report}
\usepackage{enumitem}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries

\newcommand{\mathgloss}[2]{%
    \newglossaryentry{#1}{name={#1},description={#2}}%
    \begin{description}[labelwidth=3em]%
      \item[\gls{#1}]#2%
    \end{description}%
}

\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} 

I tried writing ("a blind shot"):

\newcommand{\mathgloss}[3]{%
    \newglossaryentry{#1}{name={#1},description={#2},symbol={#3}}%
    \begin{description}[labelwidth=3em]%
      \item[\gls{#1}]#2 #3%
    \end{description}%
}

...but I missed the target.

3
  • Could you explain what isn't working as you wish? If I substitute your code and add an additional argument to each occurrence of \mathgloss in your MWE, it compiles and prints the symbol just as you've asked. If the issue is that the symbol is not displayed in your glossary, make sure you are using a style which supports printing symbols as not all do.
    – cfr
    Jan 12, 2014 at 1:35
  • With my code I got an error File ended while scanning use of \mathgloss \input{chapters/}
    – Michal
    Jan 13, 2014 at 21:22
  • I've found the bugs. Firstly I had to delete *.gls file (as @karlkoeller advised me). Secondly I missed one bracket :/ Anyway thank you for your support.
    – Michal
    Jan 13, 2014 at 21:41

1 Answer 1

5

You have to choose a glossary style that prints the symbol field. You can find them on the Table 15.1 of the glossaries documentation.

enter image description here

If you choose, for example, the index style, you have then to print the glossary with

\printglossary[style=index]

MWE (I also changed a little the definition of \mathgloss):

\documentclass{report}
\usepackage{enumitem}
\usepackage{siunitx}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries

\newcommand{\mathgloss}[3]{%
    \newglossaryentry{#1}{name={#1},description={#2},symbol={#3}}%
    \begin{description}[labelwidth=3em]%
      \item[\gls{#1}]#2 (\textbf{#3})%
    \end{description}%
}

\begin{document}

Consider the equation
\begin{equation}
e = m * c^2
\end{equation}
in which
\mathgloss{e}{energy}{J}
\mathgloss{m}{mass}{Kg}
\mathgloss{c}{speed of light}{m/s}

\printglossary[style=index]

\end{document} 

Output (document):

enter image description here

Output (glossary):

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .