3

I came across this question which wants no header rows on the last page. While trying to find a way for that I was wondering if it's possible to have different header rows on different pages automatically. An MWE is given with the tabularray package but it's not necessary to use this package for a solution. So, is it possible to have different header rows on different pages?

\documentclass{article}

\usepackage{xcolor} \usepackage{tabularray}

\begin{document} \begin{longtblr}[ caption = {A Long Long Long Long Long Long Long Table}, entry = {Short Caption}, label = {tblr:test}, ]{ colspec = {XXX}, width = 0.85\linewidth, rowhead = 2, rowfoot = 1, row{odd} = {gray9}, row{even} = {brown9}, row{1-2} = {purple7}, row{Z} = {blue7}, }

\hline Head & Head & Head \ \hline Head & Head & Head \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Foot & Foot & Foot \ \hline \end{longtblr} \end{document}

L.J.R.
  • 10,932
Imran
  • 3,096
  • 1
    note you have tagged this longtable but longtable and tabulararry do not share any code so any solution for one will not apply to the other, you may want to tag both packages and make your title clearer that you refer to a generic "long table" not specifically longtable – David Carlisle Dec 04 '21 at 15:59
  • @DavidCarlisle Thanks, edited the title. Please add the appropriate tag or remove the inappropriate one. Solution using any package is acceptable and I am not sure which tag to add in that case (I thought longtable tag wasn't related to any package, so I added that). – Imran Dec 04 '21 at 16:08
  • if you hover over the longtable tag below your question you will see it references the package there is this for longtable https://tex.stackexchange.com/questions/263597/change-endhead-in-the-middle-of-a-longtable/263602#263602 – David Carlisle Dec 04 '21 at 16:22
  • The row head and foot are saved in boxes at the beginning of the tblr construction, and so they cannot be changed mid-table. You could try to put this information in the table head instead, (as a mini tblr in the capcont template), but it would probably be difficult to align it with the main table. – Pieter van Oostrum Dec 04 '21 at 19:26
  • @PietervanOostrum If possible, please write an answer. – Imran Dec 05 '21 at 05:29

1 Answers1

3

The row head and foot are saved in boxes at the beginning of the tblr construction, and so they cannot be changed mid-table. You could try to put this information in the table head instead, and then you can differentiate between first, middle and last head. These are also put in boxes, so you can only differentiate between the first end last one, and all the intermediate ones (the latter ones will be all the same).

Here is an example of how this could be done. I have used the capcont template, which applies to all headers after the first one. If you want to differentiate between the middle and the last headers, you should use the middlehead and lasthead templates instead.

It could use some improvement in the spacing. If you use different colspecs the header might not align with the rest of the table.

\documentclass{article}

\usepackage{xcolor} \usepackage{tabularray} \newcommand\RowHead{Head-2} \DefTblrTemplate {conthead-text}{rowheads}{% (Continued)\par \begin{tblr}{colspec = {XXX}, width = 0.85\textwidth, row{odd} = {gray9}, row{even} = {brown9}, row{1-2} = {purple7}, row{Z} = {blue7}, } \hline \RowHead & \RowHead & \RowHead \ \hline \RowHead & \RowHead & \RowHead \end{tblr} }

\DefTblrTemplate{capcont}{rowheads}{% \par\centering \UseTblrTemplate {caption-tag}{default}% \UseTblrTemplate {caption-sep}{default}% \UseTblrTemplate {caption-text}{default}% \UseTblrTemplate {conthead-text}{rowheads}% } \NewTblrTheme{rowheads}{% \SetTblrTemplate{capcont}{rowheads}% }

\begin{document} \begin{longtblr}[ theme=rowheads, headsep=0pt, caption = {A Long Long Long Long Long Long Long Table}, entry = {Short Caption}, label = {tblr:test}, ]{ colspec = {XXX}, width = 0.85\textwidth, rowhead = 0, rowfoot = 1, row{odd} = {gray9}, row{even} = {brown9}, row{1-2} = {purple7}, row{Z} = {blue7}, }

\hline Head & Head & Head \ \hline Head & Head & Head \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Alpha & Beta & Gamma \ \hline Epsilon & Zeta & Eta \ \hline Iota & Kappa & Lambda \ \hline Nu & Xi & Omicron \ \hline Rho & Sigma & Tau \ \hline Phi & Chi & Psi \ \hline Foot & Foot & Foot \ \hline \end{longtblr} \end{document}

enter image description here

enter image description here