1

I am trying to build a table that has the two columns evenly distributed (yes/no columns):

enter image description here

This is what I have achieved so far with the help of the community, thereby using the following code:

\usepackage{ragged2e}
\usepackage{makecell}
\usepackage{xcolor}
\usepackage{tabularray}
\newcommand\TB{\textbullet}

\begin{document}
\begin{center}
\begin{tblr}{hline{1,4} = {2-4}{1pt},
             hline{2} = {3-4}{solid},
             hline{3} = 0.6pt,  
             hline{4-17}=solid, 
             vline{1} = {3-10}{solid},
             vline{2-5},
             colspec = {>{\centering\arraybackslash}p{0.5cm}
             >{\centering\arraybackslash}p{3cm}{c}
             >{\centering\arraybackslash}p{7cm}{c} *{2}{c}
             },
             cell{3-15}{1} = {cmd=\rotcell[cc]},
             row{1} = {font=\bfseries},
             row{2} = {font=\footnotesize},
             vspan = even
            }
    &   \SetCell[r=2]{f, font=\bfseries}    Criteria
        &   \SetCell[c=2]{c}   Migration? & \\
    &   &   Yes & No \\
\SetCell[r=2]{c}    \footnotesize ...                              
    &   \multicolumn{1}{|m|}{C1}
        & \TB   & \TB \\
    &   \multicolumn{1}{|m|}{C2}
        & \TB   & \TB \\
\SetCell[r=2]{c}    \footnotesize ...
    &   \multicolumn{1}{|m|}{C3}
        & \TB   & \TB \\
    &   \multicolumn{1}{|m|}{C4}
        & \TB   & \TB \\
\SetCell[r=2]{c}    \footnotesize ...
    &   \multicolumn{1}{|m|}{C5}
        & \TB   & \TB \\
    &   \multicolumn{1}{|m|}{C6}
        & \TB   & \TB \\
\end{tblr}
\captionof{table}{Whatever}
\label{tab:whatever}
    \end{center}
\end{document}

Any advice how I can make the space of the two cells below the multicolumn "Migration?" (yes/no cells) to be 50% each of the total width of the "Migration?"-column?

Many thanks in advance!

2
  • 1
    Specify the option hspan=even in the argument of \begin{tblr}
    – marv
    Apr 4, 2022 at 19:47
  • @marv thanks for the response. Unfortunately, this does not work for me.
    – bpmler
    Apr 4, 2022 at 20:48

1 Answer 1

3
  • you provide uncomplete code fragment, you should correct them that will be compilable as it is
  • you have a mix of "classic" and tabularray way of specification
  • bear in mind that recent tabularray version (2022A) remove support to "classic" able specification as is multicolumn
  • all commands multicolumn in your code fragment are superfluous
  • you specify more columns as they are used in table. Note: tabularray require that in each row should be all ampersands as is needed regarding to specified columns (in your case three in each row)
  • corrected code for your table in form of MWE, is:
\documentclass{article}
\usepackage{caption}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{xcolor}
\usepackage{tabularray}
\newcommand\TB{\textbullet}

\begin{document}
\begin{tblr}{hline{1} = {2-4}{1pt},
             hline{2} = {2-4}{solid},
             hline{3,Z} = 1pt,
             hline{4-Y},
             vline{1}   = {3-10}{solid},
             vline{2-5},
             colspec  = {Q[c, font=\footnotesize] Q[c,30mm] Q[c,30mm] Q[c,30mm]},
             cell{3-15}{1} = {cmd=\rotcell[cc]},
             row{1} = {font=\bfseries},
             }
    &   \SetCell[r=2]{f}    Criteria
        &  \SetCell[c=2]{c}   Migration?
                &               \\
    &   &   Yes &   No          \\
%
\SetCell[r=2]{c}    ...
    &   C1
        & \TB   & \TB   \\
    &  C2
        & \TB   & \TB \\
\SetCell[r=2]{c}    ...
    &   C3
        & \TB   & \TB \\
    &   C4
        & \TB   & \TB \\
\SetCell[r=2]{c}   ...
    &   C5
        & \TB   & \TB \\
    &   C6
        & \TB   & \TB \\
\end{tblr}
\captionof{table}{Whatever}
\label{tab:whatever}
\end{document}

enter image description here

If width of columns are not as you wish, please correct them in column specifications accordingly. Above MWE is tesed by tabularray version 2022A.

Edit: In cases, when natural width of the rotated text is wider than height of spanned columns, you need:

  • specify length or rotated text
  • add option vspan =even to table preamble
  • in such cases the table preambles are:
    \begin{center}
    \settowidth\rotheadsize{\theadfont <Widest head text>}
\begin{tblr}{hline{1} = {2-4}{1pt},
             hline{2} = {2-4}{solid},
             hline{3,Z} = 1pt,
             hline{4-Y},
             vline{1}   = {3-10}{solid},
             vline{2-5},
             colspec  = {Q[c, font=\footnotesize] Q[c,30mm] Q[c,30mm] Q[c,30mm]},
             cell{3-15}{1} = {cmd=\rotcell[cc]},
             row{1} = {font=\bfseries},
             vspan = even
             }
% table body
\end{tblr}
\captionof{table}{Whatever}
\label{tab:whatever}
    \end{center}
\end{document}
  • it is not clear, why you put table in center environment and than for caption use \captionof{table}{ <caption text > }. Isn't simpler to use float table with placement option for example [!ht!?
1
  • That's it, thank you very much @zarko!! :)
    – bpmler
    Apr 5, 2022 at 8:42

You must log in to answer this question.

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