I want to create a table with multicolumns where numbers are vertically aligned at the decimal sign, so I used the dcolumn package. Some of my numbers have negative signs. For every second column my code perfectly works but not for the other columns. Can anybody figure out what I did wrong? Did I place the D{.}{.}{-1}
commands at the right place? My \textwidth
commands seem to look a bit complicated but the table I posted here is just a small part of a very big multicolumn table where I need to specify the width of each column in order to get it fit to one page.
\documentclass[11pt,a4paper,twoside]{article}
\usepackage{dcolumn}
\usepackage{booktabs}
\begin{document}
\begin{table}[!htp]
\label{tab:troistorrents_differences}
\begin{tabularx}{\textwidth}
{p{0.3\textwidth}
p{0.05\textwidth}D{.}{.}{-1}
p{0.05\textwidth}D{.}{.}{-1}
p{0.05\textwidth}D{.}{.}{-1}
p{0.05\textwidth}D{.}{.}{-1}
p{0.05\textwidth}D{.}{.}{-1}
p{0.05\textwidth}D{.}{.}{-1}
}
\addlinespace \toprule[0.5pt] \addlinespace
\multicolumn{1}{l}{\textbf{Position}} & \multicolumn{6}{c}{\textbf{Model1}}\\
& \multicolumn{2}{l}{82m Mast} & \multicolumn{2}{l}{SODAR 1}& \multicolumn{2}{l}{SODAR 2} \\
& m/s & \% & m/s & \% & m/s & \% \\
\addlinespace \midrule \addlinespace
Mast 1 & 0.0 & 0.0 & -0.3 & -7.4 & -0.3 & -8.4 \\
SODAR 1 & 0.4 & 7.8 & 0.0 & 0.0 & 0.1 & 1.3 \\
SODAR 2 & 0.3 & 7.8 & 0.0 & 0.0 & 0.0 & 0.0 \\
Mast 2 & -0.1 & -2.5 & -0.4 & -10.8 & -0.5 & -12.5 \\
\addlinespace \bottomrule[0.5pt] \addlinespace
\end{tabularx}
\end{table}
\end{document}
Aucun commentaire:
Enregistrer un commentaire