# Simplified formatting of NMR data

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.

Three more variants:

\documentclass{scrreprt}

\usepackage[version=4]{mhchem}

\begin{document}

\underline{\ce{CH3}}\ce{-CH2}

\ce{\underline{\ce{CH3}}-CH2}

\def\ulce[#1]{\underline{\ce{#1}}}
\cesplit{%
{CH3}{\c{ulce}[\0]}%
}{CH3-CH2}

\end{document}


• Doesn't mhchem throw a warning for a missing [version=4]? – mhchem Jul 29 '17 at 11:56
• @mhchem Thanks, option version added. – Heiko Oberdiek Jul 29 '17 at 12:44
• I was just wondering if a warning was visible, because I see the missing version so often. – mhchem Jul 29 '17 at 14:16
• @mhchem Yes, there is a warning if option version is not present. – Heiko Oberdiek Jul 29 '17 at 14:25