1

How to get a math expression defined with newcommand as a {name} in \newglossaryentry? I have this

\newcommand{\equivdef}{{\overset{\text{def}}{\equiv\joinrel\equiv}}}

and want this glossary entry:

\newglossaryentry{equivdefi}{name={$\equivdef$},
description={define as equivalent to}
}

But get the error:

"! Argument of \@tempc has an extra }.
 <inserted text>
 \par
 l.10 }"

My MWE:

\documentclass[ebook,openany]{memoir}
\usepackage{amssymb}

\usepackage[sort=use,toc,style=long3col]{glossaries}

\newcommand{\equivdef}{{\overset{\text{def}}{\equiv\joinrel\equiv}}}

\newglossaryentry{equivdefi}{name={$\equivdef$},
description={define as equivalent to}
}

\makeglossaries
\normalfont
\begin{document}
Use symbol \gls{equivdefi} and define $p\veebar q$ as
\begin{equation}
p\veebar q\equivdef (p\vee q)\wedge\bigl(\neg(p\wedge q)\bigr).
\end{equation}
\printglossaries
\end{document}

The entry prints in the Glossary but not in the text. Mising symbol

Symbol in entry

3
  • in your text you say you have \newcommand{\equivdef} but your example shows \newcommand{\equivdefi}{ leaving equivdef undefined Aug 10, 2016 at 16:29
  • I don't think that is a good idea to use a math content macro as a glossary key name
    – user31729
    Aug 10, 2016 at 16:30
  • Agree @ChristianHupfer, but I would like to have it. In this example the entry prints in the Glossary but not in the text.
    – tatojo
    Aug 10, 2016 at 16:41

1 Answer 1

2

Don't neglect the error messages you get during processing. In this case the error is one that points to a fragile command in a moving argument:

! Argument of \@tempc has an extra }.
<inserted text> 
                \par 
l.10 }

Solution: add \protect.

\documentclass[ebook,openany]{memoir}
\usepackage{amssymb}

\usepackage[sort=use,toc,style=long3col]{glossaries}

\newcommand{\equivdef}{{\overset{\text{def}}{\equiv\joinrel\equiv}}}

\newglossaryentry{equivdefi}{
  name={$\protect\equivdef$},% <---- \protect
  description={define as equivalent to},
}

\makeglossaries
\normalfont
\begin{document}
Use symbol \gls{equivdefi} and define $p\veebar q$ as
\begin{equation}
p\veebar q\equivdef (p\vee q)\wedge\bigl(\neg(p\wedge q)\bigr).
\end{equation}
\printglossaries
\end{document}

enter image description here

However, your definition of \equivdef has a wrong pair of braces; moreover, you want \textnormal rather than \text (try it in a theorem statement to see why.

\newcommand{\equivdef}{\overset{\textnormal{def}}{\equiv\joinrel\equiv}}

enter image description here

Can you spot the difference?

3
  • Yes @egreg, with \textnormal you avoid the slanted or italics in a theorem. I can't see where to \protect the command. I use PDFLaTeX in TeXmaker.
    – tatojo
    Aug 10, 2016 at 17:27
  • 1
    @tatojo Sorry, I missed adding it.
    – egreg
    Aug 10, 2016 at 17:35
  • Great answer @egreg, this \protect command was something new for me.
    – tatojo
    Aug 10, 2016 at 17:42

You must log in to answer this question.

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