rolfn/xltabular

Error when using both S column-type (siunitx) in the first column with caption

Closed this issue · 4 comments

In the following code, siunitx causes error when xltabular has its first column defined as S AND the table contains a caption

\documentclass{article}
\usepackage{xltabular}
\usepackage{siunitx}
    \sisetup{table-format=3}
\begin{document}
\begin{xltabular}{\textwidth}{S lcccc}
    \caption{Longtable --- caption} \\
      1 & Row 10 & cell & cell & cell & cell \\
     11 & Row 20 & cell & cell & cell & cell \\
    111 & Row 20 & cell & cell & cell & cell
\end{xltabular}
\end{document}

There's no error when caption is not provided!

At the time of writing this, I have following TeXLive installed: "This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex 2022.7.6) 11 JUL 2022 10:43".

The the log:

...
./main.tex:20: Use of \@@array doesn't match its definition.
<argument> ...\def \reserved@a {\def \reserved@a *
                                                  {\TX@cap@gobble }\reserved...
l.20 \end{xltabular}
                    
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

./main.tex:20: Use of \@@array doesn't match its definition.
<argument> ...ed@a *{\TX@cap@gobble }\reserved@a }
                                                  \def \reserved@b {\TX@cap@...
l.20 \end{xltabular}
                    
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

./main.tex:20: Illegal parameter number in definition of \l__siunitx_table_collect_tl.
<to be read again> 
                   \unskip 
l.20 \end{xltabular}
                    
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

./main.tex:20: Illegal parameter number in definition of \l__siunitx_table_collect_tl.
<to be read again> 
                   \unskip 
l.20 \end{xltabular}
                    
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

./main.tex:20: Illegal parameter number in definition of \l__siunitx_table_collect_tl.
<to be read again> 
                   \unskip 
l.20 \end{xltabular}
                    
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

./main.tex:20: Illegal parameter number in definition of \l__siunitx_table_collect_tl.
<to be read again> 
                   \unskip 
l.20 \end{xltabular}
                    
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

./main.tex:20: Illegal parameter number in definition of \l__siunitx_table_collect_tl.
<to be read again> 
                   \unskip 
l.20 \end{xltabular}
                    
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

./main.tex:20: Illegal parameter number in definition of \l__siunitx_table_collect_tl.
<to be read again> 
                   \unskip 
l.20 \end{xltabular}
                    
You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

./main.tex:20: Incomplete \iffalse; all text was ignored after line 20.
<inserted text> 
                \fi 
l.20 \end{xltabular}
                    
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

./main.tex:20: Incomplete \iffalse; all text was ignored after line 20.
<inserted text> 
                \fi 
l.20 \end{xltabular}
                    
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

Runaway definition?
->\let \reserved@d =*\def \def {\protect \TX@cap@gobble }\def \@tempdima \ETC.
./main.tex:20: Forbidden control sequence found while scanning definition of \l__siunitx_table_collect_tl.
<inserted text> 
                }
l.20 \end{xltabular}
                    
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

./main.tex:20: Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.20 \end{xltabular}

Use it this way:

\documentclass{article}
\usepackage{xltabular}
\usepackage{siunitx}
\sisetup{table-format=3}
\usepackage{caption}

\begin{document}

\captionof{table}{Longtable --- caption} 
\begin{xltabular}{\textwidth}{S lcccc}
      1 & Row 10 & cell & cell & cell & cell \\
     11 & Row 20 & cell & cell & cell & cell \\
    111 & Row 20 & cell & cell & cell & cell 
\end{xltabular}

\end{document}

@hvoss49 Thanks, it's working. It just adds quite long vertical space in between.

Is that how it should work? Shall I close the issue?

Use a negative skip here:

{\belowcaptionskip=-0.5\normalbaselineskip
\captionof{table}{Longtable --- caption} 
\begin{xltabular}{\textwidth}{S lcccc}
      1 & Row 10 & cell & cell & cell & cell \\
     11 & Row 20 & cell & cell & cell & cell \\
    111 & Row 20 & cell & cell & cell & cell 
\end{xltabular}}

and yes, issue can be closed

Thanks