当我开始撰写论文时,我使用了包ngerman
。之后,我发现已经ngerman
过时了,babel
应该改用。我将文档中的包从 更改为 ,\usepackage{ngerman}
因为\usepackage[english]{babel}
我无论如何都是用英语撰写论文的。编译时,pdflatex 报告以下致命错误:
TeX capacity exceeded, sorry [input stack size=5000]. \LdfInit\CurrentOption{date\CurrentOption}
第 47 行english.ldf
是注释块后的第一行:
%%
%% This is file `english.ldf',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% english.dtx (with options: `english,code')
%% This is a generated file.
%%
%% Copyright 1989-2005 Johannes L. Braams and any individual authors
%% 2013-2017 Javier Bezos, Johannes L. Braams and any individual authors
%% listed elsewhere in this file. All rights reserved.
%%
%% This file was generated from file(s) of the Babel system.
%% ---------------------------------------------------------
%%
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The Current Maintainer of this work is Javier Bezos.
%%
%% This file may only be distributed together with a copy of the Babel
%% system. You may however distribute the Babel system without
%% such generated files.
%%
%% The list of all files belonging to the Babel distribution is
%% given in the file `manifest.bbl'. See also `legal.bbl for additional
%% information.
%%
%% The list of derived (unpacked) files belonging to the distribution
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension .ins) which are part of the distribution.
\ProvidesLanguage{english}
[2017/06/06 v3.3r English support from the babel system]
%% File 'english.dtx'
%% Babel package for LaTeX version 2e
%% Copyright (C) 1989 - 2005
%% by Johannes Braams, TeXniek
%% 2013-2017 Javier Bezos, Johannes Braams
\LdfInit\CurrentOption{date\CurrentOption}
\ifx\l@english\@undefined
\ifx\l@UKenglish\@undefined
\ifx\l@british\@undefined
\ifx\l@american\@undefined
\ifx\l@USenglish\@undefined
\ifx\l@canadian\@undefined
\ifx\l@australian\@undefined
\ifx\l@newzealand\@undefined
\@nopatterns{English}
\adddialect\l@english0
\else
\let\l@english\l@newzealand
\fi
\else
\let\l@english\l@australian
\fi
\else
\let\l@english\l@canadian
\fi
\else
\let\l@english\l@USenglish
\fi
\else
\let\l@english\l@american
\fi
\else
\let\l@english\l@british
\fi
\else
\let\l@english\l@UKenglish
\fi
\fi
\ifx\l@british\@undefined
...
将 ngerman 包更改为 babel 包存在什么问题?
更新:问题来自 cls 文件,它是 apa6 的衍生版本,我所在的大学对其进行了更改。cls 文件需要ngerman
并加载它。当在前言中加载 babel 时,会导致此错误。
答案1
我可以用
\documentclass{article}
\usepackage{ngerman}
\usepackage[english]{babel}
\begin{document}
Some text
\end{document}
获得
! TeX capacity exceeded, sorry [input stack size=10000].
<argument> \bbl@tempe
USenglish
l.47 \LdfInit\CurrentOption{date\CurrentOption}
你必须从您的文档中删除\usepackage{ngerman}
。也许加载隐藏在某个文件中\input
。
避免类加载可怕的包的一个可能的解决方法是使用以下代码开始文档
\makeatletter
\disable@package@load{ngerman}{}
\makeatother
\documentclass[<options>]{<class>}
但如果该类使用的特定功能,ngerman
你就注定失败了。
答案2
我可以在不加载“german”或“ngerman”包的情况下重现该错误:
\documentclass{文章} \newcommand{\originalTeX}{\selectlanguage{英语}} \usepackage[german]{babel} \开始{文档} 一些文本 \结束{文档}
问题的根源在于\originalTeX
一些(较旧的)包中的定义以及它在 Babel 核心包中的处理方式。
如果\originalTeX
定义了并且其定义\selectlanguage
与默认语言有关,则 Babel 将进入无限扩展循环,导致“输入堆栈”溢出错误。
这个问题的一个快速而肮脏的修复:重新定义\originalTeX
为空,如果在调用它之前加载了“(n)german”或其他较旧的包,即,
\documentclass{文章} \usepackage{ngerman} \originalTeX % 将所有内容重置为默认语言 \renewcommand{\originalTeX}{}% 避免 babel 的无限扩展循环 \usepackage[german]{babel} \开始{文档} 一些文本 \结束{文档}
完整的修复必须在 (a) 在 Babel 中决定如何在加载 Babel 包时处理所有内容之后和/或 (b) 在“(n)german.sty”中完成(例如,只需加载并使用带有 german/ngerman 选项的 Babel 包即可绕过所有旧定义)。