[Tex/LaTex] Maths mode with chemmacros

chemformulachemistrychemmacros

I am a beginner with chemmacros and I have a problem during the compilation when I want to use greek letters inside the \ch{} command. Here is an example:

\ch{\Delta E=h.\nu}

A solution is to write this :

\ch{$\Delta E=h.\nu$}

However, I know that there is another solution as the initial command was already compiled on another computer. And as I have a 10,000 lines file, I cannot fix everything by hand…

Here is the package I loaded :

 \usepackage{upgreek}
 \usepackage{chemmacros}
 \usepackage{textgreek} 
 \chemsetup{greek=textgreek}
 \usepackage{amsmath}

I am using MacTeX2016 with LaTeX v3.62 and the lastest chemmacros version.
Any idea? Thanks a lot for your help.

Best Answer

\ch{\Delta E=h.\nu} should never have worked (I surely never intended it to). Also it doesn't make sense: $\Delta E=h\nu$ is a mathematical formula and not a chemical one. If you need math in a chemical formula chemformula offers to surround the entry with $…$ as you've already discovered.

Using \ch{$\Delta E=h.\nu$} is still wrong – not only semantically: the spacing is also wrong. Use \ch for chemical formulae and equations and math mode for math expressions and equations.

\documentclass{article}
\usepackage{chemformula}

\begin{document}

wrong: \ch{$\Delta E=h.\nu$} \par
correct: $\Delta E=h\cdot\nu$\par
correct: $\Delta E=h\nu$

\bigskip

correct: \ch{H2SO4} \par
wrong: $H_2SO_4$

\end{document}

enter image description here

Related Question