TeX 容量超出

TeX 容量超出

以下是一个演示我的问题的简单示例。错误

TeX capacity exceeded, sorry [input stack size=5000] \end{latexresult}

或多或少取决于代码行数,而不是实际代码(因此它很长)。几乎可以注释掉任何一行,错误就会消失。我不知道是什么原因导致了这个问题。我脑子里有 mdframed,但看不出是什么导致了错误。

\documentclass[]{scrbook}

\usepackage{url}
\RequirePackage{etoolbox}
\RequirePackage{filecontents}
\RequirePackage{mdframed}

\RequirePackage{listings}

\lstnewenvironment{latexcode}{}{}
\newenvironment{latexresult}{%
Result:
\mdframed[skipabove=6pt]%
}{
\endmdframed
\noindent
}

\listfiles

\begin{document}

\chapter{template demonstration}
\section{text markup}
\subsection{standard commands}
%
\begin{filecontents*}{democode}
The standard commands for font attributes:  
\textbf{bold}, \textit{italic}, \textsl{slanted},
\textsf{sans serif}, \textsc{small caps} and
\texttt{monospaced typewrite}.
And any combination of them:
\textit{\textbf{bold italic}},
\textsl{\textbf{bold slanted}},
\textsf{\textbf{bold sans serif}},
\textsc{\textbf{bold small caps}}
\textsl{\textsf{sans serif slanted}}. 
\end{filecontents*}

Code: 
\lstinputlisting{democode.tex}%
\begin{latexresult}%
\IfFileExists{democode.tex}{\input{democode.tex}}{}%
\end{latexresult}

\begin{filecontents*}{democode}
\url{http://www.dante.de} \\
\end{filecontents*}

\ifcsdef{url}{%
\subsection{package: url}

The url package provides a failsafe way to print
urls with characters not allowed by LaTeX.

\begin{minipage}[t]{0.49\textwidth}
\begin{latexresult}%
\IfFileExists{democode.tex}{\input{democode.tex}}{}%
\end{latexresult}
\end{minipage}

The font used for this command can be set up in the preamble.
}{}%

\section{paragraph alignment}
\subsection{standard alignment}

\begin{minipage}[t]{0.49\textwidth}
\begin{latexresult}%
\IfFileExists{democode.tex}{\input{democode.tex}}{}%
\end{latexresult}
\end{minipage}

\end{document}

编辑:我取消注释了一行以让它再次编译,然后得到这个文件列表:

*File List*
scrbook.cls 2011/06/16 v3.09a KOMA-Script document class (book)
scrkbase.sty 2011/06/16 v3.09a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
scrbase.sty 2011/06/16 v3.09a KOMA-Script package (KOMA-Script-independent
basics and keyval usage)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty 2011/03/09 v3.09 KOMA-Script package (loading files)
tocbasic.sty 2011/05/30 v3.09a KOMA-Script package (handling toc-files)
scrsize11pt.clo 2011/06/16 v3.09a KOMA-Script font size class option (11pt)
typearea.sty 2011/06/16 v3.09a KOMA-Script package (type area)
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
etoolbox.sty 2011/01/03 v2.1 e-TeX tools for LaTeX
etex.sty 1998/03/26 v2.0 eTeX basic definition package (PEB)
filecontents.sty 2009/03/17 v1.2 Create an external file from within a LaTeX
document
mdframed.sty 2011/08/22 v0.8: mdframed
kvoptions.sty 2010/12/23 v3.10 Keyval support for LaTeX options (HO)
ltxcmds.sty 2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
kvsetkeys.sty 2011/04/07 v1.13 Key value parser (HO)
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/message (HO)
etexcmds.sty 2011/02/16 v1.5 Prefix for e-TeX command names (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
calc.sty 2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
color.sty 2005/11/14 v1.0j Standard LaTeX Color (DPC)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
md-frame-0.mdf 2011/08/22 v0.8: md-frame-0
listings.sty 2007/02/22 1.4 (Carsten Heinz)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
supp-pdf.mkii
democode.tex
omscmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
democode.tex
democode.tex
***********

之后我更新了 texlive,然后 mdframed 更改为 0.9e 版本,并且加载了许多之前未加载的包:

mdframed.sty 2011/09/11 v0.9e: mdframed
...
zref-abspage.sty 2011/03/18 v2.21 Module abspage for zref (HO)
zref-base.sty 2011/03/18 v2.21 Module base for zref (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Defining keys (HO)
pdftexcmds.sty 2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
auxhook.sty 2011/03/04 v1.3 Hooks for auxiliary files (HO)
atbegshi.sty 2011/01/30 v1.15 At begin shipout hook (HO)
md-frame-0.mdf 2011/09/10 v0.9e: md-frame-0

现在编译时没有错误。

答案1

正如评论中提到的,使用 TeXLive2011 编译提供的代码对我来说很好,所以也许你正在使用某个软件包的旧版本。以下内容不是此处报告的问题的直接解决方案,而是显示代码的另一种方式:

如果你想显示 LaTeX 代码及其输出,你应该考虑使用包裹showexpl随着包裹listings因为这会产生非常好的输出:

在此处输入图片描述

\documentclass[]{scrbook}

\usepackage{url}
\usepackage{xcolor}

\usepackage{listings}
\usepackage{showexpl}
    \lstset{
        backgroundcolor=\color{yellow},
        basicstyle=\small\ttfamily,% print whole listing small
        keywordstyle=\color{blue}\bfseries\underbar,
        numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,
        showstringspaces=false
    }
    \lstloadlanguages{[LaTeX]TeX}


\begin{document}
\begin{LTXexample}[pos=b]
The standard commands for font attributes:  
\textbf{bold}, \textit{italic}, \textsl{slanted},
\textsf{sans serif}, \textsc{small caps} and
\texttt{monospaced typewrite}.
And any combination of them:
\textit{\textbf{bold italic}},
\textsl{\textbf{bold slanted}},
\textsf{\textbf{bold sans serif}},
\textsc{\textbf{bold small caps}}
\textsl{\textsf{sans serif slanted}}. 
\end{LTXexample}

The url package provides a failsafe way to print
urls with characters not allowed by LaTeX.

\begin{LTXexample}
\url{http://www.dante.de}
\end{LTXexample}
\end{document}

相关内容