当我使用 babel 加载多种语言时,我的连字例外不会被使用。以下是一个例子:
====== hy.tex =======
\hyphenation{para-dichloro-diphenyl-trichloro-ethane}
====== 测试.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}
我的连字例外不被遵守。\selectlanguage
但是,如果我删除,连字例外就会起作用。
答案1
\hyphenation
命令引用当前语言,并babel
在文档主体开头切换为法语。您的示例按预期工作,在切换为英语hy.tex
后加载\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}
另外,看看为多语言文档指定多个连字例外列表。