7

When using the \iupac command from chemmacros I can do something like \ch{1,2\-dimethyl|really|long|name} so that LaTeX knows it can split the name up, and where. However, when I have a really long formula the \ch{UO2} command (From the chemformula subpackage) does not have such an option listed in the manual (and I tried | already). Is there a way to break up my long (45 character) chemical formula?

MWE:

\documentclass[letterpaper]{article}
%\usepackage[left = 1.5 in, right = 1.5 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[language=british]{chemmacros}
    \chemsetup[iupac]{coord-use-hyphen=true} %Puts hypens after bridging and hapto

%misc

%Load last stuff.
\begin{document}
This works See, it breaks at where I tell it to: \iupac{methyl|phenyl|piperidin|yl|acetate}


Here is a chemical formula: \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2]2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text: \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2]2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text: \ch{Cu(NCMe)2(pyz)|[AuCl2(CN)2]|2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text: \ch{Cu(NCMe)2(pyz) [AuCl2(CN)2] 2UO2(NO3)2}

Note a complete lack of this working despite spaces and such. 

The one way I've seen it work is (filler text filler text) \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2] * 2 MeCN}
\end{document}

1 Answer 1

2

Not sure if this is the correct way, but, hey, it works!

Add a new property that allows line breaking. I propose two: one that just allows a break and one that also adds a hyphen. Take your pick.

\documentclass[letterpaper]{article}
%\usepackage[left = 1.5 in, right = 1.5 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[language=british]{chemmacros}

\chemsetup[iupac]{coord-use-hyphen=true} %Puts hypens after bridging and hapto

\NewChemCompoundProperty{|}{\linebreak[0]}
\NewChemCompoundProperty{?}{\-}

%misc

%Load last stuff.
\begin{document}
This works See, it breaks at where I tell it to: \iupac{methyl|phenyl|piperidin|yl|acetate}


Here is a chemical formula: \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2]2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text:
\ch{Cu(NCMe)2 | (pyz) | [AuCl2(CN)2]2 | UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text:
\ch{Cu(NCMe)2 ? (pyz) ? [AuCl2(CN)2]2 ? UO2(NO3)2}

\end{document}

enter image description here

4
  • Probably what I'd do myself. :) Spaces around the new property symbols are not necessary by the way: \ch{Cu(NCMe)2|(pyz)|[AuCl2(CN)2]2|UO2(NO3)2}
    – cgnieder
    May 3, 2015 at 9:54
  • @clemens I used spaces just for better seeing where the additional break points are. I believe they're ignored in the argument of \ch.
    – egreg
    May 3, 2015 at 10:00
  • Dammit, I can't get it to work in my actual formula, but I can't post it since I need to publish is.
    – Canageek
    May 6, 2015 at 18:54
  • Ok, it does work if I make the margins larger, so it obviously just doesn't like where I've told it to break.
    – Canageek
    May 6, 2015 at 18:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .