我使用 tabularray 制作了一个横向的长表格。我对表格本身很满意,我的问题是:如何删除第二页(续)表格标题内的悬挂缩进?
下表为:
代码如下:
\documentclass{article}
%% PACKAGES
\usepackage{caption} % Captions
\usepackage{array} % Tables
\usepackage{booktabs} % Tables
\usepackage{multirow} % Tables
\usepackage{geometry} % page geometry - for landscape
\usepackage{pdflscape} % landscape page
\usepackage{tabularray} % long table
\usepackage{lipsum} % filler words
% set long table specifications
\NewTblrTheme{thesis}{
\SetTblrStyle{caption}{hang=0pt,format=plain,font=\bfseries}
\SetTblrStyle{head}{hang=0pt,format=plain,font=\bfseries}
\SetTblrStyle{conthead}{hang=0pt,format=plain,font=\bfseries}
}
% caption setup
\captionsetup{format=plain, justification=justified, font=small, labelfont=bf, textfont=bf}
% create \tab command
\newcommand\tab{\hspace{10mm}}
\begin{document}
% text from document
\newgeometry{margin=1in}
\begin{landscape}
\singlespacing
\begin{longtblr}[
theme=thesis,
caption={Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines.},
label={tbl:example}
]{%
rowhead=2,
colspec={X[1.4,c,m]X[2.55,l,h]X[2.3,l,h]X[2.7,l,h]}
}
& \multicolumn{3}{c}{These columns are explained here} \\
& \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\
\hline
Row 1
& \textb{Text here} \par
\tab Values values values \par
Text here \par
\tab values values vlues \par
\textbf{Text here} \par
\tab \textbf{values values values}\par
Text here \par
\tab values values values \par
\textbf{Text here} \par
\tab \textbf{values values values}
& \textbf{Text} \par
\tab \textbf{values values} \par
\textbf{Text} \par
\tab \textbf{Values values}
& \textbf{Text} \par
\tab \textbf{Values values } \par
\textbf{Text} \par
\tab \textbf{values values} \\
\hline
Row 2 & \lipsum[1-1][1-2] & \lipsum[1-1][1-5] & \lipsum[1-1][1-2] \\
\hline
Row 3 & \lipsum[1-1][1-5] & \lipsum[1-1][1-2] & \lipsum[1-1][1-2] \\
\hline
Row 4 & \lipsum[1-1][1-5] & \lipsum[1-1][1-2] & \lipsum[1-1][1-4] \\
\hline
Row 5 & \lipsum[1-1][1-2] & \lipsum[1-1][1-4] & \lipsum[1-1][1-2] \\
\hline
\end{longtblr}
\doublespacing
\end{landscape}
\restoregeometry
% text from document
\end{document}
PS 我按原样显示第 1 行,以便更好地说明为什么我需要使用 tabularray 包(多个不同的数字线、缩进和单元格对齐)。
答案1
重新定义capcont
模板。顺便说一句,我必须纠正一些错误才能让它正常工作
\documentclass{article}
%% PACKAGES
\usepackage{caption} % Captions
\usepackage{array} % Tables
\usepackage{booktabs} % Tables
\usepackage{multirow} % Tables
\usepackage{geometry} % page geometry - for landscape
\usepackage{pdflscape} % landscape page
\usepackage{tabularray} % long table
\usepackage{lipsum} % filler words
% set long table specifications
\NewTblrTheme{thesis}{
\SetTblrStyle{caption}{hang=0pt,format=plain,font=\bfseries}
\SetTblrStyle{head}{hang=0pt,format=plain,font=\bfseries}
\SetTblrStyle{conthead}{hang=0pt,format=plain,font=\bfseries}
}
% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
% Redefine continuation caption
% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\DefTblrTemplate{capcont}{default}{%
\par
\UseTblrTemplate {caption-tag}{default}%
\UseTblrTemplate {caption-sep}{default}%
\UseTblrTemplate {caption-text}{default}
\UseTblrTemplate {conthead-text}{default}
\par
}
% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
% caption setup
\captionsetup{format=plain, justification=justified, font=small, labelfont=bf, textfont=bf}
% create \tab command
\newcommand\tab{\hspace{10mm}}
\begin{document}
% text from document
\newgeometry{margin=1in}
\begin{landscape}
%\singlespacing
\begin{longtblr}[
theme=thesis,
caption={Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines. Long caption that spans multiple lines.},
label={tbl:example}
]{%
rowhead=2,
colspec={X[1.4,c,m]X[2.55,l,h]X[2.3,l,h]X[2.7,l,h]}
}
& \multicolumn{3}{c}{These columns are explained here} \\
& \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\
\hline
Row 1
& \textbf{Text here} \par
\tab Values values values \par
Text here \par
\tab values values vlues \par
\textbf{Text here} \par
\tab \textbf{values values values}\par
Text here \par
\tab values values values \par
\textbf{Text here} \par
\tab \textbf{values values values}
& \textbf{Text} \par
\tab \textbf{values values} \par
\textbf{Text} \par
\tab \textbf{Values values}
& \textbf{Text} \par
\tab \textbf{Values values } \par
\textbf{Text} \par
\tab \textbf{values values} \\
\hline
Row 2 & \lipsum[1-1][1-2] & \lipsum[1-1][1-5] & \lipsum[1-1][1-2] \\
\hline
Row 3 & \lipsum[1-1][1-5] & \lipsum[1-1][1-2] & \lipsum[1-1][1-2] \\
\hline
Row 4 & \lipsum[1-1][1-5] & \lipsum[1-1][1-2] & \lipsum[1-1][1-4] \\
\hline
Row 5 & \lipsum[1-1][1-2] & \lipsum[1-1][1-4] & \lipsum[1-1][1-2] \\
\hline
\end{longtblr}
%\doublespacing
\end{landscape}
\restoregeometry
% text from document
\end{document}