I need help to create a multi-row and multi-column table in a same table.
The required table is given in the image below.
]1
multicolmultirowtables
I need help to create a multi-row and multi-column table in a same table.
The required table is given in the image below.
]1
Horizontal lines should be used to structure the content, but whitespace on the right place can do the same. Have a look at the table, it looks cleaner. Please note the little white space before/after the rules.
Package siunitx
helps us here to align the numbers at the decimal mark.
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
{\begin{tabular}{lcccS[table-format=2]S[table-format=2]S[table-format=2]}
\toprule
\multicolumn{2}{c}{Workload} & {Description} & {Input} & {Miss Ratio} & {MPKI} & {LPKI} \\
\midrule
& A & B & C & 1 & 2 & 3 \\
& D & E & F & 4 & 5 & 6 \\
group1 & G & H & I & 7 & 8 & 9 \\
& J & K & L & 10 & 11 & 12 \\
& M & N & O & 13 & 14 & 15 \\
& P & Q & R & 16 & 17 & 18 \\\addlinespace[1.3ex]
& S & T & U & 19 & 20 & 21 \\
& V & W & X & 22 & 23 & 24 \\
group2 & Y & Z & AA & 25 & 26 & 27 \\
& AB & AC & AD & 28 & 28 & 29 \\
& AE & AF & AG & 30 & 31 & 32 \\
& AH & AI & AJ & 33 & 34 & 35 \\\addlinespace[1.3ex]
group3 & AK & AL & AM & 36 & 37 & 38 \\
& AN & AO & AP & 39 & 40 & 41 \\
\bottomrule
\end{tabular}}
\end{document}
I am not quite sure i get the problem. I tried to construct a situation, but without succes. Right now i cannot reproduce the behaviour. Be aware, that multirow
always requires manual labor. Please note, that i used \midrule
s again for their better spacing.
Please consider the following
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{array}
\newcolumntype{L}{>{\raggedright\arraybackslash}p{2.5cm}}
\begin{document}
{\begin{tabular}{lLLLS[table-format=2]S[table-format=2]S[table-format=2]}
\toprule
\multicolumn{2}{c}{Workload} & {Description} & {Input} & {Miss Ratio} & {MPKI} & {LPKI} \\
\midrule \multirow{15}{*}{\rotatebox{90}{group1}} & Lions are pretty big & Every lock has its key & Canada is a country. & 1 & 2 & 3 \\
& some useful information here & E & F & 4 & 5 & 6 \\
& Why did the duck cross the road? & H & I & 7 & 8 & 9 \\
& There are footprints on your back & K & L & 10 & 11 & 12 \\
& Did the lion eat the zebra? & N & O & 13 & 14 & 15 \\
& There's a cat on the window sill & Q & R & 16 &
17 & 18 \\\midrule
& Lions are pretty big & Every lock has its key & Canada is a country. & 1 & 2 & 3 \\
& some useful information here & E & F & 4 & 5 & 6 \\
& Why did the duck cross the road? & H & I & 7 & 8 & 9 \\
group1 & There are footprints on your back & K & L & 10 & 11 & 12 \\
& Did the lion eat the zebra? & N & O & 13 & 14 & 15 \\
& There's a cat on the window sill & Q & R & 16 &
17 & 18 \\\midrule
\multirow{6}{*}{\rotatebox{90}{group2}} & S & T & U & 19 & 20 & 21 \\
& V & W & X & 22 & 23 & 24 \\
& Y & Z & AA & 25 & 26 & 27 \\
& AB & AC & AD & 28 & 28 & 29 \\
& AE & AF & AG & 30 & 31 & 32 \\
& AH & AI & AJ & 33 &
34 & 35 \\\midrule
\multirow{2}{*}{group3} & AK & AL & AM & 36 & 37 & 38 \\
& AN & AO & AP & 39 & 40 & 41 \\
\bottomrule
\end{tabular}}
\end{document}
Replace the p
column qualifier with m
. The first column doesn't require any multirow. Finally I suggest removing all vertical rules, and much less horizontal rules, replaced with \addlinespace
s:
\documentclass[12pt, twocolumn]{article}
\usepackage{booktabs}
\usepackage{array, multirow, caption}
\begin{document}
\begin{table}[ht]
\caption{Stories}\label{tab:scenarios}
\centering
\def\arraystretch{1.2}% 1 is the default, change whatever you need
\begin{tabular}{@{}cm{4.4cm}m{2.2cm}@{}}
\toprule
{\bfseries Story} & {\bfseries Description} & {\bfseries Properties} \\
\midrule\midrule
% item 1/2
{s1} & PAID Sample project assignment (err on the side of paying fairly for estimated completion time
& \multirow{4}{2.4cm}{Sample project assignment (err on the side of paying fairly}\\
\addlinespace
s2 & PAID Sample project assignment (err on the side of paying fairly for estimated completion time
& \\
\midrule
% item 3/4
s3 & PAID Sample project assignment (err on the side of paying fairly for estimated completion time
& \multirow{4}{2.4cm}{Sample project assignment (err on the side of paying fairly} \\
\addlinespace
s4 & PAID Sample project assignment (err on the side of paying fairly for estimated completion time
& \\
\midrule
% item 5/6
s5 & PAID Sample project assignment (err on the side of paying fairly for estimated completion time
& \multirow{4}{2.4cm}{Sample project assignment (err on the side of paying fairly}\\
%\cmidrule{1-2}
\addlinespace
s6 & PAID Sample project assignment (err on the side of paying fairly for estimated completion time
& \\
% Closing table
\midrule\bottomrule
\end{tabular}
\end{table}
\end{document}
Best Answer
tabularx
comes in handy for such big tables since it enables the table to occupy the total\linewidth
. You will need themultirow
package for these multi-line cells and thearray
package for defining new column types (C
andL
). The last three columns should be defined by specified width columnsC
orL
because they interfere with each other. At least one column should be specifiedX
to fill the remaining horizontal space.\renewcommand{\arraystretch}{1.3}
is used to give the table some vertical extension for readability. Finally, you may consider usingbooktabs
for more beauty.