2

I have a question. I want to use SI unit X in my acronym definitions. For example:

\newacronym{M}{\si{\Molar}}{molar}

Sadly this doesn't work. Is there a way to do use SI units in the acronym definition? I know about the possibility to use \newglossaryentry, but I want to have all my acronyms in one list. When I remove all the \si parts, it works. But I'd like to have the spacing right.

5

1 Answer 1

4

(It would help if you provide a minimal working example (MWE) that people can work with.)

The problem is caused by the default expansion that's performed when the entry is defined. This can be fixed by using \glsnoexpandfields to switch off the expansion:

\documentclass{article}

\usepackage{siunitx}
\usepackage{glossaries}

\DeclareSIUnit\Molar{\textsc{m}}

\makeglossaries

\glsnoexpandfields

\newacronym{M}{\si{\Molar}}{molar}

\begin{document}

\gls{M}

\printglossaries
\end{document}

Alternative, protect the fragile commands:

\documentclass{article}

\usepackage{siunitx}
\usepackage{glossaries}

\DeclareSIUnit\Molar{\textsc{m}}

\makeglossaries

\newacronym{M}{\protect\si{\protect\Molar}}{molar}

\begin{document}

\gls{M}

\printglossaries
\end{document}
3
  • \si is not fragile (LaTeX3-based => \protected\def)
    – Joseph Wright
    Jul 15, 2015 at 11:54
  • @JosephWright Sorry, it's just \Molar that needs protecting. Jul 15, 2015 at 12:10
  • 1
    Thanks for your answer. I solved the problem with \newacronym[sort=M]{M}{\unexpanded{\si{\Molar}}}{molar}
    – tomriddle
    Jul 15, 2015 at 21:17

You must log in to answer this question.

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