glossaries: fail to expand in tabularx

When I use an acronym (glossaries or acronym package) for the first time in tabularx, then it fails to expand, and even breaks down the table structure. The problem is already mentioned here, but there is no straightforward solution provided.

The problem does not appear with \acf, \acs or other commands that do not check for the first time usage of the entry. However, it is not a solution, as the whole idea of this package is automatic checking. I am looking for a simple solution with not too much processing overhead, as I have thousands of \ac commands in my text.

Sample code:

\documentclass{article}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{tabularx}
\newacronym{BI}{BI}{Beacon Interval}

\begin{document}

\begin{tabularx}{\textwidth}{|l|X|}
Parameter & Value \\ \hline
\ac{BI}  & Typical: 0.1 seconds. I heard somebody say, that the sentence ended here, But everyone knows it's goin' still. \\
\end{tabularx}

\bigskip

\begin{tabularx}{\textwidth}{|l|X|}
Parameter & Value \\ \hline
\ac{BI}  & Typical: 0.1 seconds. I heard somebody say, that the sentence ended here, But everyone knows it's goin' still. \\
\end{tabularx}

\end{document}

-
Could you make your snippet of code into a complete minimal working example (MWE)? –  egreg Jan 22 '13 at 17:19
I just tried it using the acronym package. Works fine with tabular. Sadly, this does not work correctly with tabularx, too. –  Rico Jan 22 '13 at 17:19
I changed it to a complete MWE. –  Aydin Jan 23 '13 at 13:23
I don't think it's a good idea that an acronym appears for the first time in the tabular. The obvious problem is that tabularx makes two passes over the material, so on the first pass it expands the "new" acronym, but on the second pass the acronym has been marked as "already seen" and so not expanded any more. –  egreg Jan 23 '13 at 13:44
@egreg, I agree, and try to avoid such an occasion. However, the procedure is somewhat automatic. I have a long text full of acronyms. If I remove a paragraph (that has an acronym) from an early chapter, then the acronym may appear somewhere else for its first time. I don't want to end up with unpredictable layout issues when there is no time to review the whole document. –  Aydin Jan 25 '13 at 16:20

\documentclass{article}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{tabularx}
\newacronym{BI}{BI}{Beacon Interval}
\makeatletter

\def\foo#1\hbox#2#3!!{%
\def\TX@trial##1{#1\hbox{\let\glsunset\@gobble#2}#3}%
}
\expandafter\foo\TX@trial{#1}!!
\makeatother
\begin{document}

\noindent X \dotfill X

\noindent
\begin{tabularx}{\textwidth}{|l|X|}
Parameter & Value \\ \hline
\ac{BI}  & Typical: 0.1 seconds. I heard somebody say, that the sentence ended here, But everyone knows it's goin' still. \\
\end{tabularx}

\bigskip

\noindent
\begin{tabularx}{\textwidth}{|l|X|}
Parameter & Value \\ \hline
\ac{BI}  & Typical: 0.1 seconds. I heard somebody say, that the sentence ended here, But everyone knows it's goin' still. \\
\end{tabularx}

\noindent X \dotfill X

\end{document}

-
Thanks, I added a working example to the question. Your code does not solve the problem completely, but spreads the table into page margin. –  Aydin Jan 23 '13 at 13:36
Code updated to work with supplied example –  David Carlisle Jan 23 '13 at 14:36
Thank you very much indeed. It solved the problem. –  Aydin Jan 25 '13 at 16:11