In a previous question (Caption in longtblr doesn't follow options given to format captions) I had a minor question regarding the formatting / output of the last cell in the tabularray table. The even columns in that table are defined as siunitx number columns, but can also contain text. This doesn't seem to be a problem, except for the last cell in the last row of the table.
The table is part of a chemistry exam question about calculating the E-factor and atom economy of the synthesis according to Traub. So the students have to determine the answer to the letters A through D before they can calculate those factors. To emphasize these determinations the letters are printed in boldface and an example of the answer is given in between B and C. In the preamble of the table that boldface printing is set using the cell{row}{column} formatting options.
However: when there is only the letter D in the last cell, siunitx compiles with a huge amount of errors, the first three being:
Package siunitx Error: Invalid number 'D'. \end
Argument of \__siunitx_table_print_format_auxi:w has an extra }. \end
Paragraph ended before \__siunitx_table_print_format_auxi:w was complete. \end
When the entry is presented as \textbf{D} the table is compiled correctly. Inserting the answer (a number) also compiles correctly
So the question remains why the letter B in the second cell of that last row does not result in syntax errors, but the letter D in the last cell does.
It may have to do with the new collecting / presenting definitions in siunitx version 3 as Ulrike Fischer pointed out in her comment to my earlier question about the caption: https://github.com/josephwright/siunitx/issues/335 .
The MWE taken form the answer by Zarko:
\documentclass[a4paper,12pt]{article}
\usepackage[text={17.0cm,26cm},top=2.0cm,left=2.5cm]{geometry}
\usepackage[dutch]{babel}
\usepackage[many]{tcolorbox} %needs to be loaded prior to gfsartemsia 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, bottom=3pt,}
%----- font paketten -----
\usepackage{gfsartemisia}
\usepackage[charter]{mathdesign}
\usepackage[scale=0.95]{tgheros}
\renewcommand*{\familydefault}{\sfdefault}
\usepackage[modules={minimal}]{chemmacros}
\chemsetup{greek=mathdesign,formula=chemformula}
\chemsetup[chemformula]{format=\sffamily}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs,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
}
\usepackage[labelfont=bf,labelsep=endash,font=small]{caption}
\begin{document}
\begin{tcolorbox}
\NewTblrTheme{captionof}% for use caption set up in talltablr captions
{
\DefTblrTemplate{caption}{default}%
{\addtocounter{table}{-1}%
\captionof{table}{\InsertTblrText{caption}}}
}
\SetTblrStyle{remark}{font=\footnotesize}
\centering
\begin{talltblr}[
theme = captionof,
caption = {Analyse van de synthese van \textit{cafeïne} volgens Traube uit 1900.}, % now uses the formatting options given for caption package
remark{1} = {MW staat voor molecuulmassa in \unit{\g\per\mole}},
remark{2} = {Afvalstoffen zijn in \textcolor{red}{rood} weergegeven},
]{
stretch=1.2,
colsep = 10pt,
colspec = {*{3}{l Q[c, si={table-format=2.3}]}},
% row{1-2}= {guard},
cell{Z}{1,2,5,6}={font=\bfseries,c},
cell{3-9}{5}={fg=red},
row{1,Y}= {bg=yellow!30, font=\bfseries},
row{2} = {bg=yellow!10, font=\itshape},
hlines = {blue, 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 & D \ %<- inserting \textbf{D} compiles correctly
\end{talltblr}
\end{tcolorbox}
\end{document}
The output PDF can be seen in Caption in longtblr doesn't follow options given to format captions
\textbf{D}essenatially declared the D as text and not as part of a number. – alchemist Jan 01 '23 at 12:29