[Tex/LaTex] Align Numbers in tabularx with standard deviation

aligncolumnstabularx

I'm trying to make this table with numbers and standard deviation, how can I aligns the numbers properly?
The spacing between numbers and st.dev is too high and the numbers are not aligned to the point.

Thanks to all for support!

\documentclass[12pt,a4paper]{book}

\usepackage{amsmath} % Advanced math typesetting
\usepackage{amstext}
\usepackage[utf8]{inputenc} % Unicode support (Umlauts etc.)
\usepackage[english]{babel} % Change hyphenation rules
\usepackage{hyperref} % Add a link to your document
\usepackage{url}
\usepackage{graphicx} % Add pictures to your document
\usepackage{listings} % Source code formatting and highlighting
\usepackage[per-mode=symbol]{siunitx} % for typesetting scientific units

\DeclareSIUnit\tex{TEX}
\DeclareSIUnit\ends{ends}
\DeclareSIUnit\rpm{rpm}
\DeclareSIUnit\wtp{wt\%}

\usepackage{booktabs}
\usepackage{array}
\usepackage{tabularx}
\usepackage{dcolumn}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X} 

\begin{document}    

\begin{table}
\setlength\tabcolsep{4pt}
\begin{tabularx}{\textwidth}{@{} l YYYYY @{}}
\toprule
& \multicolumn{1}{c}{\textbf{Length}} & \multicolumn{2}{c}{\textbf{Width}} & \multicolumn{2}{c}{\textbf{Thickness}} \\
\cmidrule(lr){2-6}
\textbf{Test} & [\si{\mm}] & \multicolumn{2}{c}{[\si{\mm}]} & \multicolumn{2}{c}{[\si{\mm}]} \\
\midrule
\textbf{Quasi-Static \& Fatigue}& $\approx$ \num{200} & \num{24.90} & $\pm$ \num{0.20} & \num{1.95} & $\pm$ \num{0.07} \\
\textbf{Short Beam}             & $\approx$ \num{20}  & \num{4.99}  & $\pm$ \num{0.05} & \num{2.00} & $\pm$ \num{0.07} \\
\textbf{Impact}                 & $\approx$ \num{65}  & \num{13.48} & $\pm$ \num{0.21} & \num{1.95} & $\pm$ \num{0.11} \\
\bottomrule
\end{tabularx}
\caption{Measured dimension with standard deviation of specimens.}\label{tab:spec_meas}
\end{table}

\end{document}

How il looks now
How it looks now

Best Answer

To get table alignment using siunitx, do not put the numbers inside \num but just straight inside an S-type column. Here, I'd probably go for something like

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\sisetup{separate-uncertainty}
\begin{tabular}
  {@{} 
    l
    >{\approx}S[table-format = \approx3]
    S[table-format = 2.2(2)]
    S[table-format = 1.2(2)]
  @{}}
  \toprule
    & \multicolumn{3}{c}{Dimensions/\si{mm}} \\
    &  \multicolumn{1}{c}{Length} & {Width} & {Thickness} \\
  \midrule
    Quasi-static \& fatigue & 200 & 24.90(20) & 1.95(7)  \\
    Short beam              &  20 &  4.99(5)  & 2.00(7)  \\
    Impact                  &  65 & 13.48(21) & 1.95(11) \\
  \bottomrule
\end{tabular}
\end{document}

(I've combined the units into one place as the repeats seems superfluous, but that's of course down to you.) Notice that I've put the \approx into the table header, so for the Length heading I need a \multicolumn to avoid a stray one!

Related Question