软件包 calc 和 siunitx 之间是否存在不兼容问题?(\GenericError [...])

软件包 calc 和 siunitx 之间是否存在不兼容问题?(\GenericError [...])

以下代码无法编译:

\documentclass[11pt]{article}
\usepackage{calc}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{p{.5cm}p{\widthof{\textbf{AAAAAAAAA}}}l}
&\textbf{AAAAAAAAA}&XXXXXXXXXXXXXXXXXXXXXX\\
&\textbf{BBBBB}&YYYYYYYYYYYYYYYYYYYYYYY\\
\end{tabular}
\end{document}

但是,它确实可以编译,当以下行

\usepackage{siunitx}

被省略。交换软件包的加载顺序没有帮助。

错误信息:

! Undefined control sequence.
\GenericError ...
#4 \errhelp \@err@ ...
l.5 ...r}{p{.5cm}p{\widthof{\textbf{AAAAAAAAA}}}l}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

答案1

array软件包应该可以让这个变得安全,修补它的一种方法是

    \documentclass[11pt]{article}
    \usepackage{calc}
    \usepackage{array}
    \usepackage{etoolbox}
\makeatletter
    \patchcmd \@mkpream
       {\let\@sharp\relax}
       {\def\widthof##1{\unexpanded{\widthof{##1}}}\let\@sharp\relax}
       {}{}
\makeatother
    \begin{document}
    \begin{tabular}{p{.5cm}p{\widthof{\textbf{AAAAAAAAA}}}l}
    &\textbf{AAAAAAAAA}&XXXXXXXXXXXXXXXXXXXXXX\\
    &\textbf{BBBBB}&YYYYYYYYYYYYYYYYYYYYYYY\\
    \end{tabular}
    \end{document}

相关内容