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 :)

Stefan Pinnow
  • 29,535
Julian
  • 1
  • 1
  • 5
  • 3
    Welcome to TeX.SE! Because you need to put \mu in math mode, not in \textrm{}. –  May 17 '18 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. https://tex.stackexchange.com/a/549/2388 – Ulrike Fischer May 17 '18 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 '18 at 14:19
  • Thank you @moewe, siunitx was exactly what I was looking for – Julian May 17 '18 at 14:58

1 Answers1

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}
egreg
  • 1,121,712
Julian
  • 1
  • 1
  • 5