Ajustar uma tabela à largura da página

Ajustar uma tabela à largura da página

Sou novo no Latex e faço tabelas usando o booktab.

Fiz uma tabela com hierarquia no eixo x de forma que tenho 3 colunas e cada coluna possui ainda 3 subcolunas. Porém, a tabela não cabe na largura da página, conforme mostrado abaixo

insira a descrição da imagem aqui

Tentei muitas soluções como tabu, Adjustbox, resize box e tabular*, mas elas não parecem resolver o problema ou não conheço a sintaxe correta.

O código que usei está anexado abaixo com a caixa de redimensionamento.

\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}

Depois de usar o redimensionamento, recebo o seguinte

insira a descrição da imagem aqui

Alguém pode me ajudar nisso? Muito obrigado antecipadamente.

Responder1

Um exemplo de solução sem utilizar métodos mais avançados, como a rotação. Ele resume minhas sugestões de comentários. A linha grossa mostra a largura do texto e separa de um exemplo original (não dimensionado). Existem algumas alterações no texto, mas provavelmente sem perda de compreensão.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx,booktabs}
\usepackage{array}
\usepackage{graphicx}

\oddsidemargin-1cm
\textwidth17cm
\def\COMP#1{\begin{tabular}{c}#1\end{tabular}}

\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}{\COMP{col.\\ One}} &
\multicolumn{1}{c}{\COMP{col.\\ two} }&
\multicolumn{1}{c}{\COMP{col.\\ One\\+col2}} &
\multicolumn{1}{c}{\COMP{col.\\ One}} &
\multicolumn{1}{c}{\COMP{col.\\ Two}} &
\multicolumn{1}{c}{\COMP{col.\\ One\\+col2}} &
\multicolumn{1}{c}{\COMP{col.\\ One}} &
\multicolumn{1}{c}{\COMP{col.\\ two}} &
\multicolumn{1}{c}{\COMP{col.\\ One\\+col2}}     \\
\midrule

ex1 & a  & b & c & d \\
ex2 & p & q & r & s \\ 

\midrule[\heavyrulewidth]
\bottomrule

\end{tabular}%
%}
\caption{Description of the table}\label{beta}
\end{table}

\noindent\rule{\textwidth}{1mm}

\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}

insira a descrição da imagem aqui

Responder2

Mais uma solução

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx,booktabs}
\usepackage{array}
        \newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}           
\usepackage{graphicx}
\newcommand{\nm}[1]{\textnormal{#1}}

\begin{document}

\begin{table} [h!]
\centering
\resizebox{\textwidth}{!} {%
\begin{tabular}{@{\hspace{1cm}}cc cc cc cc c}
\toprule

\multicolumn{3}{c}{N N}    &
\multicolumn{3}{c}{MM}    &
\multicolumn{3}{c}{DW}    \\ 
\cmidrule(lr){1-3}
\cmidrule(lr){4-6}
\cmidrule(lr){7-9}


\multicolumn{1}{C{1.5cm}}{column One} &
\multicolumn{1}{C{1.5cm}}{column two} &
\multicolumn{1}{C{1.5cm}}{column One+col2} &
\multicolumn{1}{C{1.5cm}}{column One} &
\multicolumn{1}{C{1.5cm}}{column Two} &
\multicolumn{1}{C{1.5cm}}{column One+col2} &
\multicolumn{1}{C{1.5cm}}{column One} &
\multicolumn{1}{C{1.5cm}}{column two} &
\multicolumn{1}{C{1.5cm}}{column One+col2}     \\
\midrule

\multicolumn{9}{l}{Experiment 1}\\ \cmidrule{1-2}
 a  & b & c & d \\
\multicolumn{9}{l}{Experiment 2} \\ \cmidrule{1-2}
  p & q & r & s \\ 

\midrule[\heavyrulewidth]
\bottomrule

\end{tabular}%
}
\caption{Description of the table}\label{beta}
\end{table}

\end{document}

informação relacionada