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

What is the best way to display percentages in Sweave?

A simple example:

The number 4 is \Sexpr{4 / 7} of 7.

What is the best way to get the document to display:

The number 4 is 57.1% of 7.

share|improve this question
up vote 8 down vote accepted

I would use siunitx for typesetting the number with the percent sign, which will take care of the correct spacing, and do the conversion to a percentage and the rounding within the \Sexpr:

The number 4 is \SI{ \Sexpr{round(4 / 7 * 100, 1)} }{\percent} of 7.
share|improve this answer
That's perfect. All the other ways I tried seemed like too much of a hack. Thank you! – Boom Shakalaka Jan 10 '12 at 1:22

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.