0

In the table below, I have tried to make my long texts, in the third row of the table, slanted by Werner's answer here:

\documentclass[border = 2mm]{standalone}
\usepackage{booktabs}
\usepackage{array}
\usepackage{graphicx}

\NewDocumentCommand{\rot}{O{45} O{1em} m}{\makebox[#2][l]{\rotatebox{#1}{#3}}}%

\begin{document}
\begin{tabular}{@{\extracolsep{6pt}}ccccc@{}} \toprule
Strategies&\multicolumn{4}{c}{Types}\ \cmidrule{1-1}\cmidrule{2-5}
&\multicolumn{2}{c}{Type A}&\multicolumn{2}{c}{Type B}\ \cmidrule{2-3}\cmidrule{4-5} &\rot{A long text here}&\rot{A very very very long text here}&\rot{A very very long text here}&\rot{A very very very very long text here}\ \cmidrule{2-3}\cmidrule{4-5} An strategy & 0 &1&2&3\ \bottomrule
\end{tabular} \end{document}

But, column setting do not adapt to the slanted setup leading to the result below:

enter image description here

Is there an automatic way to adjust the columns based on a slant value?

  • The long texts you want to typeset diagonally seem to have a number associated to them, namely 0, 1, 2, 3. Why not typeset the texts in the caption table instead? – egreg Oct 08 '22 at 07:35
  • @egreg: There is no such association, and those numbers are just mere fillers here. –  Oct 08 '22 at 07:39

1 Answers1

1

Adjusting the column width to the contents is the default. However, you are hiding the width of the slanted text by putting it in a \makebox. So you would have not to use a \makebox or give it an adequate optional width argument. Like: \rot[45][\width]{A very very very very long text here}

\documentclass[border = 2mm]{standalone}
\usepackage{booktabs}
\usepackage{array}
\usepackage{graphicx}

\NewDocumentCommand{\rot}{O{45} O{1em} m}{\makebox[#2][l]{\rotatebox{#1}{#3}}}%

\begin{document}
\begin{tabular}{@{\extracolsep{6pt}}ccccc@{}} \toprule
Strategies&\multicolumn{4}{c}{Types}\ \cmidrule{1-1}\cmidrule{2-5}
&\multicolumn{2}{c}{Type A}&\multicolumn{2}{c}{Type B}\ \cmidrule{2-3}\cmidrule{4-5} &\rot{A long text here}&\rot{A very very very long text here}&\rot{A very very long text here}&\rot[45][\width]{A very very very very long text here}\ \cmidrule{2-3}\cmidrule{4-5} An strategy & 0 &1&2&3\ \bottomrule
\end{tabular} \end{document}

enter image description here