[Tex/LaTex] Line break long chemical names that contain brackets

chemistryline-breaking

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?

Best Answer

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 bpchembut 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)}