1

I have huge numbers in tables (some of them are grouped in three digit groups but some are not).

I need to make a small space (or comma) between groups of three digits. I have used two packages, numprint and siunitx, but it doesn't show any changes in my tables.

I know I can do manually using the backslash but I have heaps of numbers in my tables.

Here my code,

\begin{tabular}{|l|l|l|}
\hline
x & y & z \\ 
\hline
9,833.823 & 550,245 & 15004568 \\ 
\hline
9,458.230 & 81,345.23 & 198000344 \\ 
\hline
\end{tabular}

enter image description here

  • Hi, do you insert that group separator points manually or is that some input issue? Are you able to insert only decimal points? Which one would you like. Dot or comma? – LaRiFaRi Dec 5 '14 at 6:01
5

You should use the package siunitx here. But in order to get the tables right, you have to use the S-column. I am showing some example below. If you really need left alignment, let me know.

It is not very clear from your post, what the input is, and what output is desired. Speaking of comma and dot. But what ever situation you have, siuntix is able to handle that. Just show us, what your input looks like and you output should look like.

% arara: pdflatex

\documentclass{article}
\usepackage{siunitx}
%\sisetup{group-separator={,}} % If you prefer... You should add your language as option as well!
\usepackage{booktabs}

\begin{document}
\begin{tabular}{S[table-format=1.6]S[table-format=3.5]S[table-format=9.0]}
    \toprule
    {x} & {y} & {z} \\ 
    \midrule
    9,833823 & 550,245 & 15004568 \\ 
    9,458230 & 81,34523 & 198000344 \\ 
    \bottomrule
\end{tabular}
\end{document}

enter image description here

  • It doesn't work for a larger table when you have \hline instead of \toprule – Harry Dec 5 '14 at 6:04
  • 2
    @Harry Can't imaging that. What does not work? Please be more precise. My solution should be absolutely independent of the choice of table design. – LaRiFaRi Dec 5 '14 at 6:06
  • Can you edit my code using your approach. It doesn't work me. Thanks – Harry Dec 8 '14 at 0:34
  • 1
    I think you may have misinterpreted the meaning of the commas in the inputs: They are probably not decimal markers but, instead, grouping dividers. (At least, that's how they tend to be used in the U.S.) Use the option input-ignore={,} as an option for \sisetup in order to avoid having to delete the commas by hand from the input. – Mico Dec 8 '14 at 6:15
  • 1
    @Harry I asked you two times, what the commas and dots are and if you need them. And I still do not know, what the input looks like for your large table. Do you have commas and dots everywhere? Mico's solution should work then, but without your information, I am guessing around and wasting my time. – LaRiFaRi Dec 8 '14 at 8:26

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.