# Line break long chemical names that contain brackets

I have some very long chemical names that are spilling into the margins, and I'd like to just tell LaTeX how to hyphenate them automatically so I don't have to manually go back and insert hard line breaks. I've tried using \hyphenate and it gives me a "not a letter" error, which is probably because these formula names include parenthenses.

The chemical names are: tris(tetrachlorocatecholato)manganese(IV), bis(tetrachlorocatecholato)tetrachlorosemiquinonatocobalt(III), tris(tetrachlorosemiquinonato)iron(III), and tris(tetrachlorocatecholato)iron(III)

Here's what I've tried in the preamble:

``````\hyphenation{tris(tetra-chloro-cat-e-cho-la-to)man-gan-ese(IV)}
\hyphenation{bis(tetra-chloro-cat-e-cho-la-to)tetra-chloro-semi-qui-non-ato-cobalt(III)}
\hyphenation{tris(tetra-chloro-semi-qui-non-ato)iron(III)}
\hyphenation{tris(tetra-chloro-cat-e-cho-la-to)iron(III)}
``````

I tried just doing a hyphenation for the parts in the parenthenses:

``````\hyphenation{tetra-chloro-cat-e-cho-la-to}
\hyphenation{tetra-chloro-semi-qui-non-ato}
``````

But it won't hyphenate those within the longer "word" of the chemical name. Is there a way to automate this or am I just stuck doing hard line breaks by hand?

• Did you see Hyphenation next to a parenthesis? – egreg Apr 23 '14 at 20:09
• I looked at that and I'm not sure that will work, the way this document is set up I can't use macros in the abstract, and redefining brackets to make hyphen breaks will probably screw up a lot more than it will solve. – hmc73 Apr 24 '14 at 0:48

## 2 Answers

EDIT: As pointed out by Joseph Wright in the comment, the new version (4.6) of `chemmacros` provides the `\iupac` command which does similar thing with the `\IUPAC` command in `bpchem`but with many more customisations, it is detailed in the section 8 in the user manual.

For your case using `chemmacros` should be

``````\iupac{tris|(tetra|chloro|cat|e|cho|la|to)|man|gan|ese(IV)}
\iupac{bis(tetra|chloro|cat|e|cho|la|to)tetra|chloro|semi|qui|non|ato|cobalt(III)}
\iupac{tris(tetra|chloro|semi|qui|non|ato)iron(III)}
\iupac{tris(tetra|chloro|cat|e|cho|la|to)iron(III)}
``````

Notice that in `chemmacros`, both `|` and `\|` are active inside `\iupac` but `\|` will be depracated so `|` is recommended.

You can also use the `bpchem` package, and use the `\|` command for your desired hyphenation position.

``````\IUPAC{tris\|(tetra\|chloro\|cat\|e\|cho\|la\|to)\|man\|gan\|ese(IV)}
\IUPAC{bis(tetra\|chloro\|cat\|e\|cho\|la\|to)tetra\|chloro\|semi\|qui\|non\|ato\|cobalt(III)}
\IUPAC{tris(tetra\|chloro\|semi\|qui\|non\|ato)iron(III)}
\IUPAC{tris(tetra\|chloro\|cat\|e\|cho\|la\|to)iron(III)}
``````
• Perhaps you could add here that the newer `chemmacros` provides similar functionality as `\iupac`: the two ideas are more-or-less the same but `chemmacros` has more 'other stuff' so is a more generally-useful chemistry package. – Joseph Wright Dec 16 '14 at 7:33
• @JosephWright Thank you for pointing it out, I haven't aware of it. It seems that `chemmacros` is better as it provides more customisation. I will edit my answer. – bingung Dec 16 '14 at 11:44
• IMHO it is not the answer to the question. The `\iupac` macro can be used in the text of the document, but OP asked to the declaration of hyphenation patterns (only once) at beginning of the document. – wipet Dec 17 '14 at 8:38
• @wipet The `chemmacros` and `bpchem` provide macros that directly solve OP's problem (hyphenate chemical names correctly), which avoid defining hyphenation pattern. It's just another approach to the same problem. In case the OP wants to define the pattern once, he can always define a new command to avoid repeating typing the same pattern again and again. – bingung Dec 19 '14 at 0:20
• It is not really useful to add `|` at every syllable in `\iupac`. I'd rather do `\iupac{tris(tetra|chloro|catecholato)manganese(IV)}`. It will still make the right breaks when hyphenation patterns are given for `catecholato` and `manganese` – cgnieder Oct 19 '15 at 11:13

Set the parenthesis as letters for hyphenation point of view:

``````\lccode`(=`( \lccode`)=`)
\hyphenation{tris(tetra-chloro-cat-e-cho-la-to)man-gan-ese(IV)}
\hyphenation{bis(tetra-chloro-cat-e-cho-la-to)tetra-chloro-semi-qui-non-ato-cobalt(III)}
\hyphenation{tris(tetra-chloro-semi-qui-non-ato)iron(III)}
\hyphenation{tris(tetra-chloro-cat-e-cho-la-to)iron(III)}
``````
• So some text with `atomic)` will be hyphenated violating the `\righthyphenmin=3`; just try `\lccode`(=`( \lccode`)=`)\vbox{\hsize=0pt \hskip0pt atomic)}\bye` which will give `atom-ic)` which is wrong. – egreg Dec 16 '14 at 12:56
• I know about it. I assumed that if the parentheses are used in document as inner-word marks then the same parentheses aren't used as characters outer words, because it is reader confusing. But if author needs to use parentheses in both meanings then he can distinguish them, for example `\(` and `\)` for outer marks. These macros can be properly defined. Or, I can use encTeX for auto-recognizing inner and outer braces. But this wasn't the part of the question. – wipet Dec 16 '14 at 19:05