# Is there an incompatibility between the packages calc and siunitx? (\GenericError […])

The following code does not compile:

\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}


However, it does compile, when the line

\usepackage{siunitx}


is omitted. Interchanging the loading order of the packages does not help.

Error message:

! 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.

• It is no siunitx but array (loaded by siunitx). It changes the way tabular preambles are handled. – Ulrike Fischer Nov 10 '18 at 9:10
• The main problem is the fragile \textbf. You can robustify it \usepackage{etoolbox}\robustify\textbf. – Ulrike Fischer Nov 10 '18 at 9:34

array package should probably have made this safe, one way to patch it is

    \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}

• I have now added a fix to the array package (somewhat more general than the above). The next release of LaTeX's tools (planned for December 2018) will contain this. – Frank Mittelbach Nov 13 '18 at 23:18
• @FrankMittelbach Unfortunately, it seems to break xcolor: \documentclass{article} \RequirePackage[table]{xcolor} \RequirePackage{array} \begin{document} \begin{tabular}{>{\centering}p{4cm}|p{4cm}} Test \end{tabular} \end{document} – cjorssen Dec 13 '18 at 20:35
• @cjorssen that's the table option so colortbl (which did get broken) a new version of colortbl went to ctan yesterday so should be in distributions probably tomorrow – David Carlisle Dec 13 '18 at 21:17
• @DavidCarlisle This morning: update: colortbl [593k] (47614 -> 49404) ... done`. Thank you so much for being so quick to fix things. – cjorssen Dec 14 '18 at 8:03