TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found Boris's suggestion to use siunitx to achieve number formatting in Hmisc::latex tables to almost be exactly what I was looking for: R, Sweave, Hmisc: pretty-print numbers

However, if you look closely at the table, the number columns line up poorly with the column labels. This is worse when using multicolumn labels (e.g., cgroup). In looking at the documentation (page 15, table 9) for siunitx, I think this is because it is centering the numbers at the decimal point.

Is it possible to use the number formatting functions of siunitx but justify the columns as \raggedleft (right aligned) within a call to Hmisc::latex?

share|improve this question
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. – Werner Jul 31 '12 at 16:01

You can check out the option table-format on page 51 of the documentation.

I can illustrate with this example based on the answer you linked to.


dat <-  matrix(c(1000, 100, 10000, 10000,3.145,1700.42), 2)
  booktabs=T,numeric.dollar=F,colheads=c("Col A","Col B","Col C"),
      colnamesTexCmd="bfseries", col.just=c("S[table-format = 4]",
                                            "S[table-format = 5]",
                                            "S[table-format = 4.3]"))


share|improve this answer
Perfect! Thank you for the reference and the example. – penguinv22 Jul 31 '12 at 16:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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