6

I have the following snippet

\documentclass{article}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{multirow}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{V}{>{\centering\arraybackslash}m{1.5cm}}
\newcommand{\verttext}[1]{\rotatebox{90}{\parbox{3cm}{\centering\textbf{#1}}}}
\renewcommand{\arraystretch}{1.5}

\begin{document}

\begin{table}[h]
    \centering
    \begin{tabularx}{\textwidth}{V | V | C | C |}
        \multicolumn{2}{c}{} & \multicolumn{2}{c}{Ausmass des Interesses am Unternehmen}                                   \\
        \cline{3-4}
        \multicolumn{1}{c}{} & \multicolumn{1}{c|}{}                                     & Gering            & Hoch        \\
        \cline{2-4}
        \multirow{2}{*}{\verttext{Ausmass der Macht}}
                             & \verttext{Hoch}                                           & Zufrieden stellen & Key Players \\
        \cline{2-4}
                             & \verttext{Gering}                                         & minimal betreuen  & informieren \\
        \cline{2-4}
    \end{tabularx}
\end{table}

\end{document}

which looks like this: enter image description here

as you can see, the "Ausmass der Macht" isnt centered (its two cell high) and shouldn't be wrapped. The two cells (Hoch + Gering) are high enough so the text shouldn't be wrapped. I already found a kinda similar question here: Vertical Text using multirow in the Table though I have no clue how to resolve that issue.

Thanks in advance :)

0

3 Answers 3

4

Try with tabularray. IMO, it is more easily to control the height of each row exactly:

\documentclass[border=5pt]{standalone}
\usepackage{tabularray}
\usepackage{graphicx}
\begin{document}
\begin{tblr}{
    colspec={*{4}{Q[c,m]}},
    hline{3-5}={2-5}{},
    hline{2}={3-4}{},
    vline{2}={3-5}{},
    vline{3-5}={2-5}{},
    row{1,2}={ht=.5cm},
    row{3,4}={ht=3cm},
    cell{1}{3}={c=2}{c},
    cell{3}{1}={r=2}{m,cmd={\rotatebox[origin=c]{90}}},
    cell{3,4}{2}={m,cmd={\rotatebox[origin=c]{90}}},
}
    &  &    Ausmass des Interesses am Unternehmen      &  \\
    &          & Gering            & Hoch        \\
    Ausmass der Macht  & Hoch     & Zufrieden stellen & Key Players  \\
      & Gering   & minimal betreuen  & informieren \\
\end{tblr}
\end{document}

abcde

3

I suggest defining a separate command for rotating labels that span more than one row of the table:

\newcommand{\verttextMR}[1]{%
  \rotatebox[origin=c]{90}{\textbf{#1}}%
}

and using it as follows:

\multirow{2}{*}[-2 mm]{\verttextMR{Ausmass der Macht}}

Unfortunately, the vertical offset -2 mm has to be adjusted manually (this is a small drawback of this solution). If you change \parbox{3cm} to \parbox{2cm}, this offset becomes 3 mm.

In addition, I propose introducing one more column type, for example:

\newcolumntype{Y}{>{\centering\arraybackslash}m{0.5cm}}

This gives you more flexibility when designing a suitable table.

Here is the full code:

\documentclass{article}
\usepackage{tabularx}
\usepackage{rotating}
\usepackage{multirow}

\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{V}{>{\centering\arraybackslash}m{1.5cm}}
\newcolumntype{Y}{>{\centering\arraybackslash}m{0.5cm}}

\newcommand{\verttext}[1]{%
    \rotatebox{90}{\parbox{2cm}{\centering\textbf{#1}}}
}

\newcommand{\verttextMR}[1]{%
  \rotatebox[origin=c]{90}{\textbf{#1}}%
}

\renewcommand{\arraystretch}{1.5}

\begin{document}

\begin{table}[h]
    \centering
    \begin{tabularx}{\textwidth}{Y | V | C | C |}
        \multicolumn{2}{c}{} & \multicolumn{2}{c}{Ausmass des Interesses am Unternehmen}                                   \\
        \cline{3-4}
        \multicolumn{1}{c}{} & \multicolumn{1}{c|}{}                                     & Gering            & Hoch        \\
        \cline{2-4}
        \multirow{2}{*}[-2 mm]{\verttextMR{Ausmass der Macht}}
                             & \verttext{Hoch}                                           & Zufrieden stellen & Key Players \\
        \cline{2-4}
                             & \verttext{Gering}                                         & minimal betreuen  & informieren \\
        \cline{2-4}
    \end{tabularx}
\end{table}

\end{document}

enter image description here

3

Here is a way to create that table with {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\renewcommand{\arraystretch}{1.4}

\begin{document}

\begin{table}[h]
\centering
\begin{NiceTabular} [first-col,first-row,hvlines,corners=NW] % NW = north-west
  { >{\rotate[c]} c w{c}{3cm} w{c}{3cm} }
      &          & \multicolumn{2}{c}{Ausmass des Interesses am Unternehmen} \\
      &          & Gering            & Hoch        \\
\Block{2-1}{\rotate Ausmass der Macht}
      & Hoch     & Zufrieden stellen & Key Players \rule[-9mm]{0pt}{2cm} \\
      & Gering   & minimal betreuen  & informieren \rule[-9mm]{0pt}{2cm} \\
\end{NiceTabular}
\end{table}

\end{document}

Output of the above code

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.