Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I use babel with more than one language loaded, my hyphenation exceptions are not used. Here is an example:

====== hy.tex =======

\hyphenation{para-dichloro-diphenyl-trichloro-ethane}

====== test.tex ======

\documentclass{article}
\usepackage[english,french]{babel}
\selectlanguage{english}
\input{hy}

\begin{document}
paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane 
\end{document}

My hyphenation exception is not respected. If I remove \selectlanguage, however, the hyphenation exception works.

share|improve this question
    
Thanks for accepting my answer, but please also upvote it (by clicking on the upward-pointing pen nib; upvoting has to be done separately from accepting an answer). –  lockstep Jul 26 '12 at 16:54
add comment

1 Answer 1

up vote 13 down vote accepted

\hyphenation commands refer to the current language, and babel switches to French at the start of your document body. Your example works as intended by switching to English and loading hy.tex after \begin{document}.

\documentclass{article}

\usepackage[english,french]{babel}

\usepackage{filecontents}

\begin{filecontents}{hy.tex}
\hyphenation{para-dichloro-diphenyl-trichloro-ethane}
\end{filecontents}

\begin{document}

\selectlanguage{english}
\input{hy}

\languagename

paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane paradichlorodiphenyltrichloroethane 
\end{document}

enter image description here

Also, have a look at Specifying multiple hyphenation exception lists for multi-lingual documents.

share|improve this answer
    
Thank you. I appreciate your help. –  PSH Jul 26 '12 at 16:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.