考虑以下 MWE;假设您将其保存在 中foo.tex
。
\documentclass{article}
\setcounter{secnumdepth}{0}
\usepackage{polyglossia}
\setmainlanguage{english}
\setkeys{english}{variant=british}
% \usepackage[UKenglish]{babel}
\begin{document}
\section{Report of the PRESIDENTIAL COMMISSION on the Space Shuttle
Challenger
Accident}
\subsection{Volume 2: Appendix F - Personal Observations on Reliability
of
Shuttle}
by R. P. Feynman
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
\end{document}
使用 进行编译$ xelatex foo.tex
。在生成的 PDF 中,“可靠性”一词错误地拆分为 Reliab-ility。根据牛津高级词典(死树版),正确的连字符是 re-li-abil-ity。注释行\usepackage{polyglossia}
和其后的两行,然后取消注释babel
行,将得到相同的结果。
现在注释掉该\setkeys
行(即使用“正常”英语)。该词现在被正确拆分为 Relia-bility。babel
与非英国英语一起使用也会导致正确拆分。
polyglossia
这是和中的拼写错误吗babel
?还是这两个软件包所依赖的某个文件中的拼写错误(可能是 UK-lang 特定设置的文件)?如果能帮助我调试这个问题,我们将不胜感激。
答案1
答案2
确实,与 LaTeX 进行交互
> latex
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=latex)
restricted \write18 enabled.
**\relax
entering extended mode
LaTeX2e <2015/01/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
*\makeatletter\language=\l@british
*\showhyphens{reliability}
Underfull \hbox (badness 10000) detected at line 0
[] \OT1/cmr/m/n/10 re-li-ab-il-ity
表明英式英语的连字模式比字典中提供的连字点多一个。这并不意味着“错误”,本身。您可以在适当的邮件列表;但这是我们无法polyglossia
控制babel
的事情。
如果您认为连字符错误,您可以修复它:
\documentclass{article}
\setcounter{secnumdepth}{0}
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
% see http://tex.stackexchange.com/questions/229915/polyglossia-ignores-my-custom-hyphenation
\newcommand{\sethyphenation}[2]{%
\AtBeginDocument{%
\begin{otherlanguage*}{#1}\hyphenation{#2}\end{otherlanguage*}%
}%
}
\sethyphenation{english}{re-li-abil-ity}
\begin{document}
\section{Report of the PRESIDENTIAL COMMISSION on the Space Shuttle
Challenger
Accident}
\subsection{Volume 2: Appendix F - Personal Observations on Reliability
of
Shuttle}
by R. P. Feynman
For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
\end{document}
\sethyphen
对于特定语言,您可以在命令中指定任意数量的单词。