Ich bin neu bei Latex und erstelle Tabellen mit Booktab.
Ich habe eine Tabelle mit Hierarchie auf der X-Achse erstellt, sodass ich 3 Spalten habe und jede Spalte zusätzlich 3 Unterspalten hat. Die Tabelle passt jedoch nicht in die Breite der Seite, wie unten gezeigt
Ich habe viele Lösungen wie Tabu, Adjustbox, Resize Box und Tabular* ausprobiert, aber sie scheinen das Problem nicht zu beheben oder ich kenne die richtige Syntax nicht.
Der von mir verwendete Code ist unten mit dem Feld zur Größenänderung angehängt.
\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}
Nach der Größenänderung erhalte ich Folgendes
Kann mir jemand dabei helfen? Vielen Dank im Voraus.
Antwort1
Ein Beispiel für eine Lösung ohne Verwendung fortgeschrittener Methoden wie Rotation. Es fasst meine Vorschläge aus den Kommentaren zusammen. Die dicke Linie zeigt die Breite des Textes und unterscheidet sich vom ursprünglichen (nicht skalierten) Beispiel. Es gibt einige Änderungen im Text, aber wahrscheinlich ohne Verlust des Verständnisses.
\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}
Antwort2
Noch eine andere Lösung
\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}