I would like to create the same table in latex:
The first two and last two columns consist of a few words, but the two in the middle are made up of longer text. In my code, I chose landscape orientation for the table. Here is my code:
\documentclass[]{article}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{lipsum}
\usepackage{booktabs}
\newcolumntype{s}{>{\hsize=.15\hsize}X}
\newcommand{\heading}[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{sidewaystable}
\caption{Metrics}
\begin{tabularx}{\textheight}{s|s|X||X|s|s}
\multirow{8}{*}{\rotatebox[origin=c]{90}{Connectivity 1}} & \multirow{4}{*}{\rotatebox[origin=c]{90}{\shortstack[c]{Type of \\connection 1}}}
& blabal blabal blabalbl abalblabal blabalbla balblaba lblabalbl abalbl abalbla balblabal & blabal blabal blabalbl abalblabal blabalbla balblaba lblabalbl abalbl abalbla balblabal
& \multirow{4}{*}{\rotatebox[origin=c]{-90}{\shortstack[c]{Type of \\connection 2}}}
& \multirow{8}{*}{\rotatebox[origin=c]{-90}{Connectivity 2}} \\
& & 2 & 2.1 & & \\
& & 3 & 3.1 & & \\
& & 4 & 4.1 & & \\
\cmidrule{2-3}\cmidrule{4-5}
& \multirow{4}{*}{\rotatebox[origin=c]{90}{\shortstack[c]{Privileges \\ and rights 1}}}
& 5 & 5.1
& \multirow{4}{*}{\rotatebox[origin=c]{-90}{\shortstack[c]{Privileges \\ and rights 2}}} & \\
& & 6 & 6.1 & & \\
& & 7 & 7.1 & & \\
& & 8 & 8.1 & & \\
\cmidrule{2-5}
\end{tabularx}
\end{sidewaystable}
\end{document}
And the output:
There are several issues that I want to correct:
- Despite the
origin=c
use in\rotatebox
, it seems that the rotated texts are not centered - I must not use the midrule properly
- Maybe there is a better way to define column types
Thank's for your help.
booktabs
package, such as\midrule
are intended to be used without vertical lines, hence the small gaps around intersections that you observe.\multirow
. The first argument of\multirow
is the number of lines of text, the\multirow
cell spans, not the number of table rows. Thus, use\multirow{10}{*}{\rotatebox[origin=c]{90}{Connectivity 1}}
instead of\multirow{8}{*}{\rotatebox[origin=c]{90}{Connectivity 1}}
and adapt the other\multirow
commands accordingly.s
with a simplec
column type. If you plan on usings
, which is basically just a narrower version ofX
, you must make sure that the sum of\hsize
coefficient equals the number ofX
or derived column types in your table. (Currently, you use 6X
or similar type columns, but the coefficients only add up to 2.6) Using regularc
type columns instead ofs
would be alot easier here.