Me gustaría tener las variables (definidas en Latex3) alineadas en una tabla con el punto decimal. Eso sí, sin utilizar el "espacio extra" de "prueba y error",". ¿Hay alguna posibilidad? Muchas gracias.
PD: Esta pregunta es específica de Latex3 y no debe asimilarse a un método bien conocido de Latex2e para alinear números en tablas.
\documentclass{article}
\usepackage{xparse}
\usepackage[version=4]{mhchem}
\usepackage{siunitx,booktabs}
%
\ExplSyntaxOn
\NewDocumentCommand{\calcnumd}{o m}
{\IfValueTF{#1}
{\num[round-mode = figures, round-precision = #1, round-integer-to-decimal]{\fp_to_decimal:n{#2}}}
{\num{\fp_to_decimal:n{#2}}}
}
% data
\fp_set:Nn \dhfbiox {33.18}
\fp_set:Nn \dhftetrox {9.16}
\fp_set:Nn \dgfbiox {51.31}
\fp_set:Nn \dgftetrox {97.89}
\fp_set:Nn \cpbiox {37.20}
\fp_set:Nn \cptetrox {77.28}
% calculations
%
\ExplSyntaxOff
%
\begin{document}
\begin{center}
\begin{tabular}{l|ccc}
& $\Delta_f H^{\ominus}$ & $\Delta_f G^{\ominus}$ & $C_P$ \\
& \si{\kilo\joule\per\mole} & \si{\kilo\joule\per\mole} & \si{\joule\per\kelvin\per\mole} \\
\midrule
\ce{NO2} & \calcnumd{\dhfbiox} & \calcnumd{\dgfbiox} & \calcnumd[4]{\cpbiox} \\
\ce{N2O4} & \,\,\,\calcnumd{\dhftetrox} & \calcnumd{\dgftetrox} & \calcnumd{\cptetrox} \\
\bottomrule
\end{tabular}
\end{center}
\end{document}
Respuesta1
\documentclass{article}
\usepackage{xparse,xfp}
\usepackage[version=4]{mhchem}
\usepackage{siunitx,booktabs}
%
\ExplSyntaxOn
\NewDocumentCommand{\calcnumd}{o m}
{\IfValueTF{#1}
{\num[round-mode = figures, round-precision = #1, round-integer-to-decimal]{\fp_to_decimal:n{#2}}}
{\num{\fp_to_decimal:n{#2}}}
}
% data
\fp_set:Nn \dhfbiox {33.18}
\fp_set:Nn \dhftetrox {9.16}
\fp_set:Nn \dgfbiox {51.31}
\fp_set:Nn \dgftetrox {97.89}
\fp_set:Nn \cpbiox {37.20}
\fp_set:Nn \cptetrox {77.28}
% calculations
%
\ExplSyntaxOff
%
\begin{document}
\begin{center}
\begin{tabular}{l|SSS}
& $\Delta_f H^{\ominus}$ & $\Delta_f G^{\ominus}$ & $C_P$ \\
& \si{\kilo\joule\per\mole} & \si{\kilo\joule\per\mole} & \si{\joule\per\kelvin\per\mole} \\
\midrule
\ce{NO2} & \fpeval{\dhfbiox} & \fpeval\dgfbiox & \fpeval\cpbiox \\
\ce{N2O4} & \fpeval\dhftetrox & \fpeval\dgftetrox & \fpeval\cptetrox \\
\bottomrule
\end{tabular}
\end{center}
\end{document}