Prior to the updates published in July 2022 I used the ctable package to define annotated tables. But after that date those tables containing siunitx columns and entries give rise to a plethora of errors, mainly referencing to siunitx. Browsing the internet provided me with a possible solution to the issue in the form of the longtblr environment provided by the tabularray package. So I started converting one of the problematic tables.
That conversion went well except for two errors I can't resolve. The first (major) one is the formatting of the caption of the table. I have configured that using the options of the captions package. These options aren't parsed onto the table caption created by longtblr. That caption should look the same as the one in the ctable example. So why not? And more importantly: how to solve / work around that?
The second (minor) question is about something odd at the last entry of the table. Somehow the \textbf{D} needs to stay in that cell, even though the cell is already defined as boldface in the preamble of longtblr. Removing that code results in a siunitx error and not printing of that entry.
In the given MWE both tables environments are presented. The third option using tabularx is commented out as that doesn't even compile. The tables are placed in a tcolorbox environment. The package tcolorbox needs to be loaded first to prevent all kind of ams related errors (ams is massively used by chemmacros).
If someone can point out to me why the table uisng ctable causes so many errors I would be grateful. Since I am going to migrate all tables to tabularray that answer is just a bonus to the one posed in this question.
\documentclass[a4paper,12pt]{article}
\usepackage[many]{tcolorbox} %needs to be loaded first to prevent ams / math font conflicts
\tcbset{colback=gray!2.5, width=\linewidth, frame hidden, boxrule=0pt, toprule=1pt, bottomrule=1pt, sharp corners, boxsep=3pt, top=12pt, bottom=3pt,}
%----- taal/font pakketten -----
\usepackage[dutch]{babel}
%----- font paketten -----
\usepackage{gfsartemisia}
\usepackage[charter]{mathdesign}
\usepackage[scale=0.95]{tgheros}
%----- chemische pakketten -----
\usepackage[modules={minimal}]{chemmacros}
\chemsetup{greek=mathdesign,formula=chemformula}
\chemsetup[chemformula]{format=\sffamily}
%----- grafische pakketten -----
%\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{graphicx}
\usepackage{tikz}
%\usepackage[many]{tcolorbox}
%----- opmaak pakketten -----
\usepackage[labelfont=bf,labelsep=endash,font=small]{caption}
\usepackage{ctable}
\usepackage{booktabs}
%\usepackage{multirow}
%\usepackage{bigdelim,bigstrut}
\usepackage{dashrule}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,siunitx}
%----- layout pakketten -----
\usepackage[text={17.0cm,26cm},top=2.0cm,left=2.5cm]{geometry}
%\usepackage{xstring}
%----- wiskunde paketten -----
\usepackage{siunitx}
\sisetup{
table-alignment-mode=format,
table-number-alignment=center,
output-decimal-marker={,},
reset-text-family=false, % doesn't work - math roman font is still selected
detect-all % now undocumented, but needed to maintain the tgheros font in siuntitx macros
}
%----- aanvullende pakketten ----
%\usepackage{xpatch}
\usepackage{float}
%----- font en versie selectie -----
\renewcommand*{\familydefault}{\sfdefault}
\setlength{\parindent}{0mm}
\renewcommand{\baselinestretch}{1.2}
\setlength{\marginparwidth}{40pt}
\tcbset{colback=gray!2.5, width=\linewidth, frame hidden, boxrule=0pt, toprule=1pt, bottomrule=1pt, sharp corners, boxsep=3pt, bottom=3pt,}
\begin{document}
Using the \textit{ctable}-package to create an annotated table (used to compile correctly prior to the July 2022 updates):
\begin{tcolorbox}[top=-12pt]
\ctable[pos=H,caption={Analyse van de synthese van \textit{cafeïne} volgens Traube uit 1900}]
{| p{2.4cm} S[table-format=3.3] | p{2.4cm} S[table-format=3.3] | p{2.4cm} S[table-format=3.3] |}
{\tnote[1]{MW staat voor molecuulmassa in \si{\g\per\mole}}
\tnote[2]{Afvalstoffen zijn in \textcolor{red}{rood} weergegeven.}}{
\FL
\rowcolor{yellow!30} \multicolumn{2}{| c}{\textbf{Reagent}} & \multicolumn{2}{| c}{\textbf{Gebruikt in cafeïne}} & \multicolumn{2}{| c |}{\textbf{Niet gebruikt}} \
\rowcolor{yellow!10} \textit{Formule} & \textit{MW} & \textit{Formule} & MW & \textit{Formule} & \textit{MW} \ML
\ch{C3H8N2O} & 88.114 & \ch{C3H6N2O} & 86.098 & & \ML
\ch{C3H3NO2} & 85.064 & \ch{C3HNO} & 67.048 & \textcolor{red}{\ch{H2O}} & 18.016 \ML
\ch{HNO2} & 47.018 & \ch{N} & 14.01 & \textcolor{red}{\ch{H2O}} & 18.016 \ML
2 \ch{H2} & 4.032 & & & \textcolor{red}{\ch{H2O}} & 18.016 \ML
\ch{HCOOH} & 46.026 & \ch{C} & 12.01 & \textcolor{red}{\ch{H2O}} & 18.016 \ML
\ch{NaOH} & 39.998 & & & \textcolor{red}{2 \ch{H2O}} & 36.032 \ML
\ch{CH3Cl} & 50.484 & \ch{CH3} & 15.034 & \textcolor{red}{\ch{NaCl}} & 58,44 \ML
\rowcolor{yellow!30} \multicolumn{2}{| c}{\textbf{Totaal}} & \multicolumn{2}{| c}{\textbf{Cafeïne}} & \multicolumn{2}{| c |}{\textbf{Restant}} \ML
\textbf{A} & \textbf{B} & \ch{C8H10N4O2} & 194.20 & \textbf{C} & \textbf{D}
\LL
}
\end{tcolorbox}
% \begin{tabularx}
% {| p{3.0cm} S[table-format=3.3] | p{3.0cm} S[table-format=3.3] | p{3.0cm} S[table-format=3.3] |}
% \toprule
% \rowcolor{yellow!30} \multicolumn{2}{| c}{\textbf{Reagent}} & \multicolumn{2}{| c}{\textbf{Gebruikt in cafeïne}} & \multicolumn{2}{| c |}{\textbf{Niet gebruikt}} \
% \rowcolor{yellow!10} \textit{Formule} & \textit{MW} & \textit{Formule} & \textit{MW} & \textit{Formule} & \textit{MW} \tabularnewline \midrule
% \ch{C3H8N2O} & 88.114 & \ch{C3H6N2O} & 86.098 & & \tabularnewline \midrule
% \ch{C3H3NO2} & 85.064 & \ch{C3HNO} & 67.048 & \textcolor{red}{\ch{H2O}} & 18.016 \tabularnewline \midrule
% \ch{HNO2} & 47.018 & \ch{N} & 14.01 & \textcolor{red}{\ch{H2O}} & 18.016 \tabularnewline \midrule
% 2 \ch{H2} & 4.032 & & & \textcolor{red}{\ch{H2O}} & 18.016 \tabularnewline \midrule
% \ch{HCOOH} & 46.026 & \ch{C} & 12.01 & \textcolor{red}{\ch{H2O}} & 18.016 \tabularnewline \midrule
% \ch{NaOH} & 39.998 & & & \textcolor{red}{2 \ch{H2O}} & 36.032 \tabularnewline \midrule
% \ch{CH3Cl} & 50.484 & \ch{CH3} & 15.034 & \textcolor{red}{\ch{NaCl}} & 58,44 \tabularnewline \midrule
% \rowcolor{yellow!30} \multicolumn{2}{| c}{\textbf{Totaal}} & \multicolumn{2}{| c}{\textbf{Cafeïne}} & \multicolumn{2}{| c |}{\textbf{Restant}} \tabularnewline \midrule
% \textbf{A} & \textbf{B} & \ch{C8H10N4O2} & 194.20 & \textbf{C} & \textbf{D}
% \bottomrule
% \end{tabularx}
%\clearpage
Same table as above using the \textit{tabularray}-package.
\begin{tcolorbox}[top=-12pt]
\begin{longtblr}
[ caption={Analyse van de synthese van \textit{cafeïne} volgens Traube uit 1900}, %<- doesn't use the formating options given for captions
remark{1}={\small MW staat voor molecuulmassa in \unit{\g\per\mole}},
remark{2}={\small Afvalstoffen zijn in \textcolor{red}{rood} weergegeven},
]{
colsep=10pt,
colspec={p{2.4cm}
Q[si={table-format=3.3,},c]
p{2.4cm}
Q[si={table-format=3.3,},c]
p{2.4cm}
Q[si={table-format=3.3,},c]
},
cell{1-11}{2,4,6}={wd=1.5cm},
row{1,10}={bg=yellow!30,font=\bfseries},
row{2}={bg=yellow!10, font=\itshape},
cell{11}{1,2,5,6}={font=\bfseries,c},
cell{3-9}{5}={fg=red},
hline{1-12}={blue5, solid, 1pt},
vline{1,3,5,7}={blue5, solid, 1pt},
}
\SetCell[c=2]{c} Reagent & & \SetCell[c=2]{c} Gebruikt in cafeïne & & \SetCell[c=2]{c} Niet gebruikt & \
Formule & MW & Formule & MW & Formule & MW \
\ch{C3H8N2O} & 88.114 & \ch{C3H6N2O} & 86.098 & & \
\ch{C3H3NO2} & 85.064 & \ch{C3HNO} & 67.048 & \ch{H2O} & 18.016 \
\ch{HNO2} & 47.018 & \ch{N} & 14.01 & \ch{H2O} & 18.016 \
2 \ch{H2} & 4.032 & & & \ch{H2O} & 18.016 \
\ch{HCOOH} & 46.026 & \ch{C} & 12.01 & \ch{H2O} & 18.016 \
\ch{NaOH} & 39.998 & & & 2 \ch{H2O} & 36.032 \
\ch{CH3Cl} & 50.484 & \ch{CH3} & 15.034 & \ch{NaCl} & 58,44 \
\SetCell[c=2]{c}{Totaal} & & \SetCell[c=2]{c}{Cafeïne} & & \SetCell[c=2]{c}{Restant} & \
A & B & \ch{C8H10N4O2} & 194.20 & C & \textbf{D} % <- removing \textbf results in an error / not printing the last line
\end{longtblr}
\end{tcolorbox}
\end{document}

