4

Code

Consider the following example:

\DocumentMetadata{}

\documentclass{article}

\usepackage[margin = 1.8cm]{geometry} % to avoid `overfull \hbox' \usepackage{tabularray}

\begin{document}

\begin{tblr}{ hline{1} = {2-7}{solid}, hline{2-Z} = {solid}, vline{1} = {2-7}{solid}, vline{2-Z} = {solid} } & \SetCell{c, m, 1.75cm} Utilstræk-keligt & \SetCell{c, m, 1.75cm} Tilstræk-keligt & \SetCell{c, m, 1.75cm} Jævnt & \SetCell{c, m, 1.75cm} Godt & \SetCell{c, m, 1.75cm} Frem-ragende \ \SetCell[r = 1]{h, m, 5.9cm} Samarbejdet har fungeret og eventuelle problemer er blevet løst & & & & & \ \SetCell[r = 1]{h, m, 5.9cm} Tiden er blevet disponeret fornuftigt & & & & & \ \end{tblr}%

\end{document}

The tabularray package is fairly new to me.

Question

Can the code somehow be improved? (I know that this is a subjective question.)

  • 2
    Unrelated to your code, but your table would look more professional without all the vertical lines. – samcarter_is_at_topanswers.xyz Feb 28 '24 at 13:41
  • 1
    @samcarter_is_at_topanswers.xyz I totally agree; the problem is that some of my students have a really head time focusing, so marked cells for everything helps them to some extend. Thanks for you suggestion, none the less. – Svend Tveskæg Feb 28 '24 at 16:22

2 Answers2

5
  • Instead of specifying the alignment for each cell individually, you could do this globally in the table settings

  • Instead of hard coding the width of the cells, I would let tabularray do this for you. If you use X columns, tabularray will automatically distribute them evenly and with something like X[4] you can make the first column wider than the other columns.


\DocumentMetadata{}

\documentclass{article}

\usepackage[margin = 1.8cm]{geometry} % to avoid `overfull \hbox' \usepackage{tabularray}

\begin{document}

\begin{tblr}{ cells={m,c}, colspec={X[4,l,h]XXXXX}, hline{1} = {2-7}{solid}, hline{2-Z} = {solid}, vline{1} = {2-7}{solid}, vline{2-Z} = {solid} } & Utilstræk-keligt & Tilstræk-keligt & Jævnt & Godt & Frem-ragende \ Samarbejdet har fungeret og eventuelle problemer er blevet løst & & & & & \ Tiden er blevet disponeret fornuftigt & & & & & \ \end{tblr}%

\end{document}

enter image description here

5

For information, here is a way to create that table with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage[margin = 1.8cm]{geometry} 
\usepackage{nicematrix}
\usepackage{varwidth}

\begin{document}

\begin{NiceTabular}{V[l]{7cm}*{5}{X[c]}}[hvlines,corners=NW,cell-space-limits=3pt] & Utilstræk-keligt & Tilstræk-keligt & Jævnt & Godt & Frem-ragende \ Samarbejdet har fungeret og eventuelle problemer er blevet løst \ Tiden er blevet disponeret fornuftigt \ \end{NiceTabular}

\end{document}

You need several compilations (because nicematrix uses PGF/TikZ nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250