mhchem - bold part of equation typeset with \ce{}
An \textbf
is a hard break inside a \ce
. What goes inside \textbf
's argument is not processed by the mhchem package.
This is the way to go.
\ce{NH3(g) + HCl(g) -> $\textbf{\ce{NH4Cl}}$(s)}
Use $
to indicate that you want to escape mhchem parsing (mhchem does the correct guessing that \textbf
and the next {}
belong together, but using $
is much clearer). Then use \textbf
, then use \ce
inside.
The $
part (or the \textbf
for that matter) might interrupt the mhchem flow. The succeeding (s)
works fine, here, but you might not be always so lucky (for instance, a $\textbf{4}$
would not be recognized as a number).
Try
- using
\ce
in math mode (this dose change the output when you use a text font that looks different from the math font, or in headings, as commented by @mhchem) and - using
\mathbf
instead of\textbf
See this example:
\documentclass{article}
\usepackage[version=4]{mhchem}
\begin{document}
$\ce{NH3(g) + HCl(g) -> \mathbf{NH_4Cl}(s)}$
\ce{NH3(g) + HCl(g) -> NH_4Cl(s)}
\end{document}