我想按以下方式对齐我的表格:
砷______0,63+-0,12__________18 +-12
砷________11,7+-0,6__________109 +-9
正如您所看到的,我不希望 \pm 符号和数字之间有任何空格,即使某些数字有小数(后者应该被完全忽略)
我该如何使用我的表来实现这一点?我无法使用 sinunitx 完成这项工作。
\documentclass[listof=totoc, %Abildungsverzeichnis, Bildverz.)
twoside, openright,
bibliography=totocnumbered,%num. L.Verz.
numbers=noenddot] %keine Punkte nach Section-Nummerierung
{scrreprt} %Dokumentklasse
\usepackage[top=25mm,bottom=20mm,
footskip=24pt] %Länge zwischen Text und Seitenzahl
{geometry}
\usepackage{siunitx}
\usepackage{colortbl}
\usepackage{nicematrix}
\usepackage{booktabs}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Tabelle1'
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{lcccccc}
\toprule
\textbf{Element} & \multicolumn{1}{l}{\textbf{TWP/f}} & \multicolumn{1}{l}{\textbf{Pavement}} & \multicolumn{1}{l}{\textbf{Road Side}} & \multicolumn{1}{l}{\textbf{Elbe}} & \multicolumn{1}{l}{\textbf{Freiberger Mulde}} & \textbf{Saale} \\
\midrule
\textbf{Arsen*} & \cellcolor[rgb]{ 0, .439, .753}0,63 \pm 0,12 & \cellcolor[rgb]{ 0, .69, .314}18 \pm 12 & \cellcolor[rgb]{ 0, .69, .314}15,7 \pm 0,6 & \cellcolor[rgb]{ .573, .816, .314}38 \pm 6 & n. b. & n. b. \\
\textbf{Blei} & \cellcolor[rgb]{ 0, .439, .753}11,7 \pm 0,6 & \cellcolor[rgb]{ .573, .816, .314}109 \pm 9 & \cellcolor[rgb]{ .573, .816, .314}172 \pm 18 & \cellcolor[rgb]{ 1, .871, .216}109 \pm 26 & \cellcolor[rgb]{ 1, 0, 0}1900 & \cellcolor[rgb]{ .573, .816, .314}120 \\
\textbf{Cadmium} & \cellcolor[rgb]{ 0, .439, .753}0,23 \pm 0,06 & \cellcolor[rgb]{ 0, .69, .314}0,67 \pm 0,12 & \cellcolor[rgb]{ 0, .69, .314}1,0 \pm 0,0 & \cellcolor[rgb]{ 1, .6, 0}5,2 \pm 0,9 & \cellcolor[rgb]{ 1, 0, 0}440 & \cellcolor[rgb]{ 1, .6, 0}6,1 \\
\textbf{Chrom} & \cellcolor[rgb]{ 0, .439, .753}3,20 \pm 0,27 & \cellcolor[rgb]{ 1, .871, .216}242 \pm 17 & \cellcolor[rgb]{ 1, .871, .216}344 \pm 9 & \cellcolor[rgb]{ .573, .816, .314}112 \pm 19 & \cellcolor[rgb]{ 1, .871, .216}260 & \cellcolor[rgb]{ 0, .69, .314}96 \\
\textbf{Kupfer} & \cellcolor[rgb]{ 0, .439, .753}18 \pm 3 & \cellcolor[rgb]{ 1, 0, 0}510 \pm 100 & \cellcolor[rgb]{ 1, 0, 0}1047 \pm 6 & \cellcolor[rgb]{ .573, .816, .314}99 \pm 27 & n. b. & n. b. \\
\textbf{Nickel} & \cellcolor[rgb]{ 0, .439, .753}4,9 \pm 0,5 & \cellcolor[rgb]{ 1, .871, .216}122 \pm 11 & \cellcolor[rgb]{ .573, .816, .314}88 \pm 3 & \cellcolor[rgb]{ 0, .69, .314}50 \pm 5 & n. b. & n. b. \\
\textbf{Zink} & \cellcolor[rgb]{ 1, 0, 0}10430 \pm 80 & \cellcolor[rgb]{ 1, .6, 0}980 \pm 28 & \cellcolor[rgb]{ 1, 0, 0}2250 \pm 40 & \cellcolor[rgb]{ 1, .6, 0}950 \pm 190 & \cellcolor[rgb]{ 1, 0, 0}20100 & \cellcolor[rgb]{ 0, .69, .941}110 \\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{document}
谢谢你!
答案1
这是一个采用列包。它利用了以下事实:所讨论的四列中没有.
(点,又称句号)符号(除了指令中\cellcolor
)。我已将所有实例转换为\pm
,.
并定义了一种新的列类型,d
它将实例转换.
回\pm
。这样,列的内容将以\pm
符号为中心。
\documentclass[listof=totoc, %Abildungsverzeichnis, Bildverz.)
twoside, openright,
bibliography=totocnumbered,%num. L.Verz.
numbers=noenddot] %keine Punkte nach Section-Nummerierung
{scrreprt} %Dokumentklasse
\usepackage[top=25mm,bottom=20mm,
hmargin=20mm, % set as needed
footskip=24pt] %Länge zwischen Text und Seitenzahl
{geometry}
\usepackage{siunitx}
\usepackage{colortbl}
\usepackage{nicematrix}
\usepackage{booktabs}
%% new code:
\usepackage{dcolumn}
\newcolumntype{d}{D{.}{\:\pm\:}{-1}} % for columns 2 to 5
\newcolumntype{C}{>{$}c<{$}} % for columns 6 & 7
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\usepackage{icomma} % treat commas in math mode as decimal markers
\begin{document}
\begin{table}[htbp]
\setlength\extrarowheight{3pt} % for a less-cramped look
\centering
\caption{Add caption} \label{tab:addlabel}
\begin{tabular}{@{} l *{4}{d} CC }
\hline
\textbf{Element} &
\mc{\textbf{TWP/f}} &
\mc{\textbf{Pavement}} &
\mc{\textbf{Road Side}} &
\mc{\textbf{Elbe}} &
\textbf{Freiberger} &
\textbf{Saale} \\[-3pt]
& & & & & \textbf{Mulde} \\
\hline
\textbf{Arsen*} & \cellcolor[rgb]{ 0, .439, .753}0,63 . 0,12 & \cellcolor[rgb]{ 0, .69, .314}18 . 12 & \cellcolor[rgb]{ 0, .69, .314}15,7 . 0,6 & \cellcolor[rgb]{ .573, .816, .314}38 . 6 & \mc{n.b.} & \mc{n.b.}\\
\textbf{Blei} & \cellcolor[rgb]{ 0, .439, .753}11,7 . 0,6 & \cellcolor[rgb]{ .573, .816, .314}109 . 9 & \cellcolor[rgb]{ .573, .816, .314}172 . 18 & \cellcolor[rgb]{ 1, .871, .216}109 . 26 & \cellcolor[rgb]{ 1, 0, 0}1900 & \cellcolor[rgb]{ .573, .816, .314}120 \\
\textbf{Cadmium} & \cellcolor[rgb]{ 0, .439, .753}0,23 . 0,06 & \cellcolor[rgb]{ 0, .69, .314}0,67 . 0,12 & \cellcolor[rgb]{ 0, .69, .314}1,0 . 0,0 & \cellcolor[rgb]{ 1, .6, 0}5,2 . 0,9 & \cellcolor[rgb]{ 1, 0, 0}440 & \cellcolor[rgb]{ 1, .6, 0}6,1 \\
\textbf{Chrom} & \cellcolor[rgb]{ 0, .439, .753}3,20 . 0,27 & \cellcolor[rgb]{ 1, .871, .216}242 . 17 & \cellcolor[rgb]{ 1, .871, .216}344 . 9 & \cellcolor[rgb]{ .573, .816, .314}112 . 19 & \cellcolor[rgb]{ 1, .871, .216}260 & \cellcolor[rgb]{ 0, .69, .314}96 \\
\textbf{Kupfer} & \cellcolor[rgb]{ 0, .439, .753}18 . 3 & \cellcolor[rgb]{ 1, 0, 0}510 . 100 & \cellcolor[rgb]{ 1, 0, 0}1047 . 6 & \cellcolor[rgb]{ .573, .816, .314}99 . 27 & \mc{n.b.} & \mc{n.b.} \\
\textbf{Nickel} & \cellcolor[rgb]{ 0, .439, .753}4,9 . 0,5 & \cellcolor[rgb]{ 1, .871, .216}122 . 11 & \cellcolor[rgb]{ .573, .816, .314}88 . 3 & \cellcolor[rgb]{ 0, .69, .314}50 . 5 & \mc{n.b.} & \mc{n.b.} \\
\textbf{Zink} & \cellcolor[rgb]{ 1, 0, 0}10430 . 80 & \cellcolor[rgb]{ 1, .6, 0}980 . 28 & \cellcolor[rgb]{ 1, 0, 0}2250 . 40 & \cellcolor[rgb]{ 1, .6, 0}950 . 190 & \cellcolor[rgb]{ 1, 0, 0}20100 & \cellcolor[rgb]{ 0, .69, .941}110 \\
\hline
\end{tabular}
\end{table}%
\end{document}