我确实有一份基本上是英文的文档,有时需要嵌入其他语言的文本(即更改为其他,然后更改为英语)。我尝试在序言中加载两种语言,如下所示
\ifx\UseAlsoOther\undefined
\usepackage[english]{babel}
\else
\usepackage[Other,english]{babel}
\fi
\selectlanguage{english}
基本上它可以工作,但如果定义了 \UseAlsoOther,则章节、部分等会以其他语言输出。我做错了什么?
答案1
如果您的 documentclass 选项中也有 english,则会发生这种情况。在这种情况下,您将语言“english,other,english”传递给 babel,然后 babel 会忽略第二个 english:
\documentclass[english]{article}
\usepackage[ngerman,english]{babel}
\begin{document}
\tableofcontents
\end{document}
这发出警告
Package babel Warning: Last declared language option is `english',
(babel) but the last processed one was `ngerman'.
(babel) The main language cannot be set as both a global
(babel) and a package option. Use `main=english' as
(babel) option. Reported on input line 404.