4

I am trying to align my symbols in a glossary with \phantom. However when I try to do so, I get the following error (line 10 is the line where the definition of nc:line:num ends(closing brace)):

! Incomplete \iffalse; all text was ignored after line 10.

near MWE:

\documentclass{report}

\usepackage[sanitize=none]{glossaries}

\makeglossaries%

\newglossaryentry{nc:line:num}{
    name=thing,
    symbol=\ensuremath{\phantom{\#}l},
    description=other thing}
\newglossaryentry{nc}{
    name=thingy,
    symbol=\ensuremath{\#l},
    description=something}


\usepackage{glossary-mcols} 


\begin{document}
    \printglossary[style=altlong4col]
    asd
    \clearpage%
    nc:line:num glossary entry '\gls{nc:line:num}` \gls{nc}
\end{document}

Background: I have symbols that usually exist in two versions as symbol and as #symbol, therefore i would like to align in the following way:

 symbol
#symbol
 other
#other

rather than

symbol
#symbol
other
#other

Note: sanitize=none is used because I reference entries from another glossary, see this awnser

ted
  • 3,377
  • maybe a different phrasing of the title would make this more "attractive", something like "aligning glossary entries with a flag character to the left of some entries". (too many words, but you get the idea.) – barbara beeton Jun 14 '13 at 15:11
  • @barbarabeeton: thank you for your input. Luckily I already have the awnser and unfortunately I fail to see a catchy phrase, but I will try to keep this in midn for new questions. – ted Jun 16 '13 at 13:20

1 Answers1

3

The entry for symbol is written to the file .glo. \phantom or \hphantom is fragile and breaks. \protect needs to be used:

\documentclass{report}

\usepackage[sanitize=none]{glossaries}

\makeglossaries%

\newglossaryentry{nc:line:num}{
    name=thing,
    symbol=\ensuremath{\protect\hphantom{\#}l},
    description=other thing}
\newglossaryentry{nc}{
    name=thingy,
    symbol=\ensuremath{\#l},
    description=something}  


\usepackage{glossary-mcols}


\begin{document}
    \printglossary[style=altlong4col]
    asd
    \clearpage%
    nc:line:num glossary entry '\gls{nc:line:num}` \gls{nc}
\end{document}

Result

Heiko Oberdiek
  • 271,626
  • 1
    for those who are as unfamiliar with latex as i am, looke here to see what protect and fragile are about – ted Jun 16 '13 at 12:50