# Hyphenation of words containing apostrophes

My question is plain and simple.

Any way to hyphen words such as “Lor'themar”, “Kel'Thuzad”, etc.?

Using \hyphenation{Kel'-Thu-zad} gives me this error, for instance when compiling.

Error in hyphenation.tex (line 37): Not a letter. l.37 \hyphenation{Kel'
Letters in \hyphenation words must have \lccode>0.
Proceed; I'll ignore the character I just read.


I'd like to define a global hyphenation, but I don't mind using a local definition for each time I want to hyphen those (a bit tedious, but that'd do the job as well).

-
From your question, I am not sure if you are aware that you can write Kel'\-Thu\-zad in running text to get the hyphenation you want. It's a bit tedious indeed … –  Harald Hanche-Olsen Mar 11 '14 at 22:49
That'd do the trick. As I use ShareLaTeX and i know which exact lines are overfull, it's not a big deal. My problem will come when I code the book as ePub. But that's another story. –  Alfredo Hernández Mar 11 '14 at 23:00
If you add \lccode\'=39 just before your \hyphenation command, I believe it will not complain and it will do the trick. I also believe it will not break much in the rest of your text... –  nickie Mar 11 '14 at 23:15
Just a question, shall I added before every \hyphenation with an apostrophe, or just one time changes every \hyphenation from there on? –  Alfredo Hernández Mar 11 '14 at 23:22
It turns out that it's needed before every one containing an apostrophe. –  Alfredo Hernández Mar 11 '14 at 23:33

As explained in my answer to Listings and Babel (with some languages) are breaking hyphenation, characters with a non zero \lccode are those that TeX considers as forming words, when hyphenation is tried.

Thus in

 the masters''


only the and masters are considered as words under normal settings, where  and ' have zero \lccode. If

\lccode\'=\'


(which is equivalent to having 39 after =) is issued at the top level, the phrase above will have the “word”

masters''


and TeX will happily hyphenate it as

master-
s“

because this respects the rule that a hyphen must have at least three letters after it (in the English hyphenation rules there's \righthyphenmin=3) and the pattern aster5 in hyphen.tex makes this into a very good hyphenation point.

For this reason, characters with zero \lccode are not allowed in \hyphenation.

My advice is to use a macro for those apostrophes and something like

\documentclass{article}

\newcommand{\?}{'\-\nobreak\hspace{0pt}}

\begin{document}

\begin{minipage}{0pt}
and Lor\?themar felt that Kel\?Thuzad's controlled tone
\end{minipage}

\end{document}


where the zero width minipage is just to trigger as much hyphenation as possible.

-

Thanks to the comments I realised the are two ways to accomplish what I needed. In the examples I'll be using the word Lor'themar.

## Global definition (in the preamble):

\lccode\'=39\hyphenation{Lor'-the-mar}


## Local definition (in running text):

[...] Aethas replied, and Lor'\-the\-mar felt that his controlled tone [...]


Both ways seem to be equally efficient (apparently using \lccode\=\ may have adverse effects, as pointed out by egreg). But for convenience (not only I'm writing the text in LaTeX but also making an ePub version) I'm using the first method: the global definition.

-
Setting \lccode\=\ may have adverse effects, see listings and babel with some languages are breaking hyphenation. –  egreg Mar 11 '14 at 23:42
@egreg I have a question. I've noticed that if I write \lccode\'=39 in a separate line I can define as much \hyphenation{} for words containing apostrophes. However, If done as in the example (i.e., \lccode\'=39\hyphenation{Lor'-the-mar}) I have to write \lccode\'=39 before each line, which makes me think it only affects that specific word. Is this correct? Does this method avoid the adverse effects you linked out? –  Alfredo Hernández Mar 11 '14 at 23:52
Once you set \lccode\'=39, the apostrophe is available inside \hyphenation, but it also becomes a "word making" character, as explained in my answer to the linked question. If you don't fear about this problem (but you should, depending on how apostrophes are used in the document language), you don't need to repeat the declaration for every \hyphenation command; actually you can have a space separated list of words in a single \hyphenation command. –  egreg Mar 11 '14 at 23:59
Will I experience any problems when using English in babel? I actually don't mind using the second method, it's just a bunch of words in a very specific location in the text, but the first is easier to implement. –  Alfredo Hernández Mar 12 '14 at 0:07
Closing double quotes might trigger unwanted hyphenation. For instance masters'' might be hyphenated master-s''. It won't happen if you use UTF-8 and input it as masters”` –  egreg Mar 12 '14 at 0:24