为什么我得到一个 ! TeX 容量超出,抱歉 [输入堆栈大小=5000] 列表

为什么我得到一个 ! TeX 容量超出,抱歉 [输入堆栈大小=5000] 列表

我有以下内容,我相信这是一个几乎最小的示例(除了我正在使用的包),使用包listings

\documentclass[12pt]{article}

\usepackage{lmodern}
\usepackage[scaled]{beramono}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\usepackage[margin=1in]{geometry}
\usepackage{listings}

\usepackage{xcolor}
\definecolor{javacommentscolor}{HTML}{646464}
\definecolor{javakeywordscolor}{HTML}{7F0055}
\definecolor{javastringscolor}{HTML}{2A00FF}

%% Java
\lstdefinestyle{%
  language=java,
  basicstyle=\footnotesize\ttfamily, % code to be displayed as monospace
  breaklines=true,
  %frame=b
  commentstyle=\color{javacommentscolor},
  keywordstyle=\color{javakeywordscolor},
  stringstyle=\color{javastringscolor},
  showstringspaces=false,  % do not show string spaces character
  tabsize=4,  % change tabs to spaces
  keywordsprefix={@},  % capture method annotations and doctools
}

\definecolor{pythoncommentscolor}{HTML}{999988}
\definecolor{pythonkeywordscolor}{HTML}{000000}
\definecolor{pythonstringscolor}{HTML}{DD1144}

%% Python
\lstdefinestyle{%
  language=python,
  basicstyle=\footnotesize\ttfamily,
  breaklines=true,
  commentstyle=\color{pythoncommentscolor},
  keywordstyle\color{pythonkeywordscolor},
  stringstyle\color{pythonstringscolor},
  showstringspaces=false,
  tabsize=4
}

\begin{document}

\begin{figure}[t!]
  \centering
  \lstinputlisting[style=java]{/home/brandon/eclipse-workspace/ift_194_labs/src/lab_1/Driver.java}
  \caption{Driver.java}
  \label{fig:one}
\end{figure}

\begin{figure}
  \centering
  \lstinputlisting[style=java]{/home/brandon/eclipse-workspace/ift_194_labs/src/lab_1/Count.java}
  \caption{Count.java}
  \label{fig:two}
\end{figure}

\begin{figure}
  \centering
  \lstinputlisting[style=python]{/home/brandon/projects/visual-inspection-python/tests/test_onto.py}
  \caption{test\_onto.py}
  \label{fig:three}
\end{figure}

\end{document}

目标是在 Java 程序/文件上使用java带有 s 的样式,在 Python 脚本上使用带有 s 的样式。但是,我不知道如何实现这一点而不出现以下错误\lstinputlistingpython

! TeX capacity exceeded, sorry [input stack size=5000].

这是我的.log文件。任何帮助都将不胜感激,因为我觉得仍然有很多了解 LaTeX。

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2018.4.16)  1 JUL 2018 11:15
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**codetest.tex
(./codetest.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
File: size12.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texmf/tex/latex/lm/lmodern.sty
Package: lmodern 2009/10/30 v1.6 Latin Modern Fonts
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  OT1/cmr/m/n --> OT1/lmr/m/n on input line 22.
LaTeX Font Info:    Overwriting symbol font `letters' in version `normal'
(Font)                  OML/cmm/m/it --> OML/lmm/m/it on input line 23.
LaTeX Font Info:    Overwriting symbol font `symbols' in version `normal'
(Font)                  OMS/cmsy/m/n --> OMS/lmsy/m/n on input line 24.
LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `normal'
(Font)                  OMX/cmex/m/n --> OMX/lmex/m/n on input line 25.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 26.
LaTeX Font Info:    Overwriting symbol font `letters' in version `bold'
(Font)                  OML/cmm/b/it --> OML/lmm/b/it on input line 27.
LaTeX Font Info:    Overwriting symbol font `symbols' in version `bold'
(Font)                  OMS/cmsy/b/n --> OMS/lmsy/b/n on input line 28.
LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `bold'
(Font)                  OMX/cmex/m/n --> OMX/lmex/m/n on input line 29.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `normal'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 31.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `normal'
(Font)                  OT1/cmss/m/n --> OT1/lmss/m/n on input line 32.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `normal'
(Font)                  OT1/cmr/m/it --> OT1/lmr/m/it on input line 33.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `normal'
(Font)                  OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 34.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `bold'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 35.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `bold'
(Font)                  OT1/cmss/bx/n --> OT1/lmss/bx/n on input line 36.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `bold'
(Font)                  OT1/cmr/bx/it --> OT1/lmr/bx/it on input line 37.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `bold'
(Font)                  OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 38.
)
(/usr/share/texlive/texmf-dist/tex/latex/bera/beramono.sty
Package: beramono 2004/01/31 (WaS)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package

(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def
File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 48.
))
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols

(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks15
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2016/03/03 v2.15a AMS math features
\@mathmargin=\skip43

For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text

(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks16
\ex@=\dimen103
))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen104
)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 1999/12/14 v2.01 operator names
)
\inf@bad=\count87
LaTeX Info: Redefining \frac on input line 199.
\uproot@=\count88
\leftroot@=\count89
LaTeX Info: Redefining \overline on input line 297.
\classnum@=\count90
\DOTSCASE@=\count91
LaTeX Info: Redefining \ldots on input line 394.
LaTeX Info: Redefining \dots on input line 397.
LaTeX Info: Redefining \cdots on input line 518.
\Mathstrutbox@=\box26
\strutbox@=\box27
\big@size=\dimen105
LaTeX Font Info:    Redeclaring font encoding OML on input line 630.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 631.
\macc@depth=\count92
\c@MaxMatrixCols=\count93
\dotsspace@=\muskip10
\c@parentequation=\count94
\dspbrk@lvl=\count95
\tag@help=\toks17
\row@=\count96
\column@=\count97
\maxfields@=\count98
\andhelp@=\toks18
\eqnshift@=\dimen106
\alignsep@=\dimen107
\tagshift@=\dimen108
\tagwidth@=\dimen109
\totwidth@=\dimen110
\lineht@=\dimen111
\@envbody=\toks19
\multlinegap=\skip44
\multlinetaggap=\skip45
\mathdisplay@stack=\toks20
LaTeX Info: Redefining \[ on input line 2735.
LaTeX Info: Redefining \] on input line 2736.
)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2012/11/06 v6.83m Hypertext links for LaTeX

(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
Package: hobsub-hyperref 2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)


(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty
Package: hobsub-generic 2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
Package: hobsub 2012/05/28 v1.13 Construct package bundles (HO)
Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO)
Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
Package: ifvtex 2010/03/01 v1.5 Detect VTeX and its facilities (HO)
Package ifvtex Info: VTeX not detected.
Package: intcalc 2007/09/27 v1.1 Expandable calculations with integers (HO)
Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO)
Package ifpdf Info: pdfTeX in PDF mode is detected.
Package: etexcmds 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO)
Package: kvdefinekeys 2011/04/07 v1.3 Define keys (HO)
Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
Package: pdfescape 2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
Package: bigintcalc 2012/04/08 v1.3 Expandable calculations on big integers (HO
)
Package: bitset 2011/01/30 v1.1 Handle bit-vector datatype (HO)
Package: uniquecounter 2011/01/30 v1.2 Provide unlimited unique counter (HO)
)
Package hobsub Info: Skipping package `hobsub' (already loaded).
Package: letltxmacro 2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
Package: hopatch 2012/05/28 v1.2 Wrapper for package hooks (HO)
Package: xcolor-patch 2011/01/30 xcolor patch
Package: atveryend 2011/06/30 v1.8 Hooks at the very end of document (HO)
Package atveryend Info: \enddocument detected (standard20110627).
Package: atbegshi 2011/10/05 v1.16 At begin shipout hook (HO)
Package: refcount 2011/10/16 v3.4 Data extraction from label references (HO)
Package: hycolor 2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty
Package: auxhook 2011/03/04 v1.3 Hooks for auxiliary files (HO)
)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2011/06/30 v3.11 Key value format for package options (HO)
)
\@linkdim=\dimen112
\Hy@linkcounter=\count99
\Hy@pagecounter=\count100

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
)
\Hy@SavedSpaceFactor=\count101

(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg
File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
)
Package hyperref Info: Option `colorlinks' set `true' on input line 4319.
Package hyperref Info: Hyper figures OFF on input line 4443.
Package hyperref Info: Link nesting OFF on input line 4448.
Package hyperref Info: Hyper index ON on input line 4451.
Package hyperref Info: Plain pages OFF on input line 4458.
Package hyperref Info: Backreferencing OFF on input line 4463.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4688.
\c@Hy@tempcnt=\count102

(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip11
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 5041.
\XeTeXLinkMargin=\dimen113
\Fld@menulength=\count103
\Field@Width=\dimen114
\Fld@charsize=\dimen115
Package hyperref Info: Hyper figures OFF on input line 6295.
Package hyperref Info: Link nesting OFF on input line 6300.
Package hyperref Info: Hyper index ON on input line 6303.
Package hyperref Info: backreferencing OFF on input line 6310.
Package hyperref Info: Link coloring ON on input line 6313.
Package hyperref Info: Link coloring with OCG OFF on input line 6320.
Package hyperref Info: PDF/A mode OFF on input line 6325.
LaTeX Info: Redefining \ref on input line 6365.
LaTeX Info: Redefining \pageref on input line 6369.
\Hy@abspage=\count104
\c@Item=\count105
\c@Hfootnote=\count106
)

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def
File: hpdftex.def 2012/11/06 v6.83m Hyperref driver for pdfTeX
\Fld@listcount=\count107
\c@bookmark@seq@number=\count108

(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty
Package: rerunfilecheck 2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
82.
)
\Hy@SectionHShift=\skip46
)
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
Package: geometry 2010/09/12 v5.6 Page Geometry
\Gm@cnth=\count109
\Gm@cntv=\count110
\c@Gm@tempcnt=\count111
\Gm@bindingoffset=\dimen116
\Gm@wd@mp=\dimen117
\Gm@odd@mp=\dimen118
\Gm@even@mp=\dimen119
\Gm@layoutwidth=\dimen120
\Gm@layoutheight=\dimen121
\Gm@layouthoffset=\dimen122
\Gm@layoutvoffset=\dimen123
\Gm@dimlist=\toks21
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.sty
\lst@mode=\count112
\lst@gtempboxa=\box28
\lst@token=\toks22
\lst@length=\count113
\lst@currlwidth=\dimen124
\lst@column=\count114
\lst@pos=\count115
\lst@lostspace=\dimen125
\lst@width=\dimen126
\lst@newlines=\count116
\lst@lineno=\count117
\lst@maxwidth=\dimen127

(/usr/share/texlive/texmf-dist/tex/latex/listings/lstmisc.sty
File: lstmisc.sty 2015/06/04 1.6 (Carsten Heinz)
\c@lstnumber=\count118
\lst@skipnumbers=\count119
\lst@framebox=\box29
)
(/usr/share/texlive/texmf-dist/tex/latex/listings/listings.cfg
File: listings.cfg 2015/06/04 1.6 listings configuration
))
Package: listings 2015/06/04 1.6 (Carsten Heinz)

(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2007/01/21 v2.11 LaTeX color extensions (UK)

(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg
File: color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
)
Package xcolor Info: Driver file: pdftex.def on input line 225.

(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
\Gread@gobject=\count120
)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1337.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1341.
Package xcolor Info: Model `RGB' extended on input line 1353.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1355.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1356.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1357.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1358.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1359.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1360.
)
! TeX capacity exceeded, sorry [input stack size=5000].
\@setfontsize #1#2#3->\@nomath #1
                                 \ifx \protect \@typeset@protect \let \@curr...
l.29 }

If you really absolutely need more capacity,
you can ask a wizard to enlarge me.


Here is how much of TeX's memory you used:
 7403 strings out of 493029
 104047 string characters out of 6136234
 221009 words of memory out of 5000000
 10925 multiletter control sequences out of 15000+600000
 4702 words of font info for 16 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 5000i,0n,7501p,242b,220s stack positions out of 5000i,500n,10000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!

答案1

\lstdefinestyle接受两个参数,而不是一个:\lstdefinestyle{stylename}{key=values}。这应该有效:

将你的 java 样式设置为,\lstdefinestyle{JavaStyle}{...}然后使用 调用它\lstinputlisting[style=JavaStyle]{...}。你还忘记了键值中的一些等号。以下是你的完整代码:

\documentclass[12pt]{article}

\usepackage{lmodern}
\usepackage[scaled]{beramono}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\usepackage[margin=1in]{geometry}
\usepackage{listings}

\usepackage{xcolor}
\definecolor{javacommentscolor}{HTML}{646464}
\definecolor{javakeywordscolor}{HTML}{7F0055}
\definecolor{javastringscolor}{HTML}{2A00FF}

%% Java
\lstdefinestyle{JavaStyle}{%
  language=java,
  style=\footnotesize\ttfamily, % code to be displayed as monospace
  breaklines=true,
  %frame=b
  commentstyle=\color{javacommentscolor},
  keywordstyle=\color{javakeywordscolor},
  stringstyle=\color{javastringscolor},
  showstringspaces=false,  % do not show string spaces character
  tabsize=4,  % change tabs to spaces
  keywordsprefix={@},  % capture method annotations and doctools
}

\definecolor{pythoncommentscolor}{HTML}{999988}
\definecolor{pythonkeywordscolor}{HTML}{000000}
\definecolor{pythonstringscolor}{HTML}{DD1144}

%% Python
\lstdefinestyle{PythonStyle}{%
  language=python,
  style=\footnotesize\ttfamily,
  breaklines=true,
  commentstyle=\color{pythoncommentscolor},
  keywordstyle=\color{pythonkeywordscolor},
  stringstyle=\color{pythonstringscolor},
  showstringspaces=false,
  tabsize=4
}

\begin{document}

\begin{figure}[t!]
  \centering
  \lstinputlisting[basicstyle=JavaStyle]{/home/brandon/eclipse-workspace/ift_194_labs/src/lab_1/Driver.java}
  \caption{Driver.java}
  \label{fig:one}
\end{figure}

\begin{figure}
  \centering
  \lstinputlisting[basicstyle=JavaStyle]{/home/brandon/eclipse-workspace/ift_194_labs/src/lab_1/Count.java}
  \caption{Count.java}
  \label{fig:two}
\end{figure}

\begin{figure}
  \centering
  \lstinputlisting[basicstyle=PythonStyle]{/home/brandon/projects/visual-inspection-python/tests/test_onto.py}
  \caption{test\_onto.py}
  \label{fig:three}
\end{figure}

\end{document}

相关内容