# Why do only certain font switches work in math mode?

If my codes have a statement like ${\bfseries{\emph{something}}$, it will return an error:

\bfseries invalid in math code.

But if I change the order of the control sequences, like this ${\emph{\bfseries{something}}$, everything is fine. Why is that?

• Welcome to TeX.SX! You can highlight code in your post using back-ticks. To highlight code-blocks, either indent them by four spaces or use the {} on the gui. – Andrew Dec 6 '18 at 5:19
• Why don't you use $\textbf{...}$? – JouleV Dec 6 '18 at 5:22
• @JouleV.Yeah,I also know that key word, but it only works in English. – StevenZ Dec 6 '18 at 5:26
• Did you use a language other than English? If so, did you use babel? Or did you use xeCJK? – zyy Dec 6 '18 at 5:29
• if something is word in text, than omit $, if it is math expression, than write $\mathbf{something}$. for more help you should provide complete small document beginning with \documentclass ... and ending with \end{document}. – Zarko Dec 6 '18 at 5:59 ## 1 Answer \emph is defined to be a "text command" and therefore sets its argument in text mode. That's why you're allowed to use $\emph{\bfseries <stuff>}$ since \bfseries occurs within text mode. The other way around, $\bfseries\emph{<stuff>}$ \bfseries occurs inside math mode, which is not allowed. If you want to set text in bold inside math, consider using \textbf{<stuff>} or \text{\bfseries <stuff>} if you're using amsmath. If you want bold math content, you can use \mathbf. Alternatively, if you want bold italic math content, use $\bm{<stuff>}\$ and also add \usepackage{bm} to your preamble.

Note how \bfseries is used above; there is no argument. That is, {\bfseries ...}, not \bfseries{...}.