3

I have a thin longtable, but would like to have a caption with full text width. The longtable does not work in the table environment. I tried an extra line with \SetCell[c=5]{c}\hspace{0.9\textwidth}\\ but that moves everything weirdly and all lines become also the full width, makes sense but is not want I want.

Ideas anyone?

\documentclass[11pt,a4paper]{scrreprt}
%\usepackage[T1]{fontenc}
%\usepackage[ngerman]{babel}
%\usepackage{scrhack}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}

\begin{longtblr}[ caption = {Variation der Steuerungs-Simulationsversuche. Test 1-9 mit der neuer Steuerung, Test 1-14 mit Steuerung~1 und Test 15-19 mit Steuerung~2 durchgeführt. (n_{fc}) = Anzahl {FC} im {FC}-System, WD = Wintertag, SD = Sommertag}, entry = {Steuerungs-Simulationsversuche}, label = {tab:sim:steuerung_versuche}, ]{ colspec =ccccc,
rowhead = 1,
} \toprule Num. & (n_{fc}) & Lasttag & Heizung & {PV}\ \midrule 1 & 100 & WD& ein& aus\* 2 & 99 & WD& ein& aus \* 3 & 101 & WD& ein& aus \ 4 & 200 & WD& ein& aus\ 5 & 199 & WD& ein& aus\ 6 & 201 & WD& ein& aus\ 7 & 100 & SD& aus& Juli\ 8 & 200 & SD& aus& Juli\* 9 & 300 & WD& aus& aus\ \midrule 10& 100 & WD& ein& aus\* 11& 200 & WD& ein& aus\* 12& 300 & WD& ein& aus\ 13& 100 & SD& aus& Juli\* 14& 200 & SD& aus& Juli\ \midrule 15& 100 & WD& ein& aus\* 16& 200 & WD& ein& aus\* 17& 300 & WD& ein& aus\ 18& 100 & SD& aus& Juli\* 19& 200 & SD& aus& Juli\* \bottomrule

\end{longtblr}

\end{document}

Bernard
  • 271,350
Tobias H.
  • 105

2 Answers2

5

You can do this also within tabularray with a theme.

\documentclass[11pt,a4paper]{scrreprt}
%\usepackage[T1]{fontenc}
%\usepackage[ngerman]{babel}
%\usepackage{scrhack}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\DefTblrTemplate{caption}{wide}{% \makebox[\hsize][c]{% \parbox{\textwidth}{% \UseTblrTemplate {caption-tag}{default}% \UseTblrTemplate {caption-sep}{default}% \UseTblrTemplate {caption-text}{default}% } } } \NewTblrTheme{widecaption}{% \SetTblrTemplate{caption}{wide}% } \begin{document}

\begin{longtblr}[ theme = widecaption, caption = {Variation der Steuerungs-Simulationsversuche. Test 1-9 mit der neuer Steuerung, Test 1-14 mit Steuerung~1 und Test 15-19 mit Steuerung~2 durchgeführt. (n_{fc}) = Anzahl {FC} im {FC}-System, WD = Wintertag, SD = Sommertag}, entry = {Steuerungs-Simulationsversuche}, label = {tab:sim:steuerung_versuche}, ]{ colspec =ccccc,
rowhead = 1,
} \toprule Num. & (n_{fc}) & Lasttag & Heizung & {PV}\ \midrule 1 & 100 & WD& ein& aus\* 2 & 99 & WD& ein& aus \* 3 & 101 & WD& ein& aus \ 4 & 200 & WD& ein& aus\ 5 & 199 & WD& ein& aus\ 6 & 201 & WD& ein& aus\ 7 & 100 & SD& aus& Juli\ 8 & 200 & SD& aus& Juli\* 9 & 300 & WD& aus& aus\ \midrule 10& 100 & WD& ein& aus\* 11& 200 & WD& ein& aus\* 12& 300 & WD& ein& aus\ 13& 100 & SD& aus& Juli\* 14& 200 & SD& aus& Juli\ \midrule 15& 100 & WD& ein& aus\* 16& 200 & WD& ein& aus\* 17& 300 & WD& ein& aus\ 18& 100 & SD& aus& Juli\* 19& 200 & SD& aus& Juli\* \bottomrule

\end{longtblr}

\end{document}

enter image description here

3

One option would be to use caption package and the \captionof command. See also this post. You can specify a width for all captions. This also has the advantage, that your longtblr tables will have the format as regular tables.

\documentclass[11pt,a4paper]{scrreprt}
%\usepackage[T1]{fontenc}
%\usepackage[ngerman]{babel}
%\usepackage{scrhack}
\usepackage{caption}
\captionsetup{format=plain,labelfont=bf,font=small, width=\linewidth}

\usepackage{tabularray} \UseTblrLibrary{booktabs}

% modifying the captions of tabularray \DefTblrTemplate{firsthead}{default}{\addtocounter{table}{-1}\captionof{table}[\InsertTblrText{entry}]{\InsertTblrText{caption}}} \DefTblrTemplate{middlehead,lasthead}{default}{\addtocounter{table}{-1}\captionof{table}[]{\InsertTblrText{caption}~(Continued)}} \SetTblrTemplate{caption-lot}{empty}

\begin{document}

\listoftables

\begin{longtblr}[
    caption = {Variation der Steuerungs-Simulationsversuche. Test 1-9 mit der neuer Steuerung, Test 1-14 mit Steuerung~1 und Test 15-19 mit Steuerung~2 durchgeführt. \(n_{fc}\) = Anzahl {FC} im {FC}-System, WD = Wintertag, SD = Sommertag},
    entry = {Steuerungs-Simulationsversuche},
    label = {tab:sim:steuerung_versuche},
    ]{
        colspec =ccccc,
        rowhead = 1,     
    }
    \toprule
    Num. &  \(n_{fc}\) & Lasttag & Heizung & {PV}\\
    \midrule
    1 & 100 & WD& ein& aus\\*
    2 & 99  & WD& ein& aus \\*
    3 & 101 & WD& ein& aus \\
    4 & 200 & WD& ein& aus\\
    5 & 199 & WD& ein& aus\\
    6 & 201 & WD& ein& aus\\
    7 & 100 & SD& aus& Juli\\
    8 & 200 & SD& aus& Juli\\*
    9 & 300 & WD& aus& aus\\
    \midrule
    10& 100 & WD& ein& aus\\*
    11& 200 & WD& ein& aus\\*
    12& 300 & WD& ein& aus\\
    13& 100 & SD& aus& Juli\\*
    14& 200 & SD& aus& Juli\\
    \midrule
    15& 100 & WD& ein& aus\\*
    16& 200 & WD& ein& aus\\*
    17& 300 & WD& ein& aus\\
    18& 100 & SD& aus& Juli\\*
    19& 200 & SD& aus& Juli\\*
    \bottomrule 
\end{longtblr}

\end{document}

longtblr full width caption

If you want to specify the width locally, remove the width=\linewidht from the loading option and use

\captionsetup{width=\linewidth}

in a local group enclosing the longtblr environment.

I would also move the explanation of the variables meaning inside a remark, which would also make you caption a bit shorter.

marv
  • 2,099
  • 1
  • 7
  • 26