1

When I try to align values in a pgfplots table, I get problems when the exponent in the scientific notation has more digits.

Currently I am using the style:

columns/0/.style={column type={r},column name=\makecell{Column 0},sci,sci 10e,precision=3, column type/.add={}{@{\hspace{1em}}}},

I now get a problem when I have values like

1.1234 · 10⁹
 1.12 · 10¹¹

Without right align I get

1.1234 · 10⁹
1.12 · 10¹¹

What I would like to have is

1.1234 · 10⁹
  1.12 · 10¹¹

Or maybe padding with zeros

1.1234 · 10⁹
1.1200 · 10¹¹

Example Code:

\documentclass[a4paper,10pt]{article}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstabletypeset[
    columns/1/.style={column type={r},sci,sci 10e,precision=3, column type/.add={}{@{\hspace{1em}}}},
    col sep=&,
    row sep=\\,
]{
    1 & 1234000000   \\
    2 & 120000000000 \\
}
\end{document}
2

2 Answers 2

1

You can use the column S type from siunitx.

\documentclass[a4paper,10pt]{article}
\usepackage{siunitx} % Formats the units and values
\usepackage{pgfplotstable}

\usepackage[hang,bf,small]{caption}
\begin{document}
  \pgfplotstabletypeset[
  columns/1/.style={column type={r},sci,sci 10e,precision=3, column type/.add={}{@{\hspace{1em}}}},
  col sep=&,
  row sep=\\,
  ]{
    1 & 1234000000   \\
    2 & 120000000000 \\
  }

  \pgfplotstabletypeset[
  string type,
  columns/1/.style={column type={S[
      round-mode=places,
      round-precision = 3,
      exponent-mode = scientific,
      drop-zero-decimal=true,
      table-format=1.3e1,
      ]}},
  col sep={&},
  row sep={\\},
  header=false,
  ]{
    1 & 1234000000   \\
    2 & 120000000000 \\
  }
\end{document}

Which produces

enter image description here

0

I now use the sci,sci zerofill,sci 10e style with left aligned colums column type={l}. It aligns the dots, as now all numbers left of them have the same length.

You must log in to answer this question.

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