1

I'm making a table with numbers with different decimal contents. I'd like to complete automatically with 0 the remaining decimal positions, i.e. in a list of numbers like 1.2, 2.34 and 3.456 I'd like to print 1.200, 2.340 and 3.456. How can I achieve this using siunitx package?

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[htb]
\centering
\caption{Example Table}
\begin{tabular}{cS[table-format=1.3]}
\midrule
\textbf{Parameter} & \textbf{Value}\\
\midrule
Parameter 1 & 1\\
Parameter 2 & 1.2\\
Parameter 3 & 2.34\\
Parameter 4 & 4.567\\
\midrule
\end{tabular}
\end{table}
\end{document}

enter image description here

1 Answer 1

4

Look at the manual of siunitx, section 5.5 “Post-processing numbers”.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}[htb]
\centering
\caption{Example Table}
\begin{tabular}{
  c
  S[table-format=1.3,round-mode=places,round-precision=3,round-integer-to-decimal]
}
\toprule
\textbf{Parameter} & \textbf{Value}\\
\midrule
Parameter 1 & 1\\
Parameter 2 & 1.2\\
Parameter 3 & 2.34\\
Parameter 4 & 4.567\\
\bottomrule
\end{tabular}
\end{table}

\end{document}

The setting can also be enforced with \sisetup if it has to hold for the whole tabular; if \sisetup appears inside table, then the setting will be valid only in the environment.

enter image description here

You must log in to answer this question.

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