I'm trying to make a table in which the last column has mixed input of text and numbers in the same cell, and I want to align them at the decimal point, irrespective of the lenght of the preceeding text (though is usually a symbol like <, >, etc.). The problem is that the numbers overlap the text.
MWE:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{@{}l S[table-format=1.4] @{}}
& {p} \\
\midrule
Model & {\textless{}} 0,0001 \\
\hspace{0.5cm}A & {\textless{}} 0,0001 \\
\hspace{0.5cm}B & 0,2980 \\
\hspace{0.5cm}C & 0,0007 \\
\end{tabular}
\end{table}
\end{document}
results in:
If I use:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{@{}l S[table-format=1.4] @{}}
& {p} \\
\midrule
Model & {text} {0.0001} \\
\hspace{0.5cm}A & {\textless{}} {0.0001} \\
\hspace{0.5cm}B & 0.2980 \\
\hspace{0.5cm}C & 0.0007 \\
\end{tabular}
\end{table}
\end{document}
I get:
with no space between "text" and "0.0001", and the numbers not aligned at the decimal point.
If I try aligning the numbers to the right and centering the title:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{@{}l r@{}}
& \multicolumn{1}{c}{p} \\
\midrule
Model & {\textless{}} {0.0001} \\
\hspace{0.5cm}A & {\textless{}} {0.0001} \\
\hspace{0.5cm}B & 0.2980 \\
\hspace{0.5cm}C & 0.0007 \\
\end{tabular}
\end{table}
\end{document}
the result is:
which is still wrong, as the title is not centered in the column (it's more to the left side than it should be).
I also tried declaring mode=text in the preamble for siunitx, but still couldn't get the result I want.
Is there any way to get a single column with the header centered with the text below, and cells with some text followed by a space and then numbers aligned at the decimal point? Something closer to this mock-up:
I'm trying to avoid manual adjustments like \hspace{} or the like. Thanks.
EDIT OK, thanks to @Mico's code I got closer to what I want. I've added a few digits at both sides of the decimal marker to check the alignment of the text before and after the numerals. MWE:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{
output-decimal-marker = {,},
table-number-alignment = center,
table-align-comparator = false,
table-align-text-pre = false,
table-align-text-post = false,
table-space-text-pre = \, ,
}
\begin{document}
\begin{tabular}{c S[table-format=2.8, table-comparator=true]}
& {Value} \\
\midrule
Model & <9,0001 \\
A & >90,001 \\
B & 0,29801111 \\
C & \sim 0,0007 \\
D & \approx 1,030356{\textsuperscript{a}}
\end{tabular}
\end{document}
gives:
Now I only need to find a way to control the spacing between the pre- and post- text. I'd like a small space (like \,) between the comparator symbol and the numeral. The idea is to define this globally, to avoid having to define something like \newcommand{\ssim}{\sim\,}
for every symbol (<, >, ~, ±, etc.). Thanks.