如何修复 tabularx 中的 \pex 标签数字?

如何修复 tabularx 中的 \pex 标签数字?

expex在表格内放置标签的\tl命令似乎与不兼容tabularx,因为每次放置标签时,标签编号都会从更高的数字开始\tl

有没有简单的方法来修补这个问题?

在此处输入图片描述

\documentclass{scrartcl}
\usepackage{expex,tabularx}
\labels

\begin{document}
    Regular \verb|tabular|s have proper label numbering, starting at a. in each \verb|\pex|
    
    \pex
        \begin{tabular}[t]{cc}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabular}
    \xe
    \pex~
        \begin{tabular}[t]{cc}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabular}
    \xe
    
    But \verb|tabularx|s start at a different number depending on how many \verb|\tl|s are set
    
    \pex
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabularx}
    \xe
    \pex~
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
                & text \\
                & text
        \end{tabularx}
    \xe
    \pex~
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
            \tl & text \\
                & text
        \end{tabularx}
    \xe
    
    And at even higher numbers if you use \verb|\ex| instead
    
    \ex
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabularx}
    \xe
\end{document}

编辑:

我只是想到了一个快速解决方案,即\pexcnt在每次第一个标签之前重置。
但如果可能的话,我仍在寻找更全面的解决方案。

\newcommand{\tlx}{\pexcnt=97\tl}

...

\pex
    \begin{tabularx}{.5\linewidth}[t]{cX}
        \tlx & text \\
        \tl  & text \\
        \tl  & text
    \end{tabularx}
\xe

答案1

tabularx保留用声明的 latex 计数器\setcounter,但不保留用普通 tex 样式分配\newcount,您可以使 latex 名称遮蔽现有分配

在此处输入图片描述

\documentclass{scrartcl}
\usepackage{expex,tabularx}
\labels
\makeatletter
\let\c@excnt\excnt
\let\c@pexcnt\pexcnt
\@addtoreset{excnt}{@ckpt}
\@addtoreset{pexcnt}{@ckpt}
\makeatother

\begin{document}
    Regular \verb|tabular|s have proper label numbering, starting at a. in each \verb|\pex|
    
    \pex
        \begin{tabular}[t]{cc}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabular}
    \xe
    \pex~
        \begin{tabular}[t]{cc}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabular}
    \xe
    
    But \verb|tabularx|s start at a different number depending on how many \verb|\tl|s are set
    
    \pex
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabularx}
    \xe
    \pex~
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
                & text \\
                & text
        \end{tabularx}
    \xe
    \pex~
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
            \tl & text \\
                & text
        \end{tabularx}
    \xe
    
    And at even higher numbers if you use \verb|\ex| instead
    
    \ex
        \begin{tabularx}{.5\linewidth}[t]{cX}
            \tl & text \\
            \tl & text \\
            \tl & text
        \end{tabularx}
    \xe
\end{document}

我假设最终的 c、d、e 标签是正确的(我得到的结果相同tabular),但我不知道这个包。

相关内容