# How can I write bond labels with chemformula?

I want to reproduce this scheme in P. J. Flory's first book, p. 319:

for which I need to typeset labels under the bonds. I tried to make bonds accept labels like arrows do, first with the pretty naïve attempt in the MWE below, then I delved into chemformula's code to try to paste up a solution, but LaTeX3 looks like extraterrestrial to me.

\documentclass{article}
\usepackage{chemformula}

%% \ch{A --[a][b] B}, with --[a][b] defined as follows, puts too much space around the arrow-bond.
\NewChemArrow{--}{\draw[chemarrow] (cf_arrow_start) -- (cf_arrow_end) ; }

\begin{document}

\ch{A--[a][b]B}

\bigskip
\ch{A '$\underset{a}{\ch{--}}$' B} % This one ends in "TeX capacity exceeded, sorry [grouping levels=255]."

\end{document}


 One solution is to use \ch[bond-length=3em]{A '$\underset{x-1}{\bond{sb}}$' B}, as suggested by @Troy.

Is it possible to let the label accomodate itself under the text? As it stands now, a large label pushes the atoms apart:

\documentclass{article}
\usepackage{chemformula}

\begin{document}

\noindent
\ch{A-B}\\
\ch{A '$\underset{x - 1}{\bond{sb}}$' B}\\
\ch[bond-length=3em]{A '$\underset{x-1}{\bond{sb}}$' B}

\end{document}


prints

• @Troy Thanks! Should have figured out by myself... Anyway, I would rewrite it as \ch{A '$\underset{a}{\bond{sb}}$' B} (with the quotes and the spaces surrounding the bond). Try \ch[bond-length=3em]{A '$\underset{x-1}{\bond{sb}}$' B} with and without them to see the difference. – Arch Stanton Sep 9 '17 at 16:15

I'd use chemformula's

\ch{ !(<text>)(<formula>) }


syntax and a zero-width box:

\documentclass{article}

\usepackage{chemformula}

\begin{document}

\ch{
H !(1)(\bond{sb}) ORCO !(2)(\bond{sb}) ORCO !(3)(\bond{sb})
...
!(\makebox[0pt]{$x-1$})(\bond{sb}) ORCO !($x$)(\bond{sb}) OH
}

\end{document}


• Thank you Clemens. What is the empty group before the dots for? – Arch Stanton Sep 10 '17 at 8:49
• @ArchStanton it's useless, I removed it – clemens Sep 10 '17 at 11:50

mathtools' \mathclap does the job:

\documentclass{article}
\usepackage{chemformula}
\usepackage{mathtools}

\begin{document}

\noindent
\ch{A-B}\\
\ch{A '$\underset{\mathclap{x - 1}}{\bond{sb}}$' B}\\
\ch[bond-length=3em]{A '$\underset{x-1}{\bond{sb}}$' B}
\end{document}


You may use a command for it:

\newcommand*{\blb}[2][sb]{\ensuremath{\underset{\mathclap{#2}}{\bond{#1}}}}
...
\ch{A '\blb{x-1}' B} % same as the second line above
\ch{A '\blb[db]{x-1}' B} % this is an unsaturated AB