当我第一次在 tabularx 中使用缩写词(词汇表或缩写包)时,它无法展开,甚至会破坏表结构。问题已经提到这里,但没有提供直接的解决方案。
\acf
或\acs
其他不检查条目首次使用的命令不会出现此问题。但是,这不是解决方案,因为此包的整个想法是自动检查。我正在寻找一种简单的解决方案,不会有太多的处理开销,因为我\ac
的文本中有数千个命令。
示例代码:
\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}
答案1
\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}
答案2
根据 David 的回答,版本 4.28(2017-01-07)glossaries
现在有一个命令\glspatchtabularx
可以执行 David 的补丁,而不需要\makeatletter
:
\documentclass{article}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{tabularx}
\newacronym{BI}{BI}{Beacon Interval}
\glspatchtabularx
\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}
tabularx
如果尚未加载,它将不执行任何操作。
答案3
我知道这是旧的,并且已经在上游进行了,但我认为我有一个替代解决方案,可能不需要修补tabularx
。这个想法是tabularx
在排版表格之前进行多次试验,但当它们结束时,在最后一步之前,\@footnotetext
让\TX@ftntext
,并且此分配可用于识别试验已结束:
\documentclass{article}
\usepackage[acronym,shortcuts]{glossaries}
\usepackage{tabularx}
\newacronym{BI}{BI}{Beacon Interval}
\makeatletter
\renewcommand*{\glsunset}[1]{%
\ifx\@footnotetext\TX@ftntext
\gls@ifnotmeasuring
{%
\glsdoifexists{#1}%
{%
\@glsunset{#1}%
}%
}%
\fi
}
\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}
当然,这只是“概念证明”,但如果这种检查确实适合情况,那么\gls@ifnotmeasuring
基于它提供类似的东西也不会很困难。