For my thesis I have to format NMR data. The assignment of individual signals can be done either by numbering the atoms in the molecule or by writing down part of its structure as a molecular formular where the individual coresponding atoms are highlighted (underlined, italic or bold).
I am aware of the chemmacros bundle and its \NMR command for easy formatting of the first mentioned assigning possibility.
However I would prefer the latter method. The following MWE shows my attempt of achieving the desired output (last line) using the mhchem package. Unfortunately, nesting formatting commands inside the \ce environment does not directly lead to the desired output (see 2nd and 3rd line), so some adjustments have to be made. These make the code somehow messy and hardly readable and it takes some time to type this for all the nmr data I have to format.
For now I would like to know if there is either a package or command to achieve this, that I was not aware of or if I can somehow simplify my input.
\documentclass{scrreprt}
\usepackage{mhchem}
\begin{document}
\ce{CH3-CH2}
\ce{\underline{CH3}-CH2}
\ce{{\underline{CH3}}-CH2}
\ce{{\underline{CH\textsubscript{3}}}-CH2}
\end{document}
The following picture includes the output of the above shown code. The last line represents the output I want to generate.


[version=4]? – mhchem Jul 29 '17 at 11:56versionadded. – Heiko Oberdiek Jul 29 '17 at 12:44versionso often. – mhchem Jul 29 '17 at 14:16versionis not present. – Heiko Oberdiek Jul 29 '17 at 14:25