刪除 tabularray 表格標題

刪除 tabularray 表格標題

問題

我想使用沒有標題的longtblrfrom (例如,「表 1:測試表」)。tabularray

最小工作範例

\documentclass{article}

\usepackage{caption}
\captionsetup{
    format=plain,
    labelsep=newline,
    justification=justified,
    singlelinecheck=false,
    labelfont=bf,
    textfont=it,
}

\usepackage{booktabs}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

% Format tabularray longtblr: Use captionsetup settings, no captions on succeeding pages
\DefTblrTemplate{firsthead}{default}{%
    \addtocounter{table}{-1}%
    \captionof{table}[\InsertTblrText{entry}]{\InsertTblrText{caption}}%
}
\DefTblrTemplate{middlehead, lasthead}{default}{}
\DefTblrTemplate{contfoot-text}{default}{}

% Format tabularray talltblr
\SetTblrStyle{note-tag}{font=\rmfamily}
\SetTblrTemplate{note}{plain}

\begin{document}

\begin{booktabs}[
    long,
    note{a} = {Test note.},
]{
    colspec = {XXXX},
}
    \toprule
    Test Column A\TblrNote{a} & Test Column B & Test Column C & Test Column D \\
    \midrule

    Test & Test & Test & Test \\
    \vdots & \vdots & \vdots & \vdots \\
    Test & Test & Test & Test \\

    \bottomrule
\end{booktabs}

\end{document}

範本default設定適用於文件中的其他表格,並且按預期工作。我只需要一張沒有標題的表格,但它們被強制放在longtblrs 和talltblrs 中。

在此輸入影像描述

嘗試過的解決方案

我知道這個 StackExchange 線程但是將下面的程式碼片段與外部規範一起添加theme = blank是行不通的。

\NewTblrTheme{blank}{
    \SetTblrStyle{firsthead, middlehead,lasthead}{}
}

答案1

您可能需要在自訂主題中重新定義預設範本才能獲得結果

\NewTblrTheme{blank}{
    \DefTblrTemplate{firsthead}{default}{}%
    \DefTblrTemplate{middlehead,lasthead}{default}{}%
    \DefTblrTemplate{contfoot-text}{default}{}%
}

不確定這是否是答案,但我們開始:

\documentclass{article}

\usepackage{caption}
\captionsetup{
    format=plain,
    labelsep=newline,
    justification=justified,
    singlelinecheck=false,
    labelfont=bf,
    textfont=it,
}

\usepackage{booktabs}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

% Format tabularray longtblr: Use captionsetup settings, no captions on succeeding pages
\DefTblrTemplate{firsthead}{default}{%
    \addtocounter{table}{-1}%
    \captionof{table}[\InsertTblrText{entry}]{\InsertTblrText{caption}}%
}
\DefTblrTemplate{middlehead, lasthead}{default}{}
\DefTblrTemplate{contfoot-text}{default}{}

% Format tabularray talltblr
\SetTblrStyle{note-tag}{font=\rmfamily}
\SetTblrTemplate{note}{plain}


\NewTblrTheme{blank}{
    \addtocounter{table}{-1}%
    \DefTblrTemplate{firsthead}{default}{}%
    \DefTblrTemplate{middlehead, lasthead}{default}{}%
    \DefTblrTemplate{contfoot-text}{default}{}%
}


\begin{document}

\begin{booktabs}[
    theme=blank,
    long,
    note{a} = {Test note.},
]{
    colspec = {XXXX},
}
    \toprule
    Test Column A\TblrNote{a} & Test Column B & Test Column C & Test Column D \\
    \midrule

    Test & Test & Test & Test \\
    \vdots & \vdots & \vdots & \vdots \\
    Test & Test & Test & Test \\

    \bottomrule
\end{booktabs}

\vspace{1cm}

\begin{booktabs}[
    long,
    note{a} = {Test note.},
]{
    colspec = {XXXX},
}
    \toprule
    Test Column A\TblrNote{a} & Test Column B & Test Column C & Test Column D \\
    \midrule

    Test & Test & Test & Test \\
    \vdots & \vdots & \vdots & \vdots \\
    Test & Test & Test & Test \\

    \bottomrule
\end{booktabs}
\end{document}

在此輸入影像描述

相關內容