spaltentypen innerhalb einer tabelle anpassen

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: spaltentypen innerhalb einer tabelle anpassen

spaltentypen innerhalb einer tabelle anpassen

von Lucas_V » Mo 10. Nov 2025, 19:07

Hallo zusammen,

ich habe eine ziemlich große und verschachtelte Tabelle und habe es noch nicht geschafft, sie richtig zu formatieren. So sieht sie im Moment aus:

\documentclass[hidelinks, 12pt, oneside, headinclude=true]{scrreprt}

\usepackage{array}
\usepackage{tabularx}
	\newcolumntype{Z}{>{\centering\arraybackslash}X} % centered column with automatic width
	\newcolumntype{q}[1]{>{\raggedright\arraybackslash}p{#1}} % left-aligned column with fixed width
	\newcolumntype{n}[1]{>{\raggedright\arraybackslash}m{#1}} % left-aligned column with fixed width, vertically centered
	\renewcommand\tabularxcolumn[1]{m{#1}}
	\newcommand\T{\rule[2ex]{0pt}{1ex}} % extra distance before a table row
	\newcommand\B{\rule[-2ex]{0pt}{1ex}} % extra distance after a table row
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{adjustbox}
\usepackage{siunitx}

\begin{document}

\begin{sidewaystable}[h]
\footnotesize
\centering
\begin{threeparttable}
\caption{overview of the carried out mechanical tests for the development of DHCLT}
\label{tab:tests-overview}
\begin{tabularx}{\textheight}{n{0.8cm} n{1.8cm} n{1.1cm} n{2cm} ZZZZZZZZZZZZZZ}
\toprule
\multicolumn{4}{l}{\textbf{DHCLT variant}} & \multicolumn{4}{l}{\textbf{compression shear}} & \multicolumn{5}{l}{\textbf{bending shear tests}} & \multicolumn{5}{l}{\textbf{bending tests}} \\
 & & & & \multicolumn{4}{l}{\textbf{tests}} & & & & & & & & & & \\
\midrule
no. & side view & cross section & \multirow{2}{2.1cm}{material cross layer / middle layer} & $ w_c $ & $ \delta_c $ \tnote{a} & $ w_m $ & $ \delta_m $ & $ w_c $ & $ \delta_c $ & $ l_s $ \tnote{b} & $ w_m $ & $ \delta_m $ & $ w_c $ & $ \delta_c $ & $ l_s $ \tnote{b} & $ w_m $ & $ \delta_m $ \\
 &  &  &  & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{mm}] & [\unit{\percent}] \\
\midrule
S-0 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/s-0-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/s-0-cs.png}} & spruce / spruce & 115 & \qty{100}{\percent} & 115~/ 230 & \qty{100}{\percent} & 120 & \qty{100}{\percent} & - & 100 & \qty{100}{\percent} & 185 & \qty{100}{\percent} & - & 185 & \qty{100}{\percent} \\
\T B-0 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-0-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce & 120 & \qty{100}{\percent} & 115~/ 230 & \qty{100}{\percent} & 120 & \qty{100}{\percent} & - & 100 & \qty{100}{\percent} & 120 & \qty{100}{\percent} & - & 185 & \qty{100}{\percent} \\
\T B-1 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-1-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce & 120 & \qty{50}{\percent} & 115~/ 230 & \qty{100}{\percent} & 120 & \qty{53}{\percent} & - & 100 & \qty{100}{\percent} & 120 & \qty{50}{\percent} & - & 185 & \qty{100}{\percent} \\
\T B-2 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-2-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce & 80 & \qty{50}{\percent} & 115~/ 230 & \qty{100}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T B-3 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-3-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce & 40 & \qty{50}{\percent} & 115~/ 230 & \qty{100}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T B-4 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-4-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce & 80 & \qty{25}{\percent} & 115~/ 230 & \qty{100}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T B-5 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-1-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-5-cs.png}} & beech / spruce & 120 & \qty{50}{\percent} & 115 & \qty{50}{\percent} & 120 & \qty{53}{\percent} & - & 100 & \qty{50}{\percent} &  &  &  &  &  \\
\T B-6 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-2-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-5-cs.png}} & beech / spruce & 80 & \qty{50}{\percent} & 115 & \qty{50}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T B-7 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-3-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-5-cs.png}} & beech / spruce & 40 & \qty{50}{\percent} & 115 & \qty{50}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T B-8 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-4-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-5-cs.png}} & beech / spruce & 80 & \qty{25}{\percent} & 115 & \qty{50}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T B-9 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-1-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce &  &  &  &  & 120 & \qty{47}{\percent} \tnote{c} & - & 100 & \qty{50}{\percent} &  &  &  &  &  \\
\T B-10 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-1-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & beech / spruce &  &  &  &  & 120 & \qty{54}{\percent} & 314 & 100 & \qty{100}{\percent} & 120 & \qty{52}{\percent} & 356 & 185 & \qty{100}{\percent} \\
\bottomrule
\end{tabularx}
\end{threeparttable}
\end{sidewaystable}

