2

I am trying to write something like r=1m or r~1m inlined in my text. Currently i am using $\mbox{r=1m}$. However this gives me problems if I use $\mbox{r \approx 1m}$ it is not working and $\mbox{r}\approx\mbox{1m}$ is horrible to write and produces large gaps between r the ~ symbol and 1m. Is there a smarter way to do it ?

  • It kind of works, but gives me "Missing $ inserted when" when i need subscripts. – greole Dec 4 '13 at 11:49
  • 1
    @ferahfeza If I could downvote a comment, I would, in this case. That solution is very wrong since it destroys the spacing around \approx. – yo' Dec 4 '13 at 11:52
  • @tohecz, I understand that don't want any spacing between the 'r' and '1m'. – ferahfeza Dec 4 '13 at 11:58
5

Upright symbols in math can be produced by \mathrm. These will scale in subscripts and superscripts, unlike \mbox. Presumably your 1m is "one metre". The best way to set numbers with units is to use the siunitx package:

Sample output

\documentclass{article}

\usepackage{siunitx}

\begin{document}

\( \mathrm{r} = \SI{1}{m} \).

\end{document}

This will also work with \( \mathrm{r} \approx \SI{1}{m} \).

If you are using \mathrm{r} alot, you can define a macro instead:

\newcommand{\rad}{\mathrm{r}}

e.g. before \begin{document}, used as

\( \rad \approx \SI{1}{m} \)
  • Great! How would you expand this to ranges like r = 0..1m ? – greole Dec 4 '13 at 12:47
  • 1
    \SIrange{0}{1}{m} whose output can be custmosized, see the manual – Andrew Swann Dec 4 '13 at 12:50

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.