1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.