I often refer to some chemicals often in my document (e.g. NH415NO3) and I keep getting line breaks in the middle of the chemical formula (e.g. if NH415NO3 comes at the end of a line, sometimes NH4 and 15NO3 are split onto different lines).
To get around this, and save typing, I created new commands for some chemicals:
\newcommand{\fan}{\mbox{\ch{^{15}NH4NO3}}} % \fan = 15NH4NO3 in mbox
\newcommand{\afn}{\mbox{\ch{NH4^{15}NO3}}} % \afn = NH415NO3 in mbox
\newcommand{\an}{\mbox{\ch{NH4NO3}}} % \an = NH4NO3 in mbox
\newcommand{\fnto}{\mbox{\ch{^{15}N2O}}} % \fnto = 15N2O in mbox
However, when I use my new commands, there's no space after the chemical formula in the text. If I put an extra space in the command, like this:
\newcommand{\afn}{\mbox{\ch{NH4^{15}NO3}} } % \afn = NH415NO3 in mbox
then, I get an extra unwanted space if a full stop comes after the formula in the text.
How can I solve this problem?
xspaceand add\xspaceat the end of the macros. This is a difficulty with macros that have no argument. If it doesn't work, systematically add a pair of braces after each use of the macro in your document. – Bernard Oct 03 '16 at 00:59\mboxshouldn't be necessary in the first place… – cgnieder Oct 03 '16 at 07:29chemformula, see my answer to your other question. – cgnieder Oct 04 '16 at 13:41