# spectroscopy: \#{} without non-breaking space

When using \#{} in the experimental environment of chemmacros it gives the number followed by the nucleus, but they are separated by a regular space, instead of a non-breaking space.

I don't know if this is intentional, but it can lead to the nucleus being printed in the next line, whereas it should be treated as a unit and therefore stick to the number.

Is there a way to redefine this macro by myself or will I have to manually type 2~H for now?

My MWE:

\documentclass{scrbook}

\usepackage{chemmacros}
\chemsetup{modules={spectroscopy}}

\begin{document}
\begin{experimental}
\NMR(300)[CD3COOD]
\val{9.87} (d, \J{1.2}, \#{1}),
\val{6.54} (d, \J{3.4}, \#{2}).
\end{experimental}
\end{document}


giving me (notice the H in the second line).

• the question would be much easier to answer if there was a MWE – David Carlisle Oct 12 '17 at 15:43

\# is defined in the spectroscopy module (the file chemmacros.module.spectroscopy.code.tex) to be equal to \chemmacros_nmr_number:n inside the experimental environment. This function is defined as

\cs_new_protected:Npn \chemmacros_nmr_number:n #1
{
\__chemmacros_nmr_number:n {#1}
\skip_horizontal:N \l__chemmacros_nmr_space_skip
\chemmacros_chemformula:V \g__chemmacros_nmr_element_tl
}


but probably should be defined like this:

\cs_new_protected:Npn \chemmacros_nmr_number:n #1
{
\__chemmacros_nmr_number:n {#1}
\chemmacros_skip_nobreak:N \l__chemmacros_nmr_space_skip
\chemmacros_chemformula:V \g__chemmacros_nmr_element_tl
}


\ExplSyntaxOn
\cs_set_protected:Npn \chemmacros_nmr_number:n #1
{
\__chemmacros_nmr_number:n {#1}
\chemmacros_skip_nobreak:N \l__chemmacros_nmr_space_skip
\chemmacros_chemformula:V \g__chemmacros_nmr_element_tl
}
\ExplSyntaxOff


after loading the spectroscopy module.

I'll change this in the package. The fix will be included starting with v5.8c.

• Perfect! I was actually just looking at that same snippet of code on GitHub trying to find an answer before posting my question, but I couldn't make any sense of it. :) – basseur Oct 12 '17 at 16:14