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

  • 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 Aug 12 at 20:42
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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.