2

In the table below, column a is aligned by decimal point. Is it possible to align column b that way too?

\documentclass{standalone}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{S S}
  a      & b                           \\
  -0.135 & \pgfmathprintnumber{-0.135} \\
  0.1    & \pgfmathprintnumber{0.1}    \\
  -0.1   & \pgfmathprintnumber{-0.1}   \\
\end{tabular}
\end{document}

enter image description here

1
  • 3
    \pgfmathprintnumber is not expandable, so I don't think you can make it work inside an S column. I assume that the reason why you want to do this is that there are some calculations in the real world code? In that case, xfp's \fpeval may be a better option.
    – schtandard
    Commented Aug 12, 2019 at 20:42

1 Answer 1

2

It is possible, but have to use dcolumn instead of siunitx, below are the modified tags:

\documentclass{standalone}
\usepackage{pgfplotstable}
\usepackage{dcolumn}%
\newcolumntype{d}[1]{D{.}{.}{#1}}%

\begin{document}
\begin{tabular}{d{2,3} d{2,3}}
  a      & b                           \\
  -0.135 & \pgfmathprintnumber{-0.135} \\
  0.1    & \pgfmathprintnumber{0.1}    \\
  -0.1   & \pgfmathprintnumber{-0.1}   \\
\end{tabular}
\end{document}

And the output is:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .