0

When trying to write a mathematical symbol using the regular font (i.e not italics) in math-mode as displayed in the following MWE

\documentclass[english, 12pt, a4paper, elec, utf8, a-1b]{mythesis}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{amsfonts,amssymb,amsbsy}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{nccmath}
\usepackage{graphicx}
\usepackage{tabu}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage[lofdepth,lotdepth]{subfig}
\usepackage{booktabs}

\begin{document}
...equipped with a 50$\textrm{\mu}$m slit...
\end{document}

a error is produced saying:

Missing $ inserted.
<inserted text> 
                 $
l.684 ... equipped with a 50$\textrm{\mu}$m slit, and...

I am trying to compile the file using PdfLaTeX, and haven't found anything indicating that it shouldn't work. I have also tried deleting corrupted aux files and tried using \text{} instead of \textrm{} but the same error is produced. I have also tried using \mathrm{} but in my case the font remains the same as it would regularly be in math mode.

To reiterate, how can I write a mathematical symbol in a regular font when \text, \textrm, \mathrm{} are not working? Is there another method to write mathematical symbols in a regular font?

Thanks already in advance :)

4
  • 3
    Welcome to TeX.SE! Because you need to put \mu in math mode, not in \textrm{}.
    – user121799
    May 17, 2018 at 14:15
  • 4
    \mu needs math mode, but with \textrm you are switching to text mode. This won't work. Use siunitx to typeset such things. tex.stackexchange.com/a/549/2388 May 17, 2018 at 14:16
  • 4
    There is \mathrm for math mode, but that does not work for \mu (it doesn't produce an error like $\textrm{\mu}$ does, but the output is not what you expected). I agree with Ulrike that you are quite probably looking for siunitx: \usepackage{siunitx} and then \SI{50}{\micro\metre}.
    – moewe
    May 17, 2018 at 14:19
  • Thank you @moewe, siunitx was exactly what I was looking for
    – Julian
    May 17, 2018 at 14:58

1 Answer 1

0

As was explained by @marmot, \textrm{}, when used inside math mode exits the math mode environment thus making the syntax $\textrm{\mu}$ wrong.

One possible solution as described by marmot is to use the siunitx package

MWE:

\documentclass[12pt,a4paper]{article}
\usepackage{siunitx}


\begin{document}
...equipped with a \SI{50}{\micro\meter} slit...
\end{document}
3
  • Did you test that code? It is usually written as `\SI{50}{\micro\meter}$
    – daleif
    May 17, 2018 at 15:08
  • and the name of the package is siunitx. May 17, 2018 at 15:10
  • Yup, I tested the code and it workd fine for me when compiling with pdfLaTeX.
    – Julian
    May 18, 2018 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .