4

I have some Q-column but using a \TblrNote seems to break the auto-width of those columns... How can I re-adjust the width so columns 3-8 are of equal width?

\documentclass{scrartcl}
\usepackage{tabularray,xcolor,hyperref}
\UseTblrLibrary{siunitx}

\NewTblrTheme{mytheme}{
  \DefTblrTemplate{contfoot-text}{default}{Continued on next page ...}
  \DefTblrTemplate{conthead-text}{default}{(Continued)}
  \SetTblrStyle{head}{%
    fg=black}
  \SetTblrInner{%
    row{odd} = {bg=rwthBlueLight},
    row{1}={bg=blue,fg=white,font=\bfseries},
    width = \linewidth,
    hline{1,Z} = {2pt,fg=blue}, % toprule and bottomrule
    hline{2} = {1pt,fg=blue}, % midrule
    }
  }


  \hypersetup{%
    colorlinks = true,
    linkcolor = blue
  }

\begin{document}

\begin{tblr}[%
  theme=mytheme,
  long,
  note{a}={Figures in EUR},
  note{b}={Not all figures in EUR},
  ]{%
    colspec = {X[2,m]X[6,m]*{2}{Q[c]}Q[c]*{3}{Q[c]}},
    cell{1}{1-8} = {cmd={\hypersetup{linkcolor=white}}},
    rowhead = 1
  }
  {Project} %
  & Species %
  & {{{Quantity}}}
  & {{{Average\\ number of\\ weeks kept}}}
  & {{{Housing costs\\ per animal\\ per week}}}\TblrNote{a}
  & {{{Purchasing\\ costs \\per animal}}}\TblrNote{a}
  & {{{Requested\\funds}}}\TblrNote{a}
  & {{{Existing\\funds}}}\TblrNote{a}\\
  Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2\\
  \end{tblr}

\end{document}

enter image description here

1
  • If you want to manually set the width of the columns, you can do so right in the colspec, e.g. Q[c,2cm]; otherwise you're probably better off changing them to X with an appropriate coefficient. I think you can also do column{3-8} = {2cm,c} as another option; but I'm not 100% sure that's what you want.
    – frabjous
    Apr 1, 2022 at 0:07

1 Answer 1

8
  • Your MWE contain errors (color names).
  • Added is use of siunitx columns.
  • Interchanged are Q and X columns ...
  • for column headers I would use \small\bfseries font size

Edit:

  • We should be aware, that tags in TblrNote are in case of use hyperref package are defined by it. That tags in TblrNote will be visible, it is need to locally changed hyperref setup so, that color of tags will be the same as color of text in rows.
  • Since in table is used siunitx packages, the column headers should be in parenthesis. That hyper links will work \TblrNote had to be outside of them:
\documentclass{scrartcl}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-minimum-digits=4}
\usepackage{hyperref}
  \hypersetup{%
    colorlinks = true,
    linkcolor = blue % color is the same as the first row color!
  }

\begin{document}

\begin{longtblr}[%
  note{a}={Figures in EUR},
  note{b}={Not all figures in EUR},
                ]{%
    colsep  = 2pt,
    colspec = {*{2}{Q[l]} 
               *{3}{X[c, si={table-format=3.1}]}
               *{2}{X[1.1, c, si={table-format=5.1}]}
                    X[0.8, c, si={table-format=5.1}]
               },
    row{odd} = {bg=LightBlue},
    row{1}   = {bg=blue, fg=white, font=\small\bfseries,
                cmd={\hypersetup{linkcolor=white}} % needed that `TblrNote` tag  become visible
                },
    rowhead  = 1
                }
    \toprule[blue]
Project 
    & Species 
        & {{{Quantity}}}
            & {{{Average number of weeks kept}}}
                & {{{Housing costs per animal per week}}}\TblrNote{a}
                    & {{{Purchasing costs per animal}}}\TblrNote{a}
                        & {{{Requested funds}}}\TblrNote{a}
                            & {{{Existing funds\TblrNote{a}}}} \\
    \midrule[blue]
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2  \\
Hello & World & 456 & 78.9 & 123 & 10992.0 &  6789.0 &  1234.5  \\
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2  \\
Hello & World & 456 & 78.9 & 123 & 10992.0 &  6789.0 &  1234.5  \\
    \bottomrule[blue]
  \end{longtblr}
\end{document}

enter image description here

Addendum: With tabularray package version newer than 2022A the table code can be a bit simpler:

\documentclass{scrartcl}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-minimum-digits=4}
\usepackage{hyperref}
  \hypersetup{%
    colorlinks = true,
    linkcolor = blue % color is the same as the first row color!
  }

\begin{document}

\begin{longtblr}[%
  note{a}={Figures in EUR},
  note{b}={Not all figures in EUR},
                ]{%
    colsep  = 2pt,
    colspec = {*{2}{Q[l]}
               *{3}{X[c, si={table-format=3.1}]}
               *{2}{X[1.1, c, si={table-format=5.1}]}
                    X[0.8, c, si={table-format=5.1}]
               },
    row{odd} = {bg=LightBlue},
    row{1}   = {guard,    % <---
                font=\small\bfseries,
                fg=white, bg=blue,
                cmd={\hypersetup{linkcolor = white}}, % needed that `TblrNote` tag  be visible
                },
    rowhead  = 1
                }
    \toprule[blue]
Project
    & Species  % <---
        &   Qnty  % <--- 
            &   Average number of weeks kept  % <--- 
                &   Housing costs per animal per week\TblrNote{a}  % <---
                    &   Purchasing costs per animal\TblrNote{a}  % <---
                        &   Requested funds\TblrNote{a}  % <---
                            &   Existing funds\TblrNote{a}  % <---  \\
    \midrule[blue]
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2  \\
Hello & World & 456 & 78.9 & 123 & 10992.0 &  6789.0 &  1234.5  \\
Hello & World & 123 & 45.6 & 789 & 10992.0 & 11223.5 & 32012.2  \\
Hello & World & 456 & 78.9 & 123 & 10992.0 &  6789.0 &  1234.5  \\
    \bottomrule[blue]
  \end{longtblr}
\end{document}

Compilation result is the same as before.

6
  • Thank you. But changing the position of \TblrNote into {{{}}} will not print them. Apr 1, 2022 at 10:23
  • @LukasCB, they are there, but it has the same color as row background, so they are not visible. I will look how to change their color.
    – Zarko
    Apr 1, 2022 at 10:57
  • Thx for the support: It seems like it would work with cell{1}{1-8} = {cmd={\hypersetup{linkcolor=white}}},, to change the linking color locally... Apr 1, 2022 at 11:46
  • 1
    @LukasCB, you are right. And this works if \TblrNote is out of curly braces. I will add addendum to my answer ASAP
    – Zarko
    Apr 1, 2022 at 12:03
  • @LukasCB, see edited answer. Hopefully now works as you desired.
    – Zarko
    Apr 1, 2022 at 12:40

You must log in to answer this question.

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