How to use siunitx and tabularx together? works great if you want every X
column to be interpreted by siunitx
, however, what if I want that for just a few tables? So, is it possible to have the S[opt]
column behavior with automatic width?
I'm struggling with the optional arguments part of the S
column, so far this is what I've got.
MWE
\documentclass{article}
\usepackage{array,tabularx,siunitx,booktabs}
\usepackage[utf8]{inputenc}
% Allow `_` and `:` in macro names (LaTeX3 style)
\catcode`\_=11
\catcode`\:=11
% Internal code of `S`
\newcolumntype{Y}[1]{% << mandatory argument (how to make it optional?)
>{\__siunitx_table_collect_begin:Nn S{#1} }%
X%
<{\__siunitx_table_print:}%
}
\catcode`\_=8
\catcode`\:=12
\begin{document}
\begin{table}[h]
\centering
\caption{Some table}
\begin{tabularx}{\textwidth}{Y{}Y{}Y{}}
\toprule
{Tempo (min)} & {Fase A (\%v/v)} & {Fase B (\%v/v)} \\
\midrule
0,01 & 100 & 0\\
15 & 80 & 20\\
25 & 80 & 20\\
30 & 100 & 0\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
If the answer is "No that's not possible" it's ok, but it would be nice to have it running perfectly. :D
Someone will ask why use tabularx
for numeric columns, easy explanation: crazy advisor requirement. If it was up to me... :)
tabularx
for tables of data. it is all about line breaking . When I see it used with unbreakable numbers I feel sad for having written it:-)