5

My problem is to round numbers that are integers so, for example, I have 123456789 but I only want to have 123 * 10^6 in the table cell.

example code:

\begin{table}
\caption{Table} \label{tab:tab}
\begin{center}
\begin{tabular}{l S}
\hline
 Name & {number} \\
\hline
 a & 18799382 \\
 b & 16492855 \\
\hline
\end{tabular}
\end{center}
\end{table}

I want to round the second column to have an output of something like:

\begin{table}
\caption{Table} \label{tab:tab}
\begin{center}
\begin{tabular}{l S}
\hline
 Name & {number} \\
\hline
 a & 188e5 \\
 b & 165e5 \\
\hline
\end{tabular}
\end{center}
\end{table}
  • Welcome to TeX.SX! Is Converting numbers to scientific notations helpful or are you looking for an automatic solution? – Bobyandbob Jun 1 '18 at 11:53
  • Actually, that is useful, I just didn't know that the same controls work for tabular, but now it is obvious as I see the solution of @JosephWright. – mani Jun 2 '18 at 10:37
6

You need to do two things:

  • Turn on rounding with appropriate settings
  • Turn on fixed exponents with appropriate settings

Thus something like

\begin{tabular}
{
  l
  S[round-mode = figures,
   round-precision = 3,
   scientific-notation = fixed,
   fixed-exponent = 5]
}

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.