我在一个环境中有一张很长的桌子longtblr
。
我想在某个位置强制分页。我该怎么做?
MWE 随附于此。请
注意,我尝试过\pagebreak
、、,但这些都不起作用。\newpage
\\*
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[
caption = {ABC},
label = {tab:test},
]{
width = \textwidth,
colspec= {X[0.75,c] X[0.5,c] X[c] X[c] X[c] X[c] X[c]},
rowhead = 2,
}
\small
\hline
\multirow{2}{*}{\textbf{ID}} & \multirow{2}{*}{} & \multicolumn{5}{c|}{\textbf{Concept ID}} \\ \cline{3-7}
& & {\textbf{1}} & {\textbf{2}} & {\textbf{3}} & {\textbf{4}} & {\textbf{5}} \\ \hline
% similar block of multirow
\multirow{5}{*}{IIIA} & $A$ & {B} & {C} & {D} & {E} & {F} \\ \cline{2-7}
& $G$ & {H} & {I} & {J} & {K} & {L} \\* \cline{2-7}
& $M$ & {N} & {O} & {P} & {Q} & {R} \\* \cline{2-7}
& $S$ & {T} & {U} & {V} & {W} & {X} \\* \cline{2-7}
& $Y$ & {Z} & {AA} & {AB} & {AC} & {AD} \\ \hline
%% I WANT TO ENFORCE PAGE BREAK HERE
\multirow{5}{*}{IIIB} & $AE$ & {AF} & {AG} & {AH} & {AI} & {AJ} \\* \cline{2-7}
& $AK$ & {AL} & {AM} & {AN} & {AO} & {AP} \\* \cline{2-7}
& $AQ$ & {AR} & {AS} & {AT} & {AU} & {AV} \\* \cline{2-7}
& $AW$ & {AX} & {AY} & {AZ} & {BA} & {BB} \\* \cline{2-7}
& $BC$ & {BD} & {BE} & {BF} & {BG} & {BH} \\* \hline
% similar block of multirow
\end{longtblr}
\end{document}
答案1
\pagebreak
对我有用。
不要使用\multirow
with tabularray
,而应使用\SetCell
Instead 。
您还可以利用包功能将前两行设置为粗体row{1-2} = {font=\bfseries}
,或将第二列设置为数学模式 column{2}={mode=math} (这样您不需要$...$
在该列的每个单元格中都使用)。
您也可以使用hline{2-Z}={solid}
来避免\cline
s 和\hline
s(感谢 Zarko 的建议)。
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[
caption = {ABC},
label = {tab:test},
]{
width = \textwidth,
colspec= {X[0.75,c] X[0.5,c] X[c] X[c] X[c] X[c] X[c]},
rowhead = 2,
hline{2-Z}={solid},
column{2}={mode=math},
columns={font=\small},
row{1-2} = {font=\bfseries}
}
\SetCell[r=2]{h} ID & \SetCell[r=2]{h} & Concept ID \\
& & 1 & 2 & 3 & 4 & 5 \\
% similar block of multirow
\SetCell[r=5]{h} IIIA & A & {B} & {C} & {D} & {E} & {F} \\
& G & {H} & {I} & {J} & {K} & {L} \\
& M & {N} & {O} & {P} & {Q} & {R} \\
& S & {T} & {U} & {V} & {W} & {X} \\
& Y & {Z} & {AA} & {AB} & {AC} & {AD} \\
%% I WANT TO ENFORCE PAGE BREAK HERE
\pagebreak
\SetCell[r=5]{h} IIIB & AE & {AF} & {AG} & {AH} & {AI} & {AJ}\\
& AK & {AL} & {AM} & {AN} & {AO} & {AP} \\
& AQ & {AR} & {AS} & {AT} & {AU} & {AV} \\
& AW & {AX} & {AY} & {AZ} & {BA} & {BB} \\
& BC & {BD} & {BE} & {BF} & {BG} & {BH} \\
% similar block of multirow
\end{longtblr}
\end{document}