Text Formattingglossaries | Conditionnal formatting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
sauvage
Posts: 3
Joined: Fri Sep 14, 2012 3:07 pm

glossaries | Conditionnal formatting

Post by sauvage »

According to the content of <symbol>, I would like to print it in italic followed by a comma, or not. I used the following redefinition (before \begin{document}), but it doesn't work, the symbol (eventually empty) and the comma are always printed. Where am I wrong? The acronym definition form is:

\newacronym[symbol={Symbol1}]{key1}{Acro1}{Definition1}

or

\newacronym{key2}{Acro2}{Definition2}

Code: Select all

   \renewcommand*{\glossaryentryfield}[5]{%
      \glsentryitem{##1}%                    %% Counter increment
      \glstarget{##1}{##2} &%                %% The acronym
      \ifx\@glo@symbol\@empty%               %% If present, the symbol
         \relax
      \else
         \textit{##4}, %
      \fi
      ##3 \\%                                %% The definition
   }
Last edited by cgnieder on Fri Oct 19, 2012 4:14 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

glossaries | Conditionnal formatting

Post by nlct »

The symbol defaults to \relax rather than \@empty, so you need to test for \relax:

Code: Select all

   \renewcommand*{\glossaryentryfield}[5]{%
      \glsentryitem{##1}%                    %% Counter increment
      \glstarget{##1}{##2} &%                %% The acronym
      \ifx\relax##4%               %% If present, the symbol
         \relax
      \else
         \textit{##4}, %
      \fi
      ##3 \\%                                %% The definition
   }%
Post Reply