0

I'm creating a newenvironment for my standard style of table, using xltabular (tabularx + longtable). Something like this:

\newenvironment{tab1}[3]{\xltabular{\textwidth}{#2}
\hline
\rowcolor{WB7} #3 \\
\hline
\endfirsthead
\multicolumn{#1}{c}{\color{Y1} \faArrowUp \quad\quad\quad\quad\quad \faArrowUp \quad\quad\quad\quad\quad \faArrowUp \quad\quad\quad\quad\quad \faArrowUp \quad\quad\quad\quad\quad \faArrowUp} \\
\hline
\rowcolor{WB7} #3 \\
\hline
\endhead
\multicolumn{#1}{c}{\color{Y1} \faArrowDown \quad\quad\quad\quad\quad \faArrowDown \quad\quad\quad\quad\quad \faArrowDown \quad\quad\quad\quad\quad \faArrowDown \quad\quad\quad\quad\quad \faArrowDown}
\endfoot
\hline
\endlastfoot
}{\endxltabular}

\begin{tab1}{3}{|C|F|C|}{HELLO & Hello & hello} 1 & 2 & 3 \end{tab1}

The idea is that every table has a heading (#3) which will appear again in the case the table needs another page. This environment needs the number of columns (#1), the type of columns (#2) and the heading (#3), but for the heading I want a concrete style, a \cellcolor{WB7} and a rowstyle of \bfseries. Using \rowcolor{WB7} works fine, but I couldn't find any way to change the rowstyle. I just found these 2 questions which don't work in xltabular:

Make first row of table all bold

\bfseries for math mode (whole table row in bold)

Of course I could do {\textbf{HELLO} & \textbf{Hello} & \textbf{hello}} but as you can notice this is not a clean solution and it would be tedious to type \textbf{} every time.

CODE FOR COMPILING (simplified)

\documentclass{article}
\usepackage{xltabular}
\usepackage{multirow}
\usepackage{colortbl}

\begin{document}

\newenvironment{tab}[3]{\xltabular{\textwidth}{#2} \hline \rowcolor{yellow} #3 \ \hline \endfirsthead \multicolumn{#1}{c}{$\Uparrow$} \ \hline \rowcolor{yellow} #3 \ \hline \endhead \multicolumn{#1}{c}{$\Downarrow$} \endfoot \hline \endlastfoot }{\endxltabular}

\begin{tab}{3}{|X|X|X|}{HELLO & Hello & hello} 1 & 2 & 3 \end{tab}

\end{document}

  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – DG' Jun 30 '23 at 10:38
  • 1
    Why not using package tabularray, which does, e.g., provide defining the style of each row by row number. – cabohah Jun 30 '23 at 11:51
  • I'm currently trying with \SetRow{font=\bfseries} but it is not changing anything. I'm looking at the documentation of tabularray and also have tried to row{1}{font=\bfseries} but I don't know where to put this command as this is a xltabular environment and not a tblr. – Agente 156 Jun 30 '23 at 15:52

0 Answers0