我有一些 Q 列,但使用\TblrNote
似乎会破坏这些列的自动宽度...我该如何重新调整宽度以使第 3-8 列的宽度相等?
\documentclass{scrartcl}
\usepackage{tabularray,xcolor,hyperref}
\UseTblrLibrary{siunitx}
\NewTblrTheme{mytheme}{
\DefTblrTemplate{contfoot-text}{default}{Continued on next page ...}
\DefTblrTemplate{conthead-text}{default}{(Continued)}
\SetTblrStyle{head}{%
fg=black}
\SetTblrInner{%
row{odd} = {bg=rwthBlueLight},
row{1}={bg=blue,fg=white,font=\bfseries},
width = \linewidth,
hline{1,Z} = {2pt,fg=blue}, % toprule and bottomrule
hline{2} = {1pt,fg=blue}, % midrule
}
}
\hypersetup{%
colorlinks = true,
linkcolor = blue
}
\begin{document}
\begin{tblr}[%
theme=mytheme,
long,
note{a}={Figures in EUR},
note{b}={Not all figures in EUR},
]{%
colspec = {X[2,m]X[6,m]*{2}{Q[c]}Q[c]*{3}{Q[c]}},
cell{1}{1-8} = {cmd={\hypersetup{linkcolor=white}}},
rowhead = 1
}
{Project} %
& Species %
& {{{Quantity}}}
& {{{Average\\ number of\\ weeks kept}}}
& {{{Housing costs\\ per animal\\ per week}}}\TblrNote{a}
& {{{Purchasing\\ costs \\per animal}}}\TblrNote{a}
& {{{Requested\\funds}}}\TblrNote{a}
& {{{Existing\\funds}}}\TblrNote{a}\\
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2\\
\end{tblr}
\end{document}
答案1
- 您的 MWE 包含错误(颜色名称)。
- 添加了列的使用
siunitx
。 - 互换的是 Q 和 X 列......
- 对于列标题,我将使用
\small\bfseries
字体大小
编辑:
- 我们应该知道,
TblrNote
在使用包的情况下,中的标签hyperref
由它定义。 中的标签TblrNote
将是可见的,需要本地更改hyperref
设置,以便标签的颜色与行中文本的颜色相同。 - 由于表中使用了
siunitx
包,因此列标题应放在括号中。超链接\TblrNote
必须在括号外才能正常工作:
\documentclass{scrartcl}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-minimum-digits=4}
\usepackage{hyperref}
\hypersetup{%
colorlinks = true,
linkcolor = blue % color is the same as the first row color!
}
\begin{document}
\begin{longtblr}[%
note{a}={Figures in EUR},
note{b}={Not all figures in EUR},
]{%
colsep = 2pt,
colspec = {*{2}{Q[l]}
*{3}{X[c, si={table-format=3.1}]}
*{2}{X[1.1, c, si={table-format=5.1}]}
X[0.8, c, si={table-format=5.1}]
},
row{odd} = {bg=LightBlue},
row{1} = {bg=blue, fg=white, font=\small\bfseries,
cmd={\hypersetup{linkcolor=white}} % needed that `TblrNote` tag become visible
},
rowhead = 1
}
\toprule[blue]
Project
& Species
& {{{Quantity}}}
& {{{Average number of weeks kept}}}
& {{{Housing costs per animal per week}}}\TblrNote{a}
& {{{Purchasing costs per animal}}}\TblrNote{a}
& {{{Requested funds}}}\TblrNote{a}
& {{{Existing funds\TblrNote{a}}}} \\
\midrule[blue]
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2 \\
Hello & World & 456 & 78.9 & 123 & 10992.0 & 6789.0 & 1234.5 \\
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2 \\
Hello & World & 456 & 78.9 & 123 & 10992.0 & 6789.0 & 1234.5 \\
\bottomrule[blue]
\end{longtblr}
\end{document}
附录:
对于tabularray
2022A 以上版本的软件包,表代码可以更简单一些:
\documentclass{scrartcl}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-minimum-digits=4}
\usepackage{hyperref}
\hypersetup{%
colorlinks = true,
linkcolor = blue % color is the same as the first row color!
}
\begin{document}
\begin{longtblr}[%
note{a}={Figures in EUR},
note{b}={Not all figures in EUR},
]{%
colsep = 2pt,
colspec = {*{2}{Q[l]}
*{3}{X[c, si={table-format=3.1}]}
*{2}{X[1.1, c, si={table-format=5.1}]}
X[0.8, c, si={table-format=5.1}]
},
row{odd} = {bg=LightBlue},
row{1} = {guard, % <---
font=\small\bfseries,
fg=white, bg=blue,
cmd={\hypersetup{linkcolor = white}}, % needed that `TblrNote` tag be visible
},
rowhead = 1
}
\toprule[blue]
Project
& Species % <---
& Qnty % <---
& Average number of weeks kept % <---
& Housing costs per animal per week\TblrNote{a} % <---
& Purchasing costs per animal\TblrNote{a} % <---
& Requested funds\TblrNote{a} % <---
& Existing funds\TblrNote{a} % <--- \\
\midrule[blue]
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2 \\
Hello & World & 456 & 78.9 & 123 & 10992.0 & 6789.0 & 1234.5 \\
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2 \\
Hello & World & 456 & 78.9 & 123 & 10992.0 & 6789.0 & 1234.5 \\
\bottomrule[blue]
\end{longtblr}
\end{document}
编译结果和以前相同。