I want to align my tabularx tables on the dot. Let's say I have these two tables:
With the following code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}
\begin{document}
\begin{table}[h]
\centering
\begin{tabularx}{\textwidth}{XX}
\toprule
{Test Nr.} & Timestamp \\
\midrule
1 & 2019-01-15 05:22:10.024094 \\
2 & 2019-01-15 05:35:30.024133 \\
3 & 2019-01-23 14:32:17.868884 \\
\bottomrule
\end{tabularx}
\end{table}
\begin{table}[h]
\begin{tabularx}{\textwidth}{XXXXXXX}
\toprule
{Test Nr.} & a & b & c & d & e \\
\midrule
1 & 123 & -123 & 123.33 & 12 & 123 \\
2 & 123 & -123 & 123.98 & 123 & 5 \\
3 & 123 & -123 & -0.0123 & 123 & - \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
Now I want the decimal dot from -0.0123 and 123.98 to be vertically aligned.
I found the following solution:
\usepackage{booktabs, makecell}
\usepackage{siunitx, tabularx}
\usepackage{array}
\begingroup
% Allow `_` and `:` in macro names (LaTeX3 style)
\catcode`\_=11
\catcode`\:=11
% Internal code of `S`
\gdef\tabularxcolumn#1{%
>{\__siunitx_table_collect_begin:Nn S{} }%
p{#1}% <- this is different (is `c` in normal `S`)
<{\__siunitx_table_print:}%
}
\endgroup
The dots line up as wanted but it messes up everything else, especially the timestamps and it removes the last '-' in column e.
To be honest I really don't understand the \begingroup command.
How can I make this work properly?
dcolumn
also preferable...