2

I have switched to the tabularray package a while ago and I have encountered an "issue" recently with a long table spanning over two pages in a report class document with lualatex and pdflatex. The table has a different number of rows for the last columns and the goal is to remove the unwanted cell lines around the empty cells in the last line.

However, the first bottom rule (before pagebreak) is not full width as required in the table preamble, but only half width like the table last row (see image 1 produced with the MWE and image 2 for expected output).

MWE :

\documentclass{report}
\usepackage{tabularray}

\begin{document}
    \begin{longtblr}
        [   caption = {Caption of the table presented just below},
        ]
        {   vlines={solid},
            vline{5-7} ={Z}{0pt},
            vline{4} = {1.5pt},
            hline{1-2}={1.5pt,solid},       
            hline{1-Y}={-}{solid},
            hline{Z}={1-3}{solid},
            rowhead=1,
            colspec={X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]},
        }
          Z & alpha & beta & Z & alpha & beta\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & & &
    \end{longtblr}  
\end{document}

image 1 : Output of the MWE

image 2 : Expected output of the MWE

I wonder whether the bottom rule before each pagebreak is the "copy" of the table bottom rule by default.

I have also tried using only row numbers instead of Y and Z, with no difference in the output.

Maybe I have missed something in the manual ? I have not found yet a similar issue posted online.

EDIT : I tried what @Celdor proposed. The issue with defining the last row as a foot is that it is repeated on every page and doesn't print a full \hline.

The repetition of the same line in the last MWE may be source of confusion, so I updated the MWE with row numbers, reduces column numbers and showed the use of a phantom rowfoot (colored in pink) with no border 3.

The desired output is : last row before pagebreak with full hline, last table row, half hline 3

\documentclass{report}
\usepackage{tabularray}
\usepackage{xcolor}

\begin{document}
    \begin{longtblr}
        [   caption = {Caption of the table presented just below},
        ]{  rowfoot = 1,
            vlines={solid},
            vline{4-5} ={Y}{0pt},
            vline{-} ={Z}{0pt},
            vline{3} = {1-Y}{1.5pt},
            hline{1-2}={1.5pt,solid},       
            hline{1-Y}={-}{solid},
            hline{Z}={2-4}{0pt},
            rowhead=1,
            cell{Z}{-}={red!10},
            colspec={X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]},
        }
    
          Z & alpha  & Z  & beta\\
        1   &   alpha          & 1    &       beta\\
        2   &   alpha  & 2    &       beta\\
        3   &   alpha  & 3    &       beta\\
        4   &   alpha  & 4    &       beta\\
        5   &   alpha  & 5    &       beta\\
        6   &   alpha  & 6    &       beta\\
        7   &   alpha  & 7    &       beta\\
        8   &   alpha  & 8    &       beta\\
        9   &   alpha  & 9    &       beta\\
        10  &   alpha  & 10   &       beta\\
        11  &   alpha  & 11   &       beta\\
        12  &   alpha  & 12   &       beta\\
        13  &   alpha  & 13   &       beta\\
        14  &   alpha  & 14   &       beta\\
        15  &   alpha  & 15   &       beta\\
        16  &   alpha  & 16   &       beta\\
        17  &   alpha  & 17   &       beta\\
        18  &   alpha  & 18   &       beta\\
        19  &   alpha  & 19   &       beta\\
        20  &   alpha  & 20   &       beta\\
        21  &   alpha  & 21   &       beta\\
        22  &   alpha  & 22   &       beta\\
        23  &   alpha  & 23   &       beta\\
        24  &   alpha  & 24   &       beta\\
        25  &   alpha  & 25   &       beta\\
        26  &   alpha  & 26   &       beta\\
        27  &   alpha  & 27   &       beta\\
        28  &   alpha  & 28   &       beta\\
        29  &   alpha  & 29   &       beta\\
        30  &   alpha  & 30   &       beta\\
        31  &   alpha  & 31   &       beta\\
        32  &   alpha  & 32   &       beta\\
        33  &   alpha  & 33   &       beta\\
        34  &   alpha  & 34   &       beta\\
        35  &   alpha  & 35   &       beta\\
        36  &   alpha  & 36   &       beta\\
        37  &   alpha  & 37   &       beta\\
        38  &   alpha  & 38   &       beta\\
        39  &   alpha  & 39   &       beta\\
        40  &   alpha  & 40   &       beta\\
        41  &   alpha  & 41   &       beta\\
        42  &   alpha  & 42   &       beta\\
        43  &   gamma   &\\
        & & & 
    \end{longtblr}
\end{document}

updated MWE output on the left, right : expected output

Maybe it is not possible to use the package as is for this case. Except avoiding the table spanning across multiple pages, could the redefition of the style of the last row with makeatletter/if/else/makeatother commands something to look into ?

Such as :
> if pagebreak, then full hline (or style defined by user for this line)
> else use linestyle defined by user

6
  • If I understand the case, you probably need to append rowfoot = 1 and define your last row e.g. as 5 & alpha & mu &&&. The effect is the last row definition will be copied across pages meaning each part of the table on subsequent page will have this exact row.
    – Celdor
    Oct 12, 2022 at 11:30
  • Strangely, even if you generally set hlines and at the very bottom of the table add \SetHline[1]{4-6}{0pt} (which is supposed to override the very last hline), you still get the incomplete hline on the first page. This really seems to be a bug. Oct 12, 2022 at 15:13
  • 1
    I really think that this is a bug. In many other cases (adding color, adding vertical lines), Z only refers to the last row (on the second) page. Only in the case of the hlines, Z somehow also refers to the the last row on other pages. Also, X or Y even in this case only affect the last page. This is at least very inconsistent in my opinion and should be fixed. Oct 12, 2022 at 15:30
  • 1
    I reported this as git issue to the package author. Oct 12, 2022 at 16:44
  • Thank you for reporting it. If it really is a bug, glad to have pointed it out.
    – laum
    Oct 12, 2022 at 21:51

1 Answer 1

1

I would like to post a workaround based on a suggestion by the package maintainer (thanks to lvjr!). Essentially, you can create a custom template that adds a \hrule to the table foot on every but the last page. The below example could probably be adjusted so that the rule is not drawn twice for the left two columns:

\documentclass{report}
\usepackage{tabularray}

\DefTblrTemplate{firstfoot,middlefoot}{mytemplate}{
  \vskip -0.4pt 
  \hrule height 0.4pt width \tablewidth
}

\DefTblrTemplate{lastfoot}{mytemplate}{
}

\NewTblrTheme{mytheme}{
  \SetTblrTemplate{foot}{mytemplate}
}

\begin{document}
    \begin{longtblr}
        [   caption = {Caption of the table presented just below},
            theme=mytheme,
        ]
        {   vlines={solid},
            vline{5-7} ={Z}{0pt},
            vline{4} = {1.5pt},
            hline{1-2}={1.5pt,solid},       
            hline{1-Y}={-}{solid},
            hline{Z}={1-3}{solid},
            rowhead=1,
            colspec={X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]X[halign=c, valign=m]},
        }
          Z & alpha & beta & Z & alpha & beta\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & 6 &   rho & omega\\
        5   &   alpha   &   mu  & & &
    \end{longtblr}  
\end{document}

page1 page2

1
  • works like a charm
    – laum
    Oct 18, 2022 at 7:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .