0

enter image description here

I am trying to create a table which merges some rows but also merges some rows vertically (with vertical text).

My code so far looks like this

\begin{table}[H]
\caption{title}
\centering
\begin{tabular}{|c|c|c|c|c| }
\toprule
\multirow{1}{*}{\textbf{}}&  & \textit{\textbf{a}} & \textit{\textbf{b}} & \textit{\textbf{c}}   \\

\cmidrule{2-5}
\multirow{7}{*}[-0.4ex]{\rotatebox{90}{\textbf{merged over 3}}} 
& \textit{\textbf{These two should be merged}}   &  &  &    \\
\cmidrule{2-5}
& \textit{\textbf{These two should be merged}}  &  & &     \\
\cmidrule{2-5}
& \textit{\textbf{}}  &  &  &     \\
\cmidrule{2-5}

& \textit{\textbf{1}} &  &  &    \\
\cmidrule{2-5}
& \textit{\textbf{2}}  &  &  &      \\
\cmidrule{2-5}
& \textit{\textbf{3}}  &  &  &    \\
\bottomrule
\end{tabular}
\end{table}
1

Do you mean like the following? Please note that you shouldn't use vertical lines together with the rules provided by booktabs.

\documentclass[]{article}

\usepackage{graphics}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
\begin{tabular}{ccccc}
\toprule
\multirow{1}{*}{\textbf{}}&  & \textit{\textbf{a}} & \textit{\textbf{b}} & \textit{\textbf{c}}   \\

\cmidrule{2-5}
\multirow{7}{*}[-0.4ex]{\rotatebox{90}{\textbf{merged over 3}}} 
&    &  &  &    \\
\cmidrule{3-5}
  &
  \multirow{-2}{*}[\dimexpr\cmidrulesep+.5\cmidrulewidth\relax]{\textit{\textbf{These two should be merged}}}  &  & &     \\
\cmidrule{2-5}
& \textit{\textbf{}}  &  &  &     \\
\cmidrule{2-5}

& \textit{\textbf{1}} &  &  &    \\
\cmidrule{2-5}
& \textit{\textbf{2}}  &  &  &      \\
\cmidrule{2-5}
& \textit{\textbf{3}}  &  &  &    \\
\bottomrule
\end{tabular}
\end{document}

enter image description here

4
  • thanks for the reply. I would also like the "merged over 3" to be only splut over the first three lines and then for another box to be vertically merged over the bottom three lines. I require the table to have vertical lines also. Should I therefore be using another package ? thanks – Bat Jan 30 '20 at 18:14
  • sorry just to clarify the first colum should two vertical boxes each split over three rows. – Bat Jan 30 '20 at 18:19
  • @Bat you can only rotate the contents of the first column if your contents are small enough to fit into them, \multirow doesn't vertically enlarge the rows it's used on. If you need vertical lines you could either reduce the vertical separation around the rules provided by booktabs, or just use LaTeX's \hline and \cline macros instead. I think you can use two \multirow instances on the first column yourself, after all there are already two usage examples contained in my answer. – Skillmon Jan 30 '20 at 18:35
  • ah ok perfect thanks for clarfying that for me ! I will give the table another try with your suggestions. Many thanks for your help – Bat Jan 30 '20 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.