这是在 longtblr 中添加一段长文本,横跨整个表格的宽度给定下表(一个 longtblr):
\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}
\usepackage{dcolumn,longtable,booktabs}
\begin{document}
\begin{longtblr}[
presep=-4pt,postsep=0pt
]{
colspec = {lX},
\columnwidth,
colsep=4pt,
hlines,
hline{2,4,6}={0pt},
}
01/01/2020 $-$ 31/12/2022 & \textbf{First}
\\[-4pt]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} {\lipsum[2]} &\\
01/01/2018 $-$ 31/12/2019 & \textbf{Second}
\\[-4pt]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} {\lipsum[2]} &\\
01/01/2016 $-$ 31/12/2017 & \textbf{Third}
\\[-4pt]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} {\lipsum[2]} &\\
\end{longtblr}
是否可以将变量分配给垂直距离\\[-4pt]
,也许在 longtblr 的选项字段内?这样我就不需要在包含许多条目/行的表中多次更改它了……
我正在考虑这样的事情,使用变量名“mydistance”,但它不起作用:
\begin{longtblr}[
presep=-4pt,postsep=0pt
]{
colspec = {lX},
\columnwidth,
colsep=4pt,
hlines,
hline{2,4,6}={0pt},
mydistance = -4pt,
}
01/01/2020 $-$ 31/12/2022 & \textbf{First}
\\[mydistance]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} {\lipsum[2]} &\\
01/01/2018 $-$ 31/12/2019 & \textbf{Second}
\\[mydistance]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} {\lipsum[2]} &\\
01/01/2016 $-$ 31/12/2017 & \textbf{Third}
\\[mydistance]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} {\lipsum[2]} &\\
\end{longtblr}
答案1
您可以定义一个长度:
\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}
\newlength{\foo}
\begin{document}
\setlength{\foo}{-4pt}
\begin{longtblr}[
presep=-4pt,postsep=0pt
]{
colspec = {lX},
\columnwidth,
colsep=4pt,
hlines,
hline{2,4,6}={0pt},
}
01/01/2020 $-$ 31/12/2022 & \textbf{First}
\\[\foo]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} \lipsum[2] &\\
01/01/2018 $-$ 31/12/2019 & \textbf{Second}
\\[\foo]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} \lipsum[2] &\\
01/01/2016 $-$ 31/12/2017 & \textbf{Third}
\\[\foo]
\SetCell[c=2]{wd=\textwidth-8pt,halign=j} \lipsum[2] &\\
\end{longtblr}
\end{document}
如果严格每隔一行:
\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[
presep=-4pt,postsep=0pt
]{
colspec = {lX},
colsep=4pt,
hline{odd}={solid},
row{odd}={belowsep=0pt},
row{even}={abovesep=0pt},
cell{even}{1} = {c=2}{wd=\textwidth-8pt,halign=j}
}
01/01/2020 $-$ 31/12/2022 & \textbf{First}\\
\lipsum[2] &\\
01/01/2018 $-$ 31/12/2019 & \textbf{Second}\\
\lipsum[2] &\\
01/01/2016 $-$ 31/12/2017 & \textbf{Third}\\
\lipsum[2] &\\
\end{longtblr}
\end{document}