Adjust Spacing Around Bonds in mhchem Using Other Fonts

I just realized that the bonds in the \ce{...} command get spaces around them in text-mode, when changing the documents font using fontspec to f.e. Linux Libertine O. Due to the spaces, the double bond looks like an equal sign.

The attached MWE demonstrates the appearance of the atom-bond segment when using \ce{..} in text-mode and in math-mode and further when using neat text-mode (without \ce{..}). As can be seen, the spaces only occur when using \ce{...} in text-mode.

Is there a way to adjust the spacing between atoms and bonds in mhchem, and therefore make it appear like the neat text-mode (Or math-mode as they are anyways quite the same).

% !TeX program = lualatex
\documentclass[a4paper]{report}

\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Linux Libertine O}
\setmathfont{Libertinus Math}

\usepackage[version=4]{mhchem}

\mhchemoptions{
minus-text-sidebearing-left  = {0.14em},
minus-text-sidebearing-right = {0.22em},
minus-math-sidebearing-left  = {0.04em},
minus-math-sidebearing-right = {0.08em},
}

\begin{document}
\begin{tabular}{lll}
\ce{A\bond{-}B\bond{=}C\bond{#}D}       & \ce{A\bond{~}B\bond{~-}C}                    & \ce{A\bond{...}B\bond{....}C} \\
$$\ce{A\bond{-}B\bond{=}C\bond{#}D}$$ & $$\ce{A\bond{~}B\bond{~-}C}$$              & $$\ce{A\bond{...}B\bond{....}C}$$ \\
A--B=C & {} & {} \\
{}     & {} & {} \\
\ce{A\bond{1}B\bond{2}C\bond{3}D}       & \ce{A\bond{~--}B\bond{~=}C\bond{-~-}D}       & \ce{A\bond{->}B\bond{<-}C} \\
$$\ce{A\bond{1}B\bond{2}C\bond{3}D}$$ & $$\ce{A\bond{~--}B\bond{~=}C\bond{-~-}D}$$ & $$\ce{A\bond{->}B\bond{<-}C}$$ \\
A--B=C & {} & A\rightarrow{}B\leftarrow{}C \\
\end{tabular}
\end{document}

You can adjust the spacing by setting the textminus key:

\documentclass[a4paper]{report}

\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Linux Libertine O}
\setmathfont{Libertinus Math}
\setsansfont{Linux Libertine O}
\usepackage[version=4]{mhchem}

\mhchemoptions{
minus-text-sidebearing-left  = {0.14em},
minus-text-sidebearing-right = {0.22em},
minus-math-sidebearing-left  = {0.04em},
minus-math-sidebearing-right = {0.08em},
}

\begin{document}

\begin{tabular}{lll}
\ce{A\bond{-}B\bond{=}C\bond{#}D}\\
\mhchemoptions{textminus=--} % default : { \hspace{0.3ex} -- \hspace{0.3ex} }
\ce{A\bond{-}B\bond{=}C\bond{#}D}
\end{tabular}
\end{document}

• Quite amazing that this cannot be found in the manual :D Thanks, worked perfectly fine. – lcnittl Dec 7 '17 at 23:58
• @lcnittl It is probably not in the manual, because I wasn't sure it was good enough to be public. Now that I see how intertwined textminus is with sidebearing, I feel I should create a better public interface. So please expect a change with a future update. – mhchem Dec 8 '17 at 6:35