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
  • 2
  • @Johannes_B I thought I'd seen something like this before :-)
    – Joseph Wright
    Commented Jul 14, 2015 at 15:51
  • @Johannes_B thanks for the link! ive already seen this thread and wanted to ask, if there is a possibility to do it with newacronym. there are just a few acronyms with si units. i dont want to add an additional line, i want to use si units in my acronym definition
    – tomriddle
    Commented Jul 14, 2015 at 15:58
  • golatex.de/viewtopic,p,73945.html#73945
    – Johannes_B
    Commented Jul 14, 2015 at 16:59
  • Can you show a minimal working example that let's us reproduce the issue?
    – Johannes_B
    Commented Jul 14, 2015 at 19:46

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
    Commented Jul 15, 2015 at 11:54
  • @JosephWright Sorry, it's just \Molar that needs protecting. Commented 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
    Commented 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 .