\end{document}

Screenshot 2025-11-10 185429.png
So möchte ich die Ausrichtung der Zellen mit den Daten haben, also vertikal zentriert. Aber die Zeilen mit den Überschriften stimmen noch nicht. Hier würde ich mir eine Ausrichtung oben wünschen, so wie in der folgenden Tabelle:

\begin{sidewaystable}[h]
\footnotesize
\centering
\begin{threeparttable}
\caption*{\ref{tab:tests-overview}: (continued)}
\begin{tabularx}{\textheight}{q{0.8cm} q{1.8cm} q{1.4cm} q{2cm} ZZZZZZZZZZZZZZ}
\toprule
\multicolumn{4}{l}{\textbf{DHCLT variant}} & \multicolumn{4}{l}{\textbf{compression shear}} & \multicolumn{5}{l}{\textbf{bending shear tests}} & \multicolumn{5}{l}{\textbf{bending tests}} \\
 & & & & \multicolumn{4}{l}{\textbf{tests}} & & & & & & & & & & \\
\midrule
no. & side view & cross section & \multirow{2}{2.1cm}{material cross layer / middle layer} & $ w_c $ & $ \delta_c $ \tnote{a} & $ w_m $ & $ \delta_m $ & $ w_c $ & $ \delta_c $ & $ l_s $ \tnote{b} & $ w_m $ & $ \delta_m $ & $ w_c $ & $ \delta_c $ & $ l_s $ \tnote{b} & $ w_m $ & $ \delta_m $ \\
 &  &  &  & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{\percent}] & [\unit{mm}] & [\unit{mm}] & [\unit{\percent}] \\
\midrule
\T B-11 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-11-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-11-cs.png}} & beech / beech &  &  &  &  & 120 & \qty{53}{\percent} & - & 100 & \qty{50}{\percent} &  &  &  &  &  \\
\T B-12 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-12-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-11-cs.png}} & beech / beech &  &  &  &  & 40 & \qty{55}{\percent} & - & 100 & \qty{50}{\percent} &  &  &  &  &  \\
\T B-13 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-13-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-11-cs.png}} & beech / beech &  &  &  &  & 100 \tnote{d} & \qty{45}{\percent} & 314 & 100 & \qty{50}{\percent} & 120 & \qty{52}{\percent} & 356 & 100 & \qty{50}{\percent} \\
\T K-0 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-0-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & oak / spruce & 120 & \qty{100}{\percent} & 115~/ 230 & \qty{100}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T K-1 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-2-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-0-cs.png}} & oak / spruce & 80 & \qty{50}{\percent} & 115~/ 230 & \qty{100}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\T K-2 & \adjustbox{valign=m}{\includegraphics[width=1.8cm]{imgs/b-2-sv.png}} & \adjustbox{valign=m}{\includegraphics[width=1.1cm]{imgs/b-5-cs.png}} & oak / spruce & 80 & \qty{50}{\percent} & 115 & \qty{50}{\percent} &  &  &  &  &  &  &  &  &  &  \\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\item[] $ w_c = $ cross lamination width, $ \delta_c = $ cross layer density, $ w_m = $ middle lamination width, $ \delta_m = $ middle layer density, $ l_s = $ support densification length
\item[a] The cross layer density is determined by the lamination width and the spacing - the ratio of the total lamination widths and the specimen length may be different.
\item The support densification length is measured from the support axis.
\item[c] Specimen with variable cross layer density - the indicated value is the mean density over the whole specimen length.
\item[d] Laminations from veneer rest rolls - the actual widths varied significantly.
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}


Screenshot 2025-11-10 185516.png
Hier sind komischerweise auch die Überschriften in den hinteren Spalten vom Typ Z korrekt oben ausgerichtet, obwohl sie in der oberen Tabelle vom gleichen Typ Z sind... Aber die Darstellung der Daten in den ersten vier Spalten passt noch nicht.

Den Befehl \renewcommand\tabularxcolumn[1]{m{#1}} habe ich ehrlicherweise auch noch nicht verstanden. Mache ich da etwas falsch?

Ich bin für jede Hilfe dankbar.

Viele Grüße
Lucas

Nach oben