3

I want this my latex table to have an additional column with a rotated-side header. I tried these answers but can not make headway.

\documentclass{article}

\usepackage{booktabs, multirow} \usepackage{graphicx, float}

\begin{document} \begin{table}[H] \centering \footnotesize \label{tabb111} % Please add the following required packages to your document preamble: % \usepackage{multirow} % \usepackage{graphicx} \resizebox{\textwidth}{6.25em}{% \begin{tabular}{|l|c|c|c|c|c|c|c|c|c|} \hline \multicolumn{1}{|c|}{\multirow{2}{}{}} & \multicolumn{3}{c|}{\textbf{Min. RMSE}} & \multicolumn{3}{c|}{\textbf{Rank}} & \multicolumn{3}{c|}{\textbf{Block Length}} \ \cline{2-10} \multicolumn{1}{|c|}{} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} \ \hline \textbf{NBB} & 1.57 & 0.97 & 1.43 & 5 & 5.0 & 5 & 6 & 4 & 3 \ \hline \textbf{MBB1} & 1.57 & 0.9 & 1.26 & 3 & 3.5 & 4 & 2 & 2 & 4 \ \hline \textbf{MBB2} & 1.57 & 0.9 & 1.26 & 3 & 3.5 & 3 & 2 & 2 & 6 \ \hline \textbf{MBB3} & 1.57 & 0.89 & 1.21 & 3 & 2.0 & 2 & 2 & 9 & 6 \ \hline \textbf{CBB} & \textbf{1.44} & \textbf{0.19} & \textbf{0.09} & 1 & 1.0 & 1 & 2 & 4 & 8 \ \hline \end{tabular}% } \resizebox{\textwidth}{6.25em}{% \begin{tabular}{|l|c|c|c|c|c|c|c|c|c|} \hline \multicolumn{1}{|c|}{\multirow{2}{}{.}} & \multicolumn{3}{c|}{\textbf{Value}} & \multicolumn{3}{c|}{\textbf{Rank}} & \multicolumn{3}{c|}{\textbf{Block Length}} \ \cline{2-10} \multicolumn{1}{|c|}{} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} \ \hline \textbf{NBB} & 4.72 & 2.92 & 4.28 & 5 & 5.0 & 5 & 6 & 4 & 3 \ \hline \textbf{MBB1} & 4.71 & 2.69 & 3.78 & 3 & 3.5 & 4 & 2 & 2 & 4 \ \hline \textbf{MBB2} & 4.71 & 2.69 & 3.77 & 3 & 3.5 & 3 & 2 & 2 & 6 \ \hline \textbf{MBB3} & 4.71 & 2.67 & 3.64 & 3 & 2.0 & 2 & 2 & 9 & 6 \ \hline \textbf{CBB} & \textbf{2.49} & \textbf{0.02} & \textbf{0.8} & 1 & 1.0 & 1 & 7 & 7 & 8 \ \hline \end{tabular}% } \end{table} \end{document}

Just like this

Bernard
  • 271,350

2 Answers2

4

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document} \begin{table}[h] \centering \footnotesize \begin{NiceTabular}{l>{\bfseries}lccccccccc}[hvlines] \RowStyle{\bfseries} \Block{*-1}{\rotate M=121} & \Block{2-1}{} & \Block{1-3}{Min. RMSE} &&& \Block{1-3}{Rank} &&& \Block{1-3}{Block Length} \ & & $\phi = 0.8$ & $\phi = 0.9$ & $\phi = 0.95$ & $\phi = 0.8$ & $\phi = 0.9$ & $\phi = 0.95$ & $\phi = 0.8$ & $\phi = 0.9$& $\phi = 0.95$ \ & NBB & 1.57 & 0.97 & 1.43 & 5 & 5.0 & 5 & 6 & 4 & 3 \ & MBB1 & 1.57 & 0.9 & 1.26 & 3 & 3.5 & 4 & 2 & 2 & 4 \ & MBB2 & 1.57 & 0.9 & 1.26 & 3 & 3.5 & 3 & 2 & 2 & 6 \ & MBB3 & 1.57 & 0.89 & 1.21 & 3 & 2.0 & 2 & 2 & 9 & 6 \ & CBB & \textbf{1.44} & \textbf{0.19} & \textbf{0.09} & 1 & 1.0 & 1 & 2 & 4 & 8 \ \end{NiceTabular} \end{table} \end{document}

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

Output of the above code

F. Pantigny
  • 40,250
1

Using rotatebox from graphicx package.

\documentclass{article}

\usepackage{booktabs, multirow} \usepackage{graphicx, float}

\begin{document} \begin{table}[H] \centering \footnotesize \label{tabb111} % Please add the following required packages to your document preamble: % \usepackage{multirow} % \usepackage{graphicx} \resizebox{\textwidth}{6.25em}{% \begin{tabular}{|c|l|c|c|c|c|c|c|c|c|c|} \hline \multirow{7}{}{\rotatebox[origin=c]{90}{\textbf{n=121}}} & \multicolumn{1}{|c|}{\multirow{2}{}{}} & \multicolumn{3}{c|}{\textbf{Min. RMSE}} & \multicolumn{3}{c|}{\textbf{Rank}} & \multicolumn{3}{c|}{\textbf{Block Length}} \ \cline{2-11} & \multicolumn{1}{|c|}{} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} \ \cline{2-11} & \textbf{NBB} & 1.57 & 0.97 & 1.43 & 5 & 5.0 & 5 & 6 & 4 & 3 \ \cline{2-11} & \textbf{MBB1} & 1.57 & 0.9 & 1.26 & 3 & 3.5 & 4 & 2 & 2 & 4 \ \cline{2-11} & \textbf{MBB2} & 1.57 & 0.9 & 1.26 & 3 & 3.5 & 3 & 2 & 2 & 6 \ \cline{2-11} & \textbf{MBB3} & 1.57 & 0.89 & 1.21 & 3 & 2.0 & 2 & 2 & 9 & 6 \ \cline{2-11} & \textbf{CBB} & \textbf{1.44} & \textbf{0.19} & \textbf{0.09} & 1 & 1.0 & 1 & 2 & 4 & 8 \ \hline \end{tabular}% } \resizebox{\textwidth}{6.25em}{% \begin{tabular}{|c|l|c|c|c|c|c|c|c|c|c|} \hline \multirow{7}{}{\rotatebox[origin=c]{90}{\textbf{n=1200}}} & \multicolumn{1}{|c|}{\multirow{2}{}{.}} & \multicolumn{3}{c|}{\textbf{Value}} & \multicolumn{3}{c|}{\textbf{Rank}} & \multicolumn{3}{c|}{\textbf{Block Length}} \ \cline{2-11} & \multicolumn{1}{|c|}{} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} & \multicolumn{1}{l|}{$\phi = 0.8$} & \multicolumn{1}{l|}{$\phi = 0.9$} & \multicolumn{1}{l|}{$\phi = 0.95$} \ \cline{2-11} & \textbf{NBB} & 4.72 & 2.92 & 4.28 & 5 & 5.0 & 5 & 6 & 4 & 3 \ \cline{2-11} & \textbf{MBB1} & 4.71 & 2.69 & 3.78 & 3 & 3.5 & 4 & 2 & 2 & 4 \ \cline{2-11} & \textbf{MBB2} & 4.71 & 2.69 & 3.77 & 3 & 3.5 & 3 & 2 & 2 & 6 \ \cline{2-11} & \textbf{MBB3} & 4.71 & 2.67 & 3.64 & 3 & 2.0 & 2 & 2 & 9 & 6 \ \cline{2-11} & \textbf{CBB} & \textbf{2.49} & \textbf{0.02} & \textbf{0.8} & 1 & 1.0 & 1 & 7 & 7 & 8 \ \hline \end{tabular}% } \end{table} \end{document}

rotatebox

Imran
  • 3,096