我制作了一个表格,其中一行包含不同类型的数据。我希望它们沿着小数点的逗号对齐 - 正如我所想的那样S
。我该如何实现呢?
\documentclass{article}
\usepackage[table]{xcolor}
\definecolor{tum}{RGB}{55,113,200}
\usepackage{siunitx}
\sisetup{detect-all,
locale = DE,
range-phrase= -- ,
}
\usepackage{multirow}
\begin{document}
\begin{table}
\centering
\sffamily
\renewcommand*{\arraystretch}{1.4}
\rowcolors{2}{tum!5}{tum!13}
\begin{tabular}{%
>{\raggedright}p{5cm}
S[retain-explicit-plus]
l
S }
\rowcolor{tum}
\centering \textbf{\color{white}{Stoff}} & \multicolumn{3}{c}{\textbf{\color{white}{Toleranz (inkl. Messunsicherheit)}}}\\
Vitamine & \SI{+50}{\percent} & \multicolumn{2}{c}{\SI{-35}{\percent}} \\
Mineralstoffe & \SI{+45}{\percent} & \multicolumn{2}{c}{\SI{-35}{\percent}} \\
\cellcolor{tum!13} & \SI{< 10}{\gram} & pro 100 g: & \SI{\pm 2}{\gram} \\
\cellcolor{tum!13} & \SIrange{10}{40}{\gram} & pro 100 g: & \SI{\pm 20}{\percent} \\
\multirow{-3}{5cm}{Kohlenhydrate, Zucker, Eiweiß, Ballaststoffe} & \SI{> 40}{\gram} & pro 100 g: & \SI{\pm 8}{\gram} \\
\cellcolor{tum!5} & \SI{< 10}{\gram} & pro 100 g: & \SI{\pm 1,5}{\gram} \\
\cellcolor{tum!5} & \SIrange{10}{40}{\gram} & pro 100 g: & \SI{\pm 20}{\percent} \\
\multirow{-3}{5cm}{Fett} & \SI{> 40}{\gram} & pro 100 g: & \SI{\pm 8}{\gram} \\
& \SI{< 4}{\gram} & pro 100 g: & \SI{\pm 0,8}{\gram}\\
\cellcolor{tum!15}\multirow{-2}{5cm}{gesättigte FS, ein- und mehrfach unges. FS} & \SI{\geq 4}{\gram} & pro 100 g: & \SI{\pm 20}{\percent} \\
\cellcolor{tum!5} & \SI{< 0,5}{\gram} & pro 100 g: & \SI{\pm 0,15}{\gram} \\
\multirow{-2}{5cm}{Natrium} &\SI{< 4}{\gram} & pro 100 g: & \SI{\pm 20}{\percent} \\
& \SI{< 0,5}{\gram} & pro 100 g: & \SI{\pm 0,375}{\gram}\\
\cellcolor{tum!13} \multirow{-2}{5cm}{Kochsalz}& \SI{\geq 1,25}{\gram} & pro 100 g: & \SI{\pm 20}{\percent}\\
\end{tabular}
\end{table}
\end{document}
答案1
以下是您表格的两个不同版本。也许其中一个适合您的需求:
\documentclass{article}
\usepackage[table]{xcolor}
\definecolor{tum}{RGB}{55,113,200}
\usepackage{siunitx}
\sisetup{detect-all,
locale = DE,
range-phrase= -- ,
}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\sffamily
\renewcommand*{\arraystretch}{1.4}
\rowcolors{2}{tum!5}{tum!13}
\begin{tabular}{%
>{\raggedright}p{5cm}
r@{\,\,\,}
S[table-format=2.2]@{\,\,\,}
l
l
r@{\,\,\,}
S[table-format=2.3]@{\,}
l}
\rowcolor{tum}
\centering \textbf{\color{white}{Stoff}} & \multicolumn{7}{c}{\textbf{\color{white}{Toleranz (inkl. Messunsicherheit)}}}\\
Vitamine & \multicolumn{3}{c}{\SI{+50}{\percent}} & \multicolumn{4}{c}{\SI{-35}{\percent}} \\
Mineralstoffe & \multicolumn{3}{c}{\SI{+45}{\percent}} & \multicolumn{4}{c}{\SI{-35}{\percent}} \\
\cellcolor{tum!13} & $<$ & 10 & \si{\gram} & pro 100 g: & $\pm$ & 2 & \si{\gram} \\
\cellcolor{tum!13} & \multicolumn{2}{r}{\numrange{10}{40}} & \si{\gram} & pro 100 g: & $\pm$& 20 & \si{\percent} \\
\multirow{-3}{5cm}{Kohlenhydrate, Zucker, Eiweiß, Ballaststoffe} & $>$ & 40 & \si{\gram} & pro 100 g: & $\pm$& 8 & \si{\gram} \\
\cellcolor{tum!5} & $<$ & 10 & \si{\gram} & pro 100 g: & $\pm$ & 1,5 & \si{\gram} \\
\cellcolor{tum!5} & \multicolumn{2}{r}{\numrange{10}{40}} & \si{\gram} & pro 100 g: & $\pm$ & 20& \si{\percent} \\
\multirow{-3}{5cm}{Fett} & $>$ & 40& \si{\gram} & pro 100 g: & $\pm$ & 8 & \si{\gram} \\
& $<$ & 4& \si{\gram} & pro 100 g: & $\pm$ & 0,8& \si{\gram}\\
\cellcolor{tum!15}\multirow{-2}{5cm}{gesättigte FS, ein- und mehrfach unges. FS} & $\geq$ & 4 & \si{\gram} & pro 100 g: & $\pm$ & 20 & \si{\percent} \\
\cellcolor{tum!5} & $<$ & 0,5 & \si{\gram} & pro 100 g: & $\pm$ & 0,15 & \si{\gram} \\
\multirow{-2}{5cm}{Natrium} & $<$ & 4 & \si{\gram} & pro 100 g: & $\pm$ & 20 & \si{\percent} \\
& $<$ & 0,5 & \si{\gram} & pro 100 g: & $\pm$ & 0,375 & \si{\gram}\\
\cellcolor{tum!13} \multirow{-2}{5cm}{Kochsalz}& $\geq$ & 1,25 & \si{\gram} & pro 100 g: & $\pm$ & 20 & \si{\percent}\\
\end{tabular}
\end{table}
\begin{table}
\centering
\sffamily
\begin{tabular}{%
>{\raggedright\arraybackslash}p{3.5cm}
S[table-format=>2.2,retain-explicit-plus,table-space-text-post = \si{\percent},table-align-text-post = true]
S[table-format=-2.3,table-space-text-post = \si{\percent},table-align-text-post = true] }
\toprule
Stoff & {Toleranz} & {Messunsicherheit}\\ \midrule
Vitamine & +50\si{\percent} & -35\si{\percent} \\ \addlinespace
Mineralstoffe & +45\si{\percent} & -35\si{\percent} \\
\cmidrule{3-3}
& & {pro \SI{100}{\gram}}\\ \cmidrule{3-3}
\multirow{2}{=}{Kohlenhydrate, Zucker, Eiweiß, Ballaststoffe} & < 10\si{\gram} & 2 \si{\gram} \\
& \numrange{10}{40}\si{\gram} & 20 \si{\percent} \\
& > 40\si{\gram} & 8\si{\gram} \\ \addlinespace
Fett & < 10 \si{\gram} & 1,5\si{\gram} \\
& \numrange{10}{40}\si{\gram} & 20\si{\percent} \\
& > 40 \si{\gram} & 8\si{\gram} \\ \addlinespace
\multirow{2}{=}{gesättigte FS, ein- und mehrfach unges. FS} & < 4 \si{\gram} & 0,8 \si{\gram}\\
& \geq 4 \si{\gram} & 20 \si{\percent} \\ \addlinespace
Natrium & < 0,5 \si{\gram} & 0,15 \si{\gram} \\
&< 4 \si{\gram}& 20 \si{\percent} \\ \addlinespace
Kochsalz & < 0,5 \si{\gram} & 0,375 \si{\gram}\\
& \geq 1,25 \si{\gram} & 20 \si{\percent}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}