Discussion:
glossaries: fail to expand in tabularx
(too old to reply)
Leo
2010-01-23 14:23:02 UTC
Hello,

The following example demonstrates the problem:

\documentclass{article}
\usepackage[acronym]{glossaries}
\usepackage{tabularx}
\newacronym{CW}{CW}{continuous-wave}
\begin{document}
\begin{tabularx}{\linewidth}{X}
\gls{CW}
\end{tabularx}
\end{document}

CW will not be expanded. I wonder if this is a bug?

Best,

Leo
Nicola Talbot
2010-01-25 11:44:38 UTC
Post by Leo
\documentclass{article}
\usepackage[acronym]{glossaries}
\usepackage{tabularx}
\newacronym{CW}{CW}{continuous-wave}
\begin{document}
\begin{tabularx}{\linewidth}{X}
\gls{CW}
\end{tabularx}
\end{document}
CW will not be expanded. I wonder if this is a bug?
I haven't looked at the tabularx code, but I expect it's because
tabularx parses its contents more than once (or puts it in a box,
maybe). If you do:

\begin{tabularx}{\linewidth}{X}
\newcommand{\foo}{}\global\let\foo\foo
\end{tabularx}

You'll get two instances of the error message "Command \foo already
defined."

If you know that you haven't used the acronym CW, then you could just
put \glsreset{CW} before \gls{CW} or, if you're not sure, you could do:

\documentclass{article}
\usepackage[acronym]{glossaries}
\usepackage{tabularx}
\newacronym{CW}{CW}{continuous-wave}
\begin{document}

\ifglsused{CW}{\def\resetCW{}}{\def\resetCW{\glsreset{CW}}}
\begin{tabularx}{\linewidth}{X}
\resetCW\gls{CW}
\end{tabularx}
\end{document}

Regards
Nicola Talbot
--
Home: http://theoval.cmp.uea.ac.uk/~nlct/
LaTeX Related Information: http://theoval.cmp.uea.ac.uk/~nlct/latex/
Creating a LaTeX Minimal Example:
http://theoval.cmp.uea.ac.uk/~nlct/latex/minexample/

--- news://freenews.netfront.net/ - complaints: ***@netfront.net ---
Leo
2010-01-25 14:38:13 UTC
Post by Nicola Talbot
I haven't looked at the tabularx code, but I expect it's because
tabularx parses its contents more than once (or puts it in a box,
\begin{tabularx}{\linewidth}{X}
\newcommand{\foo}{}\global\let\foo\foo
\end{tabularx}
You'll get two instances of the error message "Command \foo already
defined."
I think this is exactly the reason.
Post by Nicola Talbot
If you know that you haven't used the acronym CW, then you could just
\documentclass{article}
\usepackage[acronym]{glossaries}
\usepackage{tabularx}
\newacronym{CW}{CW}{continuous-wave}
\begin{document}
\ifglsused{CW}{\def\resetCW{}}{\def\resetCW{\glsreset{CW}}}
\begin{tabularx}{\linewidth}{X}
\resetCW\gls{CW}
\end{tabularx}
\end{document}
Regards
Nicola Talbot
Thank you for the workaround. I will put a big warning around the table
and fix it later on.

Best,
Leo
--
H A P P Y H O L I D A Y S!