I am new to Latex and making tables using booktab.
I made a table with hierarchy in the x-axis such that I have 3 columns and each column further has 3 sub-columns. But, the table fails to fit within the width of the page as shown below
I tried many solutions such as tabu, adjustbox, resize box and tabular*, but they do not seem to fix the problem or I do not know the proper syntax.
The code that I used is attached below with resize box.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx,booktabs}
\usepackage{array}
\usepackage{graphicx}
\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{C}{>{$}c<{$}}
\newcolumntype{R}{>{$}r<{$}}
\newcommand{\nm}[1]{\textnormal{#1}}
\begin{document}
\begin{table} [h!]
\centering
\resizebox{\textwidth}{!} {%
\begin{tabular}{LCCCCCCCCC}
\toprule
\multicolumn{1}{l}{} &
\multicolumn{3}{c}{N N} &
\multicolumn{3}{c}{MM} &
\multicolumn{3}{c}{DW} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}
&
\multicolumn{1}{c}{column One} &
\multicolumn{1}{c}{column two} &
\multicolumn{1}{c}{column One+col2} &
\multicolumn{1}{c}{column One} &
\multicolumn{1}{c}{column Two} &
\multicolumn{1}{c}{column One+col2} &
\multicolumn{1}{c}{column One} &
\multicolumn{1}{c}{column two} &
\multicolumn{1}{c}{column One+col2} \\
\midrule
experiment1 & a & b & c & d \\
experiment2 & p & q & r & s \\
\midrule[\heavyrulewidth]
\bottomrule
\end{tabular}%
}
\caption{Description of the table}\label{beta}
\end{table}
\end{document}
After using the resize I get the following
Can anyone help me this? Thank You so much in advance.
\textwidth
, your (much too wide) table will fit. You can also re-create your table to be narrower.\usepackage[showframe]{geometry}
to see if your table with the\resizebox
is actually fitting in the margins.column
from the column headings. Alternatively you could rotate the table so that you have larger width to work with.