# Add hyphenation pattern for word with special characters

The \hyphenation command can be used to add extra hyphenation patterns globally to a document. This is useful for special words, that are not present in the general hyphenation patterns.

\hyphenation{
chro-no-ampe-ro-met-ric
mic-ro-graphs}


The above example results in LaTeX being able to optionally hyphenate the two words "chronoamperometric" and "micrographs" at all places where they contain dashes.

\hyphenation{
chro-mium-(III)
chro-no-am-pe-ro-met-ric
mic-ro-graphs}


I would like to add words such as "chromium(III)" to the hyphenation patterns (as in the example above), but the parentheses cause an error ("Not a letter"). How can words with parentheses be automatically hyphenated?

Ideally, I would also like to be able to specify to LaTeX that for any word that is already in the hyphenation rules, continue to hyphenate it also if it is followed by something within parentheses, and add the possibility to hyphenate between the word and the left parenthesis.

• – Dan Aug 26 '13 at 18:36
• @Dan - In this case, it's not even necessary to go the route of inserting explicit \discretionary statements. Defining a macro, say \CrIII, with \newcommand{\CrIII}{chro\-mium\-(III)} will do the job. – Mico Aug 26 '13 at 19:42
• @Mico good to know! – Dan Aug 26 '13 at 19:56
• I was hoping to find a way to do this without having to use macros as suggested by Mico, but it is of course a workaround that can be used. I want hyphenation to continue working also for normal words in parentheses, and as far as I understand, this would stop working with the solution suggested in the link in Dan's comment. – hjb981 Aug 28 '13 at 12:22

Taking Daи's pointer in the first comment, hyphenation next to a parenthesis, and going to David's Carlisle's answer, reveals that one need not use macros (Mico's suggestion) to accomplish the task. Indeed, hyphenation can even occur within the parentheses, as shown in the last example.

\documentclass{article}
\lccode$$\( \lccode$$\)
\lccode$\[ \lccode$\]

\hyphenation{chro-mium-(III)}
\hyphenation{lam-bic-(Bel-gian)}

\setlength\textwidth{1mm} % just for this example
\begin{document}

. chromium(III) % start with some character b/c pdflatex doesn't hyphenate the first word of a paragraph

. lambic(Belgian)

\end{document}


At that answer, when Lover of Structure asked "Do your first four commands have side effects?", David replied

"yes they make ()[] letters for the hyphenation algorithm so (foobar) will be looked up as the 8 letter word (foobar) not the 6 letter word foobar, this can affect hyphenation all over. But if you restrict it to areas just containing technical constructs it's probably ok as natural language hyphenation patterns are not always appropriate there anyway."

I should add (Steven talking again) that David's words "affect hyphenation all over" should not be taken to mean "prevent hyphenation of parenthesized words not specifically set with a hyphenation pattern." In the following MWE, we see that the \lccode definitions do not prevent the hyphenation of words enclosed in parentheses:

\documentclass{article}
\lccode$$\( \lccode$$\)
\lccode$\[ \lccode$\]

\setlength\textwidth{1in} % just for this example
\begin{document}
Testing (calisthenics)

Testing calisthenics
\end{document}


• Nice write-up. I've taken the liberty of (i) removing the hyphens from "Chromium(III)" and simplifying the body of the document. – Mico Mar 15 '14 at 6:42