0

I want to exend the line in xltabular to cover as well the definitons of @{}. For this question I found a solution with the optional parameter (lr) which is more or less documented in the booktabs documentation under Booktabs and longtables. But somehow the fix doesn't work if the rule is followed by a line which spans over the whole table width.

\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} 

Is there a way to fix both of the errors?

0

1 Answer 1

0

I did some minor changes to your document (marked). I hope it helps.

\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}

output

1
  • Although I would have preferred a different solution I now have used this one. Thx for the effort.
    – LeO
    Dec 9, 2020 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.