1

Why do \caption and \label not work in the longtblr environment (see pictures)? I can´t find anything specific in the caption documentation regarding longtables.

\documentclass[
12pt,
a4paper,
parskip=half,
toc=bibliography,
numbers=noendperiod
]{scrbook}

\usepackage[
left=3cm,
right=2.5cm,
top=2.5cm,
bottom=2.0cm,
includehead,
includefoot
]{geometry}

\usepackage[UKenglish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{scrlayer-scrpage}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{lscape}

\usepackage{makecell}   

\usepackage[onehalfspacing]{setspace}

\usepackage[inline]{enumitem} 
\usepackage{float}
\usepackage{caption}
\usepackage{booktabs} 
\usepackage{tabularx, ragged2e} 
\usepackage{siunitx} 
\usepackage{longtable} 
\usepackage[longtable]{multirow}
\usepackage{multicol}
\addtokomafont{caption}{\scriptsize}
\usepackage[font={normal}]{caption}
\captionsetup[table]{labelsep=space, justification=raggedright, singlelinecheck=off}
\usepackage[flushleft]{threeparttable}

\setkomafont{captionlabel}{\bfseries\rmfamily}


\renewcommand*\dictumwidth{0.72\linewidth}
\usepackage[skip=10pt]{parskip}

\usepackage{array}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{P}[1]{>{\endgraf\vspace*{-\baselineskip}}p{#1}}

\newcommand{\abbrlabel}[1]{\makebox[4cm][l]{\textbf{#1}\ \tocfill}}
\newcommand{\rr}{\raggedright}
\newcommand{\tn}{\tabularnewline}
\raggedbottom
\singlespacing\label{key}

\begin{document}
    
    
    \begin{landscape}
        \footnotesize
        \setlist[itemize]{nosep,leftmargin=*}
        \SetTblrStyle{contfoot}{font=\footnotesize\itshape}
        {\def\arraystretch{2}\tabcolsep=10pt
            \begin{longtblr}
                [
                \setlength\extrarowheight{-3pt}
                caption = {Characteristics of pressure driven membrane processes},
                entry = {Characteristics of pressure driven membrane processes},
                label = {tab:pressuredriven},
                ]{colspec = {@{} X[1,l] *{4}{X[l]} @{}},
                    stretch = -1, %<--- remove extra space above and below lists
                    % with nosep option; doc p.51 tabularray
                    rowsep = 5pt,
                    rowhead  = 1,
                    measure = vbox,
                }
                \toprule
                &   A
                &   B 
                &   C
                &   D        \\
                \midrule    
                E&F&G&&I\\
                E&F&G&H&I\\
                E&F&G&H&I\\
                \bottomrule
            \end{longtblr}
        }
    \end{landscape}
\end{document}

enter image description here

5
  • 1
    make a shorter example. There is certainly no need for all the lines or the landscape or all these packages etc. Shorter examples are much easier to debug. Commented Oct 9, 2023 at 11:13
  • 1
    Erh, why is the caption set twice? Once with the longtblr options and once with \caption, remove the latter.
    – daleif
    Commented Oct 9, 2023 at 12:41
  • sorry, now it´s the correct code. I also added a picture where you can see that the caption does not show. Commented Oct 9, 2023 at 13:09
  • 1
    You've got a stray \setlength\extrarowheight{-3pt} which is interpreted a part of a key, thus swallowing the key caption. Apparently the package ignores silently undefined keys. Strange choice.
    – campa
    Commented Oct 9, 2023 at 13:13
  • thanks. deleting the 'stray' solved the problem Commented Oct 9, 2023 at 13:17

1 Answer 1

1

The package tabularray apparently silently ignores undefined keys, leading to meaningless output without warning. For example

\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[caption=foo,some nonsense]{colspec={ll}}
a & b
\end{longtblr}
\end{document}

runs without issue but produces

A very questionable design choice in my opinion.

In your case, in the optional parameter to longtblr you have

\begin{longtblr}
                [
                \setlength\extrarowheight{-3pt}
                caption = {Characteristics of pressure driven membrane processes},
                % ...
                ]{...}

and the stray \setlength\extrarowheight{-3pt} is interpreted as part of the "key" \setlength\extrarowheight{-3pt} caption, which then does nothing (apparently) but to swallow the caption.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .