包含 Tikz-PGF 图形时出现“TeX 容量超出”错误

包含 Tikz-PGF 图形时出现“TeX 容量超出”错误

我有以下 TeX 文件 transfer_report.tex,其中包含两个 Tikz-PGF 图形...

\documentclass[oneside,12pt]{Classes/CUEDthesisPSnPDF}

\begin{document}

% Figure 1
\begin{figure}
    \begin{center}
        \begin{tikzpicture}
            \node [matrix,matrix anchor=mid, column sep=5pt, row sep=20pt] {
            % hidden layer
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (h1) [latent] {$h_1$}; &
            \node (h2) [latent] {$h_2$}; &
            \node (hlabel) [draw=none] {$\mathbf{h}$};
            \\

            % visible layer
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (x1) [latent] {$v_1$}; &
            \node (x2) [latent] {$v_2$}; &
            \node (x3) [latent] {$v_3$}; &
            \node (x4) [latent] {$v_4$}; &
            \node (xlabel) [draw=none] {$\mathbf{v}$}; &        
            \node (inv) [draw=none] {}; &       
            \\
            };

            % connections
            \draw [-] (x1) -- node [left=2pt] {} (h1);
            \draw [-] (x1) -- node [left=2pt] {} (h2);
            \draw [-] (x2) -- node [left=2pt] {} (h1);
            \draw [-] (x2) -- node [left=2pt] {} (h2);
            \draw [-] (x3) -- node [left=2pt] {} (h1);
            \draw [-] (x3) -- node [left=2pt] {} (h2);
            \draw [-] (x4) -- node [left=2pt] {} (h1);
            \draw [-] (x4) -- node [right=2pt] {W} (h2);
        \end{tikzpicture}
    \end{center}
\end{figure}

% Figure 2  
\begin{figure}[here]
    \begin{center}
        \begin{tikzpicture}[thick,scale=0.6, every node/.style={scale=0.6}]
            \node [matrix,matrix anchor=mid, column sep=4pt, row sep=30pt] {
            % hidden layer
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (inv) [draw=none] {}; &
            \node (h1) [latent] {}; &
            \node (h2) [latent] {}; &
            \node (h3) [latent] {}; &
            \node (h4) [latent] {}; &
            \node (dots) [draw=none] {\LARGE $\ldots$}; &
            \node (hn) [latent] {}; &
            \node (hlabel) [draw=none] {\LARGE $\mathbf{h}$};
            \\

            % visible layer input nodes
            \node (x1) [latent] {}; &
            \node (dots1) [draw=none]{\LARGE $\ldots$}; &
            \node (x2) [latent] {}; &
            \node (x3) [latent] {}; &
            \node (dots2) [draw=none] {\LARGE $\ldots$}; &
            \node (x4) [latent] {}; &
            \node (dots3) [draw=none] {\LARGE $\ldots$}; &
            \node (x5) [latent] {}; &
            \node (dots4) [draw=none] {\LARGE $\ldots$}; &
            \node (x6) [latent] {}; &
            \node (dots) [draw=none] {}; &          

            % visible layer class nodes
            \node (y1) [latent] {}; &
            \node (dots5) [draw=none] {\LARGE $\ldots$}; &
            \node (yn) [latent] {}; &
            \node (ylabel) [draw=none] {\LARGE $\mathbf{v}$};
            \\
            };

            % boxes around sets of nodes
            \plate{ph}{(h1)(hn)}{}{};
            \plate{px1}{(x1)(x2)}{}{rounded corners};
            \plate{px2}{(x3)(x4)}{}{rounded corners};
            \plate{px3}{(x5)(x6)}{}{rounded corners};
            \plate{pxx}{(px1)(px3)}{}{rounded corners};
            \plate{py}{(y1)(yn)}{}{rounded corners};
            \node (lab1) [draw=none, below=0.3cm of dots1 {\LARGE $s_{(t - n + 1)}$};
            \node (lab2) [draw=none, below=0.3cm of dots2]{\LARGE $s_{(t - n + 2)}$};
            \node (lab3) [draw=none, below=0.4cm of dots3]{\LARGE $\ldots$};
            \node (lab4) [draw=none, below=0.3cm of dots4]{\LARGE $s_{(t - 1)}$};
            \node (lab5) [draw=none, below=0.3cm of dots5]{\LARGE $s_{(t)}$};

            % connections
            \draw [<->] (ph) -- node [right=20pt] {\LARGE $\mathbf{W}$} (pxx);
            \draw [<->] (ph) -- node {} (py);
        \end{tikzpicture}\tabularnewline
    \end{center}
    \end{figure}

\end{document}

...这是我在上面的 TeX 文件中使用的 CUEDthesisPSnPDF.cls 文件...

%
% CUEDthesis v1.1
% By Harish Bhanderi <[email protected]
% Version 1.0 released 15/07/2002
% Version 1.1 released 14/07/2010
%-------------------------- identification ---------------------
%\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{CUEDthesisPSnPDF}[2010/07/14 v1.1 CUED thesis class]
%-------------------------- initial code -----------------------
\newif\ifCU@bookmode
\CU@bookmodetrue

\DeclareOption{report}{\CU@bookmodefalse}
\DeclareOption{book}{\CU@bookmodetrue}
\ProcessOptions\relax%

\ifCU@bookmode
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}%
\ProcessOptions\relax%
\ifx\pdfoutput\undefined%
   \LoadClass[dvips, a4paper]{book}%
\else%
   \LoadClass[pdftex, a4paper]{book}%
\fi%
\else
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}%
\ProcessOptions\relax%
\ifx\pdfoutput\undefined%
  \LoadClass[dvips, a4paper]{report}%
\else%
   \LoadClass[pdftex, a4paper]{report}%
\fi%
%\renewcommand{\refname}{References}%
\fi

%\DeclareOption{book}{%
%}%
\usepackage{setspace}
\usepackage{tocbibind}
\usepackage{amssymb}
%\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{eucal}
\usepackage[english]{babel}
\usepackage[usenames, dvipsnames]{color}
\usepackage[perpage]{footmisc}
\usepackage[square, sort, numbers, authoryear]{natbib}
\usepackage{ifthen}
\usepackage{ifpdf}
\usepackage{lscape}

% For trees
\usepackage{qtree}

% Tikz stuff
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{fit,chains}

% PGFPlots externalization to avoid exceeding TeX capacity.
% \usepgfplotslibrary{external}
% \tikzexternalize
% ... to be used together with -shell-escape option to pdflatex.

% Helps in debugging version incompatibilities in the .log file
% \listfiles

\tikzset{latent/.style={circle,fill=white,draw=black,inner sep=1pt, 
minimum size=20pt, font=\fontsize{10}{10}\selectfont},
obs/.style={latent,fill=gray!25},
const/.style={rectangle, inner sep=0pt},
factor/.style={rectangle, fill=black,minimum size=5pt, inner sep=0pt},
>={triangle 45}}

\pgfdeclarelayer{b}
\pgfdeclarelayer{f}
\pgfsetlayers{b,main,f}

% shapename, fitlist, caption, pos
\newcommand{\plate}[4]{
    \begin{pgfonlayer}{b}
        \node (invis#1) [draw, color=white, inner sep=2pt,rectangle, fit=#2] {};
    \end{pgfonlayer}

    \begin{pgfonlayer}{f}
        \node (#1) [draw,inner sep=0pt, rectangle,fit=(invis#1),#3,#4] {};
    \end{pgfonlayer}
}


%Bibliography
%uncomment next line to change bibliography name to references for Book document class
\renewcommand{\bibname}{References}
% note that this doesn't do much if you later define another bibliography style 


% Nomenclature
\usepackage{nomencl}
\makenomenclature
\renewcommand\nomgroup[1]{%
  \ifthenelse{\equal{#1}{A}}{%
   \item[\textbf{Roman Symbols}] }{%             A - Roman
    \ifthenelse{\equal{#1}{G}}{%
     \item[\textbf{Greek Symbols}]}{%             G - Greek
      \ifthenelse{\equal{#1}{R}}{%
        \item[\textbf{Superscripts}]}{%              R - Superscripts
          \ifthenelse{\equal{#1}{S}}{%
           \item[\textbf{Subscripts}]}{{%             S - Subscripts
        \ifthenelse{\equal{#1}{X}}{%
         \item[\textbf{Other Symbols}]}{{%    X - Other Symbols
        \ifthenelse{\equal{#1}{Z}}{%
         \item[\textbf{Acronyms}]}%              Z - Acronyms
                        {{}}}}}}}}}}

\ifpdf
%-->
%--> Google.com search "hyperref options"
%--> 
%--> http://www.ai.mit.edu/lab/sysadmin/latex/documentation/latex/hyperref/manual.pdf
%--> http://www.chemie.unibas.ch/~vogtp/LaTeX2PDFLaTeX.pdf 
%--> http://www.uni-giessen.de/partosch/eurotex99/ oberdiek/print/sli4a4col.pdf
%--> http://me.in-berlin.de/~miwie/tex-refs/html/latex-packages.html
%-->
    \usepackage[ pdftex, plainpages = false, pdfpagelabels, 
                 pdfpagelayout = OneColumn, % display single page, advancing flips the page - Sasa Tomic
                 bookmarks,
                 bookmarksopen = true,
                 bookmarksnumbered = true,
                 breaklinks = true,
                 linktocpage,
                 pagebackref,
                 colorlinks = true,
                 linkcolor = blue,
                 urlcolor  = blue,
                 citecolor = red,
                 anchorcolor = green,
                 hyperindex = true,
                 hyperfigures
                 ]{hyperref} 
    \usepackage[pdftex]{graphicx}
    \DeclareGraphicsExtensions{.png, .jpg, .pdf}

    \pdfcompresslevel=9
    \graphicspath{{ThesisFigs/PNG/}{ThesisFigs/PDF/}{ThesisFigs/}}
\else
    \usepackage[ dvips, 
                 bookmarks,
                 bookmarksopen = true,
                 bookmarksnumbered = true,
                 breaklinks = true,
                 linktocpage,
                 pagebackref,
                 colorlinks = true,
                 linkcolor = blue,
                 urlcolor  = blue,
                 citecolor = red,
                 anchorcolor = green,
                 hyperindex = true,
                 hyperfigures
                 ]{hyperref}

    %\usepackage{epsfig}
    \usepackage{graphicx}
    \DeclareGraphicsExtensions{.eps, .ps}
    \graphicspath{{ThesisFigs/EPS/}{ThesisFigs/}}
\fi

%define the page size including an offset for binding
%\setlength{\topmargin}{0.0in}
%\setlength{\oddsidemargin}{0in}
%\setlength{\evensidemargin}{0in}
%\setlength{\textheight}{700pt}
%\setlength{\textwidth}{500pt}


%A4 settings
\ifpdf
   \pdfpageheight=297mm
   \pdfpagewidth=210mm
\else
   \setlength{\paperheight}{297mm}
   \setlength{\paperwidth}{210mm}
\fi

\setlength{\hoffset}{0.00cm}
\setlength{\voffset}{0.00cm}

\setlength{\evensidemargin}{1.96cm}
%\setlength{\oddsidemargin}{-0.54cm}
\setlength{\topmargin}{1mm}
\setlength{\headheight}{1.36cm}
\setlength{\headsep}{1.00cm}
\setlength{\textheight}{20.84cm}
\setlength{\textwidth}{14.5cm}
\setlength{\marginparsep}{1mm}
\setlength{\marginparwidth}{3cm}
\setlength{\footskip}{2.36cm}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter. #1 }}{}}
\renewcommand{\sectionmark}[1]{}
\fancyhf{}
\fancyhead[RO]{\bfseries\rightmark}
\fancyhead[LE]{\bfseries\leftmark}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt}
\fancypagestyle{plain}{
  \fancyhead{}
  \renewcommand{\headrulewidth}{0pt}
}

\newcommand{\submittedtext}{{A report submitted for the purpose of}}
%
%
% DECLARATIONS
%
% These macros are used to declare arguments needed for the
% construction of the title page and other preamble.

% The year and term the degree will be officially conferred
\def\degreedate#1{\gdef\@degreedate{#1}}
% The full (unabbreviated) name of the degree
\def\degree#1{\gdef\@degree{#1}}
% The name of your college or department(eg. Trinity, Pembroke, Maths, Physics)
\def\collegeordept#1{\gdef\@collegeordept{#1}}
% The name of your University
\def\university#1{\gdef\@university{#1}}
% Defining the crest
\def\crest#1{\gdef\@crest{#1}}

% These macros define an environment for front matter that is always 
% single column even in a double-column document.

\newenvironment{alwayssingle}{%
       \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
       \else\newpage\fi}
       {\if@restonecol\twocolumn\else\newpage\fi}

%define title page layout
\renewcommand{\maketitle}{%
\pagenumbering{roman} % Sasa Tomic
\setcounter{page}{0}  % Sasa Tomic
\begin{alwayssingle}
    \renewcommand{\footnotesize}{\small}
    \renewcommand{\footnoterule}{\relax}
    \thispagestyle{empty}
%  \null\vfill
  \begin{center}
    { \Huge {\bfseries {\@title}} \par}
{\large \vspace*{35mm} {{\@crest} \par} \vspace*{25mm}}
    {{\Large \@author} \par}
{\large \vspace*{1ex}
    {{\@collegeordept} \par}
\vspace*{1ex}
    {{\@university} \par}
\vspace*{25mm}
    {{\submittedtext} \par}
\vspace*{1ex}
    {\it {\@degree} \par}
\vspace*{2ex}
    {\@degreedate}}
  \end{center}
  \null\vfill
\end{alwayssingle}}

% DEDICATION
%
% The dedication environment makes sure the dedication gets its
% own page and is set out in verse format.

\newenvironment{dedication}
{\begin{alwayssingle}
  \pagestyle{empty}
  \begin{center}
  \vspace*{1.5cm}
  {\LARGE }
  \end{center}
  \vspace{0.5cm}
  \begin{quote} \begin{center}}
{\end{center} \end{quote} \end{alwayssingle}}


% ACKNOWLEDGEMENTS
%
% The acknowledgements environment puts a large, bold, centered 
% "Acknowledgements" label at the top of the page. The acknowledgements
% themselves appear in a quote environment, i.e. tabbed in at both sides, and
% on its own page.

\newenvironment{acknowledgements}
{\pagestyle{empty}
\begin{alwayssingle}
\begin{center}
\vspace*{1.5cm}
{\Large \bfseries Acknowledgements}
\end{center}
\vspace{0.5cm}
\begin{quote}}
{\end{quote}\end{alwayssingle}}

% The acknowledgementslong environment puts a large, bold, centered 
% "Acknowledgements" label at the top of the page. The acknowledgement itself 
% does not appears in a quote environment so you can get more in.

\newenvironment{acknowledgementslong}
{\pagestyle{empty}
\begin{alwayssingle}
\begin{center}
\vspace*{1.5cm}
{\Large \bfseries Acknowledgements}
\end{center}
\vspace{0.5cm}\begin{quote}}
{\end{quote}\end{alwayssingle}}

%ABSTRACT
%
%The abstract environment puts a large, bold, centered "Abstract" label at
%the top of the page. The abstract itself appears in a quote environment,
%i.e. tabbed in at both sides, and on its own page.

\newenvironment{abstracts} {\begin{alwayssingle} \pagestyle{empty}
  \begin{center}
  \vspace*{1.5cm}
  {\Large \bfseries  Abstract}
  \end{center}
  \vspace{0.5cm}
   \begin{quote}}
{\end{quote}\end{alwayssingle}}

%The abstractlong environment puts a large, bold, centered "Abstract" label at
%the top of the page. The abstract itself does not appears in a quote
%environment so you can get more in.

\newenvironment{abstractslong} {\begin{alwayssingle} \pagestyle{empty}
  \begin{center}
  \vspace*{1.5cm}
  {\Large \bfseries  Abstract}
  \end{center}
  \vspace{0.5cm} \begin{quote}}
{\end{quote}\end{alwayssingle}}

%The abstractseparate environment is for running of a page with the abstract
%on including title and author etc as required to be handed in separately

\newenvironment{abstractseparate} {\begin{alwayssingle} \pagestyle{empty}
  \vspace*{-1in}
 \begin{center}
    { \Large {\bfseries {\@title}} \par}
    {{\large \vspace*{1ex} \@author} \par}
{\large \vspace*{1ex}
    {{\@collegeordept} \par}
    {{\@university} \par}
\vspace*{1ex}
    {{\it \submittedtext} \par}
    {\it {\@degree} \par}
\vspace*{2ex}
    {\@degreedate}}
  \end{center}}
{\end{alwayssingle}}

%ROMANPAGES
%
% The romanpages environment set the page numbering to lowercase roman one
% for the contents and figures lists. It also resets
% page-numbering for the remainder of the dissertation (arabic, starting at 1).

\newenvironment{romanpages}
{\setcounter{page}{1}
  \renewcommand{\thepage}{\roman{page}}}
{\newpage\renewcommand{\thepage}{\arabic{page}}}
%{\newpage\renewcommand{\thepage}{\arabic{page}}\setcounter{page}{1}}

当我编译 TeX 文件时,出现错误

! TeX capacity exceeded, sorry [input stack size=5000].
\@setfontsize #1#2#3->\@nomath #1
\ifx \protect \@typeset@protect \let \@curr...
l.157 ... (lab2) [draw=none, below=0.3cm of dots2]
{\LARGE $s_{(t - n + 2)}$};
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:
15863 strings out of 493482
285481 string characters out of 3137569
391082 words of memory out of 3000000
18829 multiletter control sequences out of 15000+200000
18450 words of font info for 71 fonts, out of 3000000 for 9000
957 hyphenation exceptions out of 8191
5000i,15n,7501p,2136b,954s stack positions out of 5000i,500n,10000p,200000b,50000s
Output written on transfer_report.dvi (21 pages, 84624 bytes).

但是,当我注释掉第二个图时,这个错误不会出现,并且我的 PDF 中会显示第一个图。此外,如果我在 transfer_report.tex 中注释掉以下几行,我可以编译 transfer_report.tex 并仍然在 PDF 中显示两个图

\node (lab1) [draw=none, below=0.3cm of dots1]{\LARGE $s_{(t - n + 1)}$};
\node (lab2) [draw=none, below=0.3cm of dots2]{\LARGE $s_{(t - n + 2)}$};
\node (lab3) [draw=none, below=0.4cm of dots3]{\LARGE $\ldots$};
\node (lab4) [draw=none, below=0.3cm of dots4]{\LARGE $s_{(t - 1)}$};
\node (lab5) [draw=none, below=0.3cm of dots5]{\LARGE $s_{(t)}$};

但是如果没有这 4 行代码,我的图就不完整。那么 (1) 为什么只有取消注释这 4 行代码时才会出现此错误? (2) 我该如何修复此问题?

希望您说得清楚。如果您需要更多详细信息,请告诉我。谢谢!

相关内容