0

I am using siunitx with comma as output-decimal-marker. (localization) For the representation of numbers with repeating decimals I use overlaps.

Is there an easy way to request the current value of siunitx's output-decimal-marker to build a phantom string that is aware of future changes of that value?

It's no biggie really, I was just wondering.

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{
    output-decimal-marker = {,},   %%% value might change
    group-separator = \text{\,}
}
\begin{document}
\begin{gather*}
    %%% \phantom{0,} is not aware of changes to output-decimal-marker !!!
    \rlap{$\phantom{0,}\dot{\phantom{9}}$}\num{0.9} = 1 \\
    \rlap{$\phantom{0,}\overline{\phantom{01}}$}\num{0.01} = \frac{1}{99}
\end{gather*}
\end{document}
0
0

siunitx's output-decimal-marker property seems to be private and can not get fetched officially. If done so nevertheless future changes to siunitx's internals might render the code dysfunctional. A better way is to make a definition that can be fed to siunitx and can be used in the text or even macros. (One might abandon the dotted representation of a single repeating decimal for the sake of readability.)

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{siunitx}
%\newcommand{\decSep}{\_}      %%% for testing purpose only
%\newcommand{\decSep}{\ldots}  %%% for testing purpose only
\newcommand{\decSep}{,}
\newcommand{\decNum}[3]{\rlap{\ensuremath{\phantom{#1\mathord{\decSep}#2}\overline{\phantom{#3}}}}\num{#1.#2#3}}
\newcommand{\decSI }[4]{\rlap{\ensuremath{\phantom{#1\mathord{\decSep}#2}\overline{\phantom{#3}}}}\SI{#1.#2#3}{#4}}
\sisetup{
    output-decimal-marker = \decSep,
    group-separator = \text{\,}
}

\begin{document}
\begin{gather*}
    \decNum{0}{}{9} = 1 \\
    \decNum{0}{}{01}= \frac{1}{99} \\
    \decNum{17}{57}{32} = \frac{6959}{396} \\
    \decSI{0}{}{3}{\volt} \\
    \decNum{12}{502}{} \\
    \decSI{12}{502}{}{\ampere}
\end{gather*}
\decNum{0}{}{9} \\
\decNum{0}{}{01} \\
\decNum{17}{57}{32} \\
\decSI{0}{}{3}{\volt} \\
\decNum{12}{502}{} \\
\decSI{12}{502}{}{\ampere}
\end{document}

screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy