13

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.

1
  • 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
14

\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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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