Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

1 Answer 1

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.

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{siunitx,booktabs}
\sisetup{group-separator={.},group-minimum-digits={3},
  output-decimal-marker={,}}
\usepackage[noae]{Sweave}
\begin{document}
\SweaveOpts{concordance=TRUE}

<<>>=
library("Hmisc")
dat <-  matrix(c(1000, 100, 10000, 10000,3.145,1700.42), 2)
@
<<echo=false,results=tex>>=
latex(dat,table=F,center='centering',file='',
  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]"))
@

\end{document}

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

Your Answer

 
discard

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.