Misaligned Text in Complex Tabularray Table

horizontal alignmentrotatingtablestabularray

Aim

I have this behemoth of a tabularray table within a custom latex document class that I want to polish. The code for the document as well as the class is given below, you can also check it out on Overleaf.

Problem

Due to the many features, i.e., sideways table, rotated columns, multirow and multicolumn content, and the custom document class, I am unable to find the source of the issues that I have with the table. I feel like tabularray would usually handle most of the issues automatically, but for some reason it does not. Probably I did some mistakes or mixed in some non-tabularray syntax somewhere. The areas I would like to improve are:

  • Some Entries in the second row are misaligned and ragged to the right, e.g., 'Data Stewardship'
  • Some entries in the second row perform a linebreak too early, while they still have enough space to fit another word into the same line, e.g., 'Target User Group' and 'Improve Data Management'
  • The values in the last row ('Relative') are somehow misaligned and intersect the vertical lines. Best case here would be to to have enough space to use percentage values instead of floating point numbers, i.e., 20% instead of '.20'. I tried that, but each cell overlapped its neighbor.
  • I think the third row (the rotated one) should be a bit more narrow. It has a lot of space at the top and bottom.

What is the source of these issues and how to address them? Is it the rotated boxes?

What I tried so far

I played around with the column width of the first and second rows (e.g., \SetCell[..]{1.5cm}), because I thought tabularray would handle it automatically then. But if I leave it out the width, the whole table breaks. I think this is issue stems from the rotated cells. Also, I tried using Q columns with a width of 0.15cm to increase spacing between columns and leave enough space for the percentages, but that lead to the table becoming too large. I would be open to reduce the font size a bit, if it helps, but I think that is not the main issue here.

Code Main

\documentclass{thesisclass}

\usepackage{lipsum}

\usepackage{tabularray}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{xcolor}
\usepackage{adjustbox}

\begin{document}

\chapter{Introduction}

\lipsum[4]

\section{Very Interesting Content}
\lipsum[1-3]

\newpage
\begingroup
\renewcommand\cellalign{cc}

\begin{sidewaystable}
\small
\begin{talltblr}[
    caption={Concept matrix for data catalogs.},
    label={tab:concept-matrix}
]{
    width=\linewidth,
    colspec={ Q[3cm,l] X X|X X X|X X X X|X X X X X X XX|X X X X X X X|X X X X X X|X X X X},
    cell{3}{2-Z} = {f, cmd=\rotcell[cc]},
    cell{1}{1} = {f},
    row{even} = {white},
    row{odd} = {gray!20},
    row{1-3} = {white, font=\bfseries},
    row{29-30} = {white},
    hline{1,Z} = 1.5pt, 
    hline{2-4} = {solid},
    hline{29} = {solid},
    stretch=0 % reduce row spacing -> https://tex.stackexchange.com/questions/611976/decrease-row-height-in-tabularray
}
      \SetCell[r=3]{f,l} Source & \SetCell[c=17]{m,c,7.5cm} Use Case for Provisioning Method & & & & & & & & & & & & & & & & &
    \SetCell[c=7,r=2]{m,c, 1.75cm} Data Source, Type and Way of Creation & & & & & & &
    \SetCell[c=10]{m,c, 2.5cm} Usage & & & & & & & & & &\\
    
    & & &  
    \SetCell[c=3]{m,c,0.75cm} Data Steward\-ship & & &  
    \SetCell[c=4]{m,c, 1cm} Foster Interaction & & & &
    \SetCell[c=8]{m,c, 2cm} Improve Data Management & & & & & & & &
    & & & & & & &
    \SetCell[c=6]{m,c, 1.5cm} Target User Group & & & & & &
    \SetCell[c=4]{m,c, 1cm} Institution & & & & \\
    
    Source & Data Monetization&Enable/Improve BIA&Governance&Compliance&Data Quality&Rating&Collaboration& Internal Sharing & External Sharing &Findability&Access&Interoperability&Reuse&Access Control&Data Description & Enrichment&Provenance&Data Lake&Manual&Automated&Top-down&Bottom-up&Data&Metadata&DA and DS &Business Users&Researchers&Management&IT Administration&Data Steward&Business&Research&Government&Private Users\\
    Cherradi 2022&&&x&&x&&&&&x&x&&&&&x&x&x&&&&&&x&&&&&&&x&&&\\
    Ehrlinger 2021&&x&x&&x&&&&&x&x&x&x&&&&&x&x&x&x&x&&x&x&x&&&&x&x&&&\\
    Calancea 2021&x&&x&x&x&&&&x&x&x&x&x&x&x&&x&&x&&&&x&x&x&x&x&&x&&x&&&\\
    Sawadogo 2021&&x&x&&x&&&&&x&x&&&&x&x&x&x&x&x&&&&x&&&&&&&&&&\\
    Eichler 2021&&&x&&&&&x&&x&&&&x&&x&&&&&&&&x&x&x&x&x&x&x&x&&&\\
    Garmandia 2021*&&&x&x&x&&&x&x&x&x&&x&x&x&x&x&&x&&x&&x&x&&x&&&&&&&x&x\\
    Flynn 2021*&&&x&&&&&x&x&x&x&x&x&x&x&&x&&&&&&&x&x&x&x&&x&x&x&x&x&x\\
    Labadie 2020&&x&x&x&x&x&&x&&x&x&x&x&&x&x&&&x&x&x&x&&x&x&x&&x&x&x&x&&&\\
    Dibowski 2020&&&&&&&&&&x&x&x&x&x&&&&x&&x&&&&x&x&x&&&x&&x&&&\\
    Aikoh 2020&&&&&x&&&&&&&&&&&&&&&&&&&x&&&&&&x&&&&\\
    Leadbetter 2020*&&&x&x&x&&&&&x&x&x&x&&&x&x&&&&&&&x&&&&&&&&x&x&\\
    Bhatia 2020*&&&&&&&&&&x&x&x&x&&&&&&&&x&&&x&&x&x&&&&&x&x&\\
    Holl 2019&&x&&&&&&x&&x&x&x&&&&&x&x&x&x&&x&x&x&x&&&&&&x&&&\\
    Sawadogo 2019&&&&&x&&&&&x&x&&&&&x&x&&&&&&&x&&&&&&&&&&\\
    Malta 2018&&&&&&&&&x&&&x&x&&&&&&x&x&&&&x&&&x&&&&&x&&\\
    Czajkowski 2017&&&&&&&x&x&x&&x&&&x&&&&&&&&&&x&&x&x&&&&&x&&x\\
    Shanmugam 2016&&&x&x&x&&&&&x&&&&x&&x&x&&&&&&&x&&&&&&&&&&\\
    Oliveira 2016&&&&&&x&&&x&x&x&&&&x&x&&&x&x&&x&x&x&&&&&&&x&x&x&x\\
    Halevy 2016&&&x&x&x&&&x&&x&x&x&x&&x&&x&x&&x&&x&&x&&&&&&&x&&&\\
    Stillerman 2016*&&&&&&&&x&x&x&x&x&x&&x&x&x&&x&&x&&&x&&&x&&&&&x&&\\
    Nakandala 2015&&&&&&&&x&x&x&&&x&x&&&&&&x&&&&x&&&x&&&&&x&&\\
    Friddell 2014*&&&&&x&&&x&x&x&x&x&x&&x&&&&x&&x&&x&x&&&x&&&&&x&x&x\\
    Beaujardiere 2010&&&&&&&&x&x&x&x&x&&&&&&&&x&&&&x&&&x&&&&&x&x&\\
    Franklin 2005&&&&&x&&&&&x&x&&&x&&&&&&&&&&x&&&&&&&x&&&\\
    Hale 1998*&&&&&x&&&&x&x&&x&&&&&&&x&&x&&&x&&&&&&&&&&\\
    Absolute&1&4&11&6&14&2&1&11&11&22&19&14&13&9&9&10&11&6&11&10&7&5&5&25&7&9&10&2&5&5&11&10&7&5\\
    Relative&$.04$&$.16 $&$.44  $&$.24  $&$.56  $&$.08  $&$.04  $&$.44  $&$.44  $&$.88  $&$.76  $&$.56  $&$.52  $&$.36  $&$.36  $&$.40  $&$.44  $&$.24  $& $.44$&$.40   $&$.28  $&$.20  $&$.20  $&$1    $&$.28  $&$.36  $&$.40  $&$.08  $&$.20  $&$.20  $&$.44  $&$.40  $&$.28  $&$.20$\\
    
\end{talltblr}
\end{sidewaystable}
\normalsize
\endgroup
\newpage 

\end{document}

Code for Class

For reproducing the table. The original class is longer. I deleted all stuff that was unnecessary for the format of the page.

\NeedsTeXFormat{LaTeX2e}                                        % We do need LaTeX2e
\ProvidesClass{thesisclass}
\LoadClass[a4paper,11pt,titlepage,openany,oneside]{scrbook} % Class based on scrbook

%% -------------------------------
%% |          Packages           |
%% -------------------------------

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % Input in ISO 8859-1 (Latin1)

\usepackage{ae}               % Almost european, virtual T1-Font
\usepackage[pdftex]{graphicx}
\usepackage{vmargin}          % Adjust margins in a simple way
\usepackage{fancyhdr}         % Define simple headings
\usepackage{subfigure}
\usepackage{url}
\usepackage[absolute,overlay]{textpos}
\usepackage{tikz}

%% IM Packages
\usepackage{setspace} % 1.5 line spacing
\onehalfspacing

%% --- End of Packages ---

%% -------------------------------
%% |         New commands        |
%% -------------------------------
\newcommand{\changefont}[3]{\fontfamily{#1} \fontseries{#2} \fontshape{#3} \selectfont}
%\renewcommand*{\headfont}{\slshape}
%\newcommand{\captionfont}{}
\newcommand{\chapterheadfont}{}
\newcommand{\blankpage}{
 \clearpage{\pagestyle{empty}\cleardoublepage}
}
%% --- End of New Commands ---

%% -------------------------------
%% |      Globale Settings       |
%% -------------------------------
\setcounter{secnumdepth}{3} % Numbering also for \subsubsections
\setcounter{tocdepth}{3}    % Register \subsubsections in content directory

\setpapersize{A4}
\setmarginsrb{3cm}{1cm}{3cm}{1cm}{6mm}{7mm}{5mm}{15mm}

\parindent 0cm                     % Do not indent beginning of paragraph
\parskip1.5ex plus0.5ex minus0.5ex % Margin between paragraphs
%% --- End of global Settings ---

%% -------------------------------
%% |          Headings           |
%% -------------------------------
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancyhf{}
\fancyhead[R]{\headfont\nouppercase{\rightmark}}   % Header for onesided Version
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{%
\fancyhf{}                                                  % No Header and Footer fields
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{\thepage}
}
%% --- End of Headings ---

%% **** END OF CLASS ****

Table

Table

Best Answer

  • Some Entries in the second row are misaligned and ragged to the right, e.g., 'Data Stewardship'
  • Some entries in the second row perform a linebreak too early, while they still have enough space to fit another word into the same line, e.g., 'Target User Group' and 'Improve Data Management'

You just give them too little space, e.g. 0.75cm for 'Data Steward-ship', and 2cm for 'Improve Data Management'. Just give them more space. By the way, leaving out the width just makes the to a cell without line breaking, so that's not what you want. Finding the proper width is a bit of trial and error.

  • The values in the last row ('Relative') are somehow misaligned and intersect the vertical lines. Best case here would be to to have enough space to use percentage values instead of floating point numbers, i.e., 20% instead of '.20'. I tried that, but each cell overlapped its neighbor.

The columns are just too narrow, because you have too many columns in the available table width. It helps to make the colsep smaller, thus giving more space to the columns. Also 'Institution' was followed by one too many &, thus giving an extra empty row at the end.

And the first column doesn't need a width, just l gives it the minimal space it needs.

  • I think the third row (the rotated one) should be a bit more narrow. It has a lot of space at the top and bottom.

\rotatebox{90} from the graphics package gives better results.

\documentclass{thesisclass}

\usepackage{lipsum}

\usepackage{tabularray}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{xcolor}
\usepackage{adjustbox}
\usepackage{graphics}

\begin{document}

\chapter{Introduction}

\lipsum[4]

\section{Very Interesting Content}
\lipsum[1-3]

\newpage
\begingroup
%\renewcommand\cellalign{cc}

\begin{sidewaystable}
\small
\begin{talltblr}[
    caption={Concept matrix for data catalogs.},
    label={tab:concept-matrix}
]{
    width=\linewidth,
    colspec={ l X X|X X X|X X X X|X X X X X X X X|X X X X X X X|X X X X X X|X X X X},
    colsep=4pt,
    cell{3}{2-Z} = {f, cmd=\rotatebox{90}},
    cell{1}{1} = {f},
    row{even} = {white},
    row{odd} = {gray!20},
    row{1-3} = {white, font=\bfseries},
    row{29-30} = {white},
    hline{1,Z} = 1.5pt, 
    hline{2-4} = {solid},
    hline{29} = {solid},
    stretch=0 % reduce row spacing -> https://tex.stackexchange.com/questions/611976/decrease-row-height-in-tabularray
}
      \SetCell[r=3]{f,l} Source & \SetCell[c=17]{m,c,7.5cm} Use Case for Provisioning Method & & & & & & & & & & & & & & & & &
    \SetCell[c=7,r=2]{m,c, 3cm} Data Source, Type and Way of Creation & & & & & & &
    \SetCell[c=10]{m,c, 2.5cm} Usage & & & & & & & & & \\
    
    & & &  
    \SetCell[c=3]{m,c, 1.5cm} Data Steward\-ship & & &  
    \SetCell[c=4]{m,c, 2cm} Foster Interaction & & & &
    \SetCell[c=8]{m,c, 4cm} Improve Data Management & & & & & & & &
    & & & & & & &
    \SetCell[c=6]{m,c, 2.5cm} Target User Group & & & & & &
    \SetCell[c=4]{m,c, 2cm} Institution & & & \\
    
    Source & Data Monetization&Enable/Improve BIA&Governance&Compliance&Data Quality&Rating&Collaboration& Internal Sharing & External Sharing &Findability&Access&Interoperability&Reuse&Access Control&Data Description & Enrichment&Provenance&Data Lake&Manual&Automated&Top-down&Bottom-up&Data&Metadata&DA and DS &Business Users&Researchers&Management&IT Administration&Data Steward&Business&Research&Government&Private Users\\
    Cherradi 2022&&&x&&x&&&&&x&x&&&&&x&x&x&&&&&&x&&&&&&&x&&&\\
    Ehrlinger 2021&&x&x&&x&&&&&x&x&x&x&&&&&x&x&x&x&x&&x&x&x&&&&x&x&&&\\
    Calancea 2021&x&&x&x&x&&&&x&x&x&x&x&x&x&&x&&x&&&&x&x&x&x&x&&x&&x&&&\\
    Sawadogo 2021&&x&x&&x&&&&&x&x&&&&x&x&x&x&x&x&&&&x&&&&&&&&&&\\
    Eichler 2021&&&x&&&&&x&&x&&&&x&&x&&&&&&&&x&x&x&x&x&x&x&x&&&\\
    Garmandia 2021*&&&x&x&x&&&x&x&x&x&&x&x&x&x&x&&x&&x&&x&x&&x&&&&&&&x&x\\
    Flynn 2021*&&&x&&&&&x&x&x&x&x&x&x&x&&x&&&&&&&x&x&x&x&&x&x&x&x&x&x\\
    Labadie 2020&&x&x&x&x&x&&x&&x&x&x&x&&x&x&&&x&x&x&x&&x&x&x&&x&x&x&x&&&\\
    Dibowski 2020&&&&&&&&&&x&x&x&x&x&&&&x&&x&&&&x&x&x&&&x&&x&&&\\
    Aikoh 2020&&&&&x&&&&&&&&&&&&&&&&&&&x&&&&&&x&&&&\\
    Leadbetter 2020*&&&x&x&x&&&&&x&x&x&x&&&x&x&&&&&&&x&&&&&&&&x&x&\\
    Bhatia 2020*&&&&&&&&&&x&x&x&x&&&&&&&&x&&&x&&x&x&&&&&x&x&\\
    Holl 2019&&x&&&&&&x&&x&x&x&&&&&x&x&x&x&&x&x&x&x&&&&&&x&&&\\
    Sawadogo 2019&&&&&x&&&&&x&x&&&&&x&x&&&&&&&x&&&&&&&&&&\\
    Malta 2018&&&&&&&&&x&&&x&x&&&&&&x&x&&&&x&&&x&&&&&x&&\\
    Czajkowski 2017&&&&&&&x&x&x&&x&&&x&&&&&&&&&&x&&x&x&&&&&x&&x\\
    Shanmugam 2016&&&x&x&x&&&&&x&&&&x&&x&x&&&&&&&x&&&&&&&&&&\\
    Oliveira 2016&&&&&&x&&&x&x&x&&&&x&x&&&x&x&&x&x&x&&&&&&&x&x&x&x\\
    Halevy 2016&&&x&x&x&&&x&&x&x&x&x&&x&&x&x&&x&&x&&x&&&&&&&x&&&\\
    Stillerman 2016*&&&&&&&&x&x&x&x&x&x&&x&x&x&&x&&x&&&x&&&x&&&&&x&&\\
    Nakandala 2015&&&&&&&&x&x&x&&&x&x&&&&&&x&&&&x&&&x&&&&&x&&\\
    Friddell 2014*&&&&&x&&&x&x&x&x&x&x&&x&&&&x&&x&&x&x&&&x&&&&&x&x&x\\
    Beaujardiere 2010&&&&&&&&x&x&x&x&x&&&&&&&&x&&&&x&&&x&&&&&x&x&\\
    Franklin 2005&&&&&x&&&&&x&x&&&x&&&&&&&&&&x&&&&&&&x&&&\\
    Hale 1998*&&&&&x&&&&x&x&&x&&&&&&&x&&x&&&x&&&&&&&&&&\\
    Absolute&1&4&11&6&14&2&1&11&11&22&19&14&13&9&9&10&11&6&11&10&7&5&5&25&7&9&10&2&5&5&11&10&7&5\\
    Relative&.04&$.16 $&$.44  $&$.24  $&$.56  $&$.08  $&$.04  $&$.44  $&$.44  $&$.88  $&$.76  $&$.56  $&$.52  $&$.36  $&$.36  $&$.40  $&$.44  $&$.24  $& $.44$&$.40   $&$.28  $&$.20  $&$.20  $&$1    $&$.28  $&$.36  $&$.40  $&$.08  $&$.20  $&$.20  $&$.44  $&$.40  $&$.28  $&$.20$\\
    
\end{talltblr}
\end{sidewaystable}
\normalsize
\endgroup
\newpage 

\end{document}

enter image description here