使用 Babel 处理多种语言时,断字异常不会加载

使用 Babel 处理多种语言时,断字异常不会加载

当我使用 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}

在此处输入图片描述

另外,看看为多语言文档指定多个连字例外列表

相关内容