6

I'm writing an equation using the displaymath environment, and I'd like to have the units in non-italic. So I use \mathrm{}, and I write this:

\begin{displaymath}
P_{AVG}=19.5 + \frac{2180}{5 \cdot 60 + 0.2} = 26.77~\mathrm{\mu}W
\end{displaymath}

But the units remain italic:

enter image description here

I tried to use the 'amsmath' package, but the problem remains. What am I doing wrong?

I'm using the book class in pdflatex: \documentclass[12pt, a4paper, titlepage, twoside, openright]{book}

EDIT: it took me a while to realize that the W was outside the \mathrm block, but the solutions are both very good.

6
  • 2
    We need to see your font set up, but if we assume standard Computer Modern then lower case Greek letters are only available in italic, as Knuth intended them for math typesetting only. You might want to look at my siunitx package for a 'wrapped up' way of dealing with the micro unit, or load something like upgreek to deal with this manually.
    – Joseph Wright
    Jul 5, 2012 at 7:53
  • @JosephWright: I think I'm not using any special font setting, as I'm using the book class in pdflatex. I'll put this in the question
    – clabacchio
    Jul 5, 2012 at 7:55
  • @JosephWright: sorry: I've put the package. Since I have many occurrences of \mathrm, can I directly replace them with \si?
    – clabacchio
    Jul 5, 2012 at 7:59
  • In any case, the W should be upright too, and all the numbers in the equation should have their units too (unless they are dimensionless). I'm with Joseph, use siunitx.
    – Jellby
    Jul 5, 2012 at 8:02
  • @Jellby: I agree, and I've installed the package. But can I just replace all the occurrences?
    – clabacchio
    Jul 5, 2012 at 8:05

2 Answers 2

13

This is my suggestion:

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}
\begin{document}

\begin{equation*}
P_{\text{AVG}} = \SI{19.5}{\micro\watt} + \frac{\SI{2180}{\micro\joule}}{5 \cdot \SI{60}{\second} + \SI{0.2}{\second}} = \SI{26.77}{\micro\watt}
\end{equation*}

\end{document}

enter image description here

(By loading the amsmath package, I can use text to typeset the "AVG" subscript in roman)

2
  • Uhm it looks very nice but it requires some work to convert all the occurrences...I'll do it later :)
    – clabacchio
    Jul 5, 2012 at 8:40
  • @clabacchio It pays in the long run, when you decide (or someone asks for it) that you want "m·N" instead of "mN", for instance.
    – Jellby
    Jul 5, 2012 at 8:54
6
\documentclass{book}
\usepackage{upgreek}
\begin{document}

\[
P_{AVG}=19.5 + \frac{2180}{5 \cdot 60 + 0.2} = 26.77~\upmu W
\]

\end{document}
3
  • I like this, it makes the job simple :) but how can I get the W non-italic?
    – clabacchio
    Jul 5, 2012 at 11:20
  • \mathrm{\upmu W}
    – user2478
    Jul 5, 2012 at 11:21
  • 1
    ok, I just realize that I left the W outside mathrm, and I was assuming it was inside :)
    – clabacchio
    Jul 5, 2012 at 11: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.