我想扩展中的行xltabular
以涵盖 的定义@{}
。对于这个问题,我找到了一个解决方案使用可选参数(lr)
,该参数或多或少在booktabs
下的文档中进行了记录。但是如果后面跟着一条横跨整个表格宽度的线,Booktabs and longtables
则修复不起作用。rule
\documentclass[a4paper,11pt]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage[shorthands=off, bidi=basic, english, ngerman]{babel}%
\usepackage[table]{xcolor}
\usepackage{booktabs}
\aboverulesep=0pt
\belowrulesep=0pt
\cmidrulekern=-\tabcolsep
\usepackage{xltabular} % for tables with long lines & long tables (over >1 page)
\usepackage{luacolor,lua-ul} %for usage of style attributes - background color
\begin{document}
\begin{xltabular}{\textwidth}{@{} X X X @{}}
\cmidrule[1pt](lr){1-3}
\rowcolor[HTML]{b96ad9}
\textbf{Firstname} &
\textbf{Lastname} &
\textbf{Age} \\
\bottomrule(lr)
\cellcolor[HTML]{b96ad9}Jill &
Smith &
50 \\
\midrule(lr)
Eve &
\cellcolor[HTML]{b96ad9}Jackson &
94 \\
\midrule(lr)
\end{xltabular}
\begin{xltabular}{\textwidth}{@{} X X @{}}
% \midrule(lr) %<-------------------------- failure: Misplaced \omit. \end{xltabular}
\multicolumn{2}{@{}>{\hsize=\dimexpr2\hsize+2\tabcolsep\relax} X @{}}{
span over multiple rows with long text to fill in to cover the distance} \\
column 1 & column2 \\
\end{xltabular}
\begin{xltabular}{\textwidth}{@{} X X X @{}}
% \midrule(lr) %<-------------------------- failure: Misplaced \noalign. \end{xltabular}
\rowcolor[HTML]{b96ad9}
\textbf{Firstname} &
\textbf{Lastname} &
\textbf{Age} \\
\end{xltabular}
\end{document}
有没有办法可以修复这两个错误?
答案1
我对您的文档做了一些小改动(已标记)。希望对您有所帮助。
\documentclass[a4paper,11pt]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage[shorthands=off, bidi=basic, english, ngerman]{babel}%
\usepackage[table]{xcolor}
\usepackage{booktabs}
\aboverulesep=0pt
\belowrulesep=0pt
\cmidrulekern=-\tabcolsep
\usepackage{xltabular} % for tables with long lines & long tables (over >1 page)
\usepackage{luacolor,lua-ul} %for usage of style attributes - background color
\begin{document}
\begin{xltabular}{\textwidth}{@{} X X X @{}}
\cmidrule[1pt](lr){1-3}
\rowcolor[HTML]{b96ad9}
\textbf{Firstname} &
\textbf{Lastname} &
\textbf{Age} \\
\bottomrule(lr)
\cellcolor[HTML]{b96ad9}Jill &
Smith &
50 \\
\midrule(lr)
Eve &
\cellcolor[HTML]{b96ad9}Jackson &
94 \\
\midrule(lr)
\end{xltabular}
\begin{xltabular}{\textwidth}{@{} X X @{}}
\cmidrule[1pt](lr){1-2} %<-------------------------- changed
\multicolumn{2}{@{}>{\hsize=\dimexpr2\hsize+2\tabcolsep\relax} X @{}}{
span over multiple rows with long text to fill in to cover the distance span over multiple rows } \\ %longer text
column 1 & column2 \\
\end{xltabular}
\begin{xltabular}{\textwidth}{@{} X X X @{}}
\cmidrule[1pt](lr){1-3} %<--------------------------changed
\rowcolor[HTML]{b96ad9}
\textbf{Firstname} &
\textbf{Lastname} &
\textbf{Age} \\
\end{xltabular}
\end{document}