下面的longtblr
表格代码和我的意见有些不同。例如,字体大小,我希望是 10pt,但输出只是将“10pt”放在表格上方,然后继续执行它想要的操作。
\documentclass[a4paper]{article}
\usepackage[top=2cm, bottom=3cm, left=3.5cm, right=3.5cm]{geometry}
\usepackage{tabularray}
\NewTblrTheme{mytable}{
%\SetTblrStyle{head}{bg=teal7}
\SetTblrStyle{contfoot-text}{normal}{font=\footnotesize\itshape}
\SetTblrStyle{caption-sep}{normal}{\enskip\(|\)\enskip}
}
\begin{document}
\begin{longtblr}[
theme = mytable,
caption = A very long table,
font=10pt,
]{
colspec = {X[l,2cm] m{7cm} Q[c] Q[c]},
width = \linewidth,
rowhead = 1,
row{1} = {teal7},
}
\hline[1.5pt]
column 1 & column 2 & column 3 & column 4 \\
\hline
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows centred in two \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & \SetCell[r=2]{c} rows \\
row & less showboating, maybe even no showboating & row & \\
\end{longtblr}
\end{document}
}
有什么想法吗?
编辑以减少示例中的错误。但是,我似乎误解了软件包文档。在我看来,颜色和字体命令似乎已随软件包加载,而第一位评论者告诉我要修复这些问题。此外,似乎并非如此\linewidth
。
答案1
考虑@Miyase 和@CarLaTeX 的评论:
\documentclass[a4paper,12pt]{article}
\usepackage[hmargin= 3.5cm,
vmargin={2cm, 3cm}]{geometry}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{kantlipsum}
\NewTblrTheme{mytable}{
\SetTblrStyle{firstfoot,middlefoot}{\footnotesize\itshape}
\DefTblrTemplate{caption-sep}{default}{\enskip\(|\)\enskip}
}
\begin{document}
\kant[1-3]
\begin{longtblr}[
theme = mytable,
caption = {A very long table},
label = {tab:long...}
]{colspec = {l X[j, m] c c},
cells = {font = \fontsize{10pt}{12pt}\selectfont},
row{1} = {teal9},
rowhead = 1,
}
\toprule
column 1 & column 2 & column 3 & column 4 \\
\midrule
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
row & some relatively long description so that the other entries can showboat their floatiness
& row & rows \\
\bottomrule
\end{longtblr}
\kant[4]
\end{document}
答案2
我稍微简化了代码,并彻底清除了错误。如果您要自定义longtblr
,则应阅读文档,主要是与相关的部分longtblr
。一开始可能不太容易理解,但一旦你了解了主题和自定义样式的工作原理,就很容易理解了。
我不明白字体大小的问题,因为字体大小10pt
是常规文档中的默认字体大小。但是,即使文档设置为(见示例),也可以为表格设置特定的字体大小12pt
。确保将表格放在\fontsize
组中,这样它只会影响表格。
这是你可以借鉴的有效代码。我添加了几段虚拟文本,以便将表格与常规内容进行比较。
\documentclass[a4paper,12pt]{article}
\usepackage[top=2cm, bottom=3cm, left=3.5cm, right=3.5cm]{geometry}
\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{kantlipsum}
\NewTblrTheme{mytable}{
\SetTblrStyle{firstfoot,middlefoot}{\footnotesize\itshape}
\DefTblrTemplate{caption-sep}{default}{\enskip\(|\)\enskip}
}
\begin{document}
\kant[1-2]
\begingroup
\fontsize{10pt}{12pt}\selectfont
\begin{longtblr}[
theme = mytable,
caption = {A very long table},
]{
colspec = {X[l] Q[7cm,m] Q[c] Q[c]},
width = \linewidth,
row{1} = {teal7},
hline{1,Z} = {wd=1.5pt},
hline{2} = {},
cell{even[2-Z]}{4} = {r=2}{},
rowhead = 1,
}
column 1 & column 2 & column 3 & column 4 \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
row & some relatively long description so that the other entries can showboat their floatiness & row & rows \\
row & less showboating, maybe even no showboating & row & \\
\end{longtblr}
\endgroup
\kant[2]
\end{document}