![错误:使用 \input 和 gnuplot 输出 tex 时超出 Tex 容量](https://linux22.com/image/340414/%E9%94%99%E8%AF%AF%EF%BC%9A%E4%BD%BF%E7%94%A8%20%5Cinput%20%E5%92%8C%20gnuplot%20%E8%BE%93%E5%87%BA%20tex%20%E6%97%B6%E8%B6%85%E5%87%BA%20Tex%20%E5%AE%B9%E9%87%8F.png)
在编译 tex 文件时我收到一个错误
errorf.tex, line 103, Tex capacity exceeded, sorry [parameter stack size=10000]. \gplbacktext
当尝试编译下一个文件时:
\documentclass[a4paper,12pt,final]{article} % to tamplate
\usepackage{mystyle}
\usepackage{gnuplottex}
\begin{document}
New figure from epslatex terminal:
\begin{figure}
\input{./img/errorf.tex}
\end{figure}
\end{document}
在哪里错误文件 是 Gnuplot 在以下命令的帮助下生成的两个文件之一(另外两个文件是“errorf.eps”):
set terminal epslatex size 1,1.5 color colortext
set xrange [-3:3]
set yrange [-1:1]
set label 1 at -2, 0.5 "$erf(x) = \\frac{2}{\\sqrt{\\pi}}\\int_0^x\\, dt e^{-t^2}$" centre
set output 'errorf.tex'
plot erf(x)
这是错误文件文件:
% GNUPLOT: LaTeX picture with Postscript
\begingroup
\makeatletter
\providecommand\color[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package color not loaded in conjunction with
terminal option `colourtext'%
}{See the gnuplot documentation for explanation.%
}{Either use 'blacktext' in gnuplot or load the package
color.sty in LaTeX.}%
\renewcommand\color[2][]{}%
}%
\providecommand\includegraphics[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
Package graphicx or graphics not loaded%
}{See the gnuplot documentation for explanation.%
}{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
\renewcommand\includegraphics[2][]{}%
}%
\providecommand\rotatebox[2]{#2}%
\@ifundefined{ifGPcolor}{%
\newif\ifGPcolor
\GPcolortrue
}{}%
\@ifundefined{ifGPblacktext}{%
\newif\ifGPblacktext
\GPblacktextfalse
}{}%
% define a \g@addto@macro without @ in the name:
\let\gplgaddtomacro\g@addto@macro
% define empty templates for all commands taking text:
\gdef\gplbacktext{}%
\gdef\gplfronttext{}%
\makeatother
\ifGPblacktext
% no textcolor at all
\def\colorrgb#1{}%
\def\colorgray#1{}%
\else
% gray or color?
\ifGPcolor
\def\colorrgb#1{\color[rgb]{#1}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
\expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
\expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
\expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
\expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
\expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
\expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
\expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
\expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
\else
% gray
\def\colorrgb#1{\color{black}}%
\def\colorgray#1{\color[gray]{#1}}%
\expandafter\def\csname LTw\endcsname{\color{white}}%
\expandafter\def\csname LTb\endcsname{\color{black}}%
\expandafter\def\csname LTa\endcsname{\color{black}}%
\expandafter\def\csname LT0\endcsname{\color{black}}%
\expandafter\def\csname LT1\endcsname{\color{black}}%
\expandafter\def\csname LT2\endcsname{\color{black}}%
\expandafter\def\csname LT3\endcsname{\color{black}}%
\expandafter\def\csname LT4\endcsname{\color{black}}%
\expandafter\def\csname LT5\endcsname{\color{black}}%
\expandafter\def\csname LT6\endcsname{\color{black}}%
\expandafter\def\csname LT7\endcsname{\color{black}}%
\expandafter\def\csname LT8\endcsname{\color{black}}%
\fi
\fi
\setlength{\unitlength}{0.0500bp}%
\ifx\gptboxheight\undefined%
\newlength{\gptboxheight}%
\newlength{\gptboxwidth}%
\newsavebox{\gptboxtext}%
\fi%
\setlength{\fboxrule}{0.5pt}%
\setlength{\fboxsep}{1pt}%
\begin{picture}(1440.00,2160.00)%
\gplgaddtomacro\gplbacktext{%
\csname LTb\endcsname%
\put(726,440){\makebox(0,0)[r]{\strut{}$-1$}}%
\put(726,804){\makebox(0,0)[r]{\strut{}$-0.5$}}%
\put(726,1168){\makebox(0,0)[r]{\strut{}$0$}}%
\put(726,1531){\makebox(0,0)[r]{\strut{}$0.5$}}%
\put(726,1895){\makebox(0,0)[r]{\strut{}$1$}}%
\put(858,220){\makebox(0,0){\strut{}$-3$}}%
\put(889,220){\makebox(0,0){\strut{}$-2$}}%
\put(920,220){\makebox(0,0){\strut{}$-1$}}%
\put(950,220){\makebox(0,0){\strut{}$0$}}%
\put(981,220){\makebox(0,0){\strut{}$1$}}%
\put(1012,220){\makebox(0,0){\strut{}$2$}}%
\put(1043,220){\makebox(0,0){\strut{}$3$}}%
\put(889,1531){\makebox(0,0){\strut{}$erf(x) = \frac{2}{\sqrt{\pi}}\int_0^x\, dt e^{-t^2}$}}%
}%
\gplgaddtomacro\gplfronttext{%
\csname LTb\endcsname%
\put(56,1722){\makebox(0,0)[r]{\strut{}erf(x)}}%
}%
\gplbacktext
\put(0,0){\includegraphics{errorf}}%
\gplfronttext
\end{picture}%
\endgroup
答案1
你误用了gnuplottex
。请运行pdflatex -shell-escape
此示例:
\documentclass[a4paper,12pt,final]{article} % to tamplate
\usepackage{gnuplottex}
\usepackage{amsmath}
\DeclareMathOperator{\erf}{erf}
\begin{document}
In figure~\ref{fig:erf} we see a plot done by \texttt{gnuplot}.
\begin{figure}[htp]
\centering
\begin{gnuplot}
set xrange [-3:3]
set yrange [-1:1]
set label 1 at -1, 0.5 "$\\displaystyle\\erf(x) = \\frac{2}{\\sqrt{\\pi}}\\int_0^x e^{-t^2}\\,dt$" centre
plot erf(x)
\end{gnuplot}
\caption{The $\erf$ function}\label{fig:erf}
\end{figure}
\end{document}
另一方面,在运行示例代码pdflatex
之后,运行以下示例,gnuplot
\documentclass[a4paper,12pt,final]{article} % to tamplate
\usepackage{amsmath,xcolor,graphicx}
\DeclareMathOperator{\erf}{erf}
\begin{document}
In figure~\ref{fig:erf} we see a plot done by \texttt{gnuplot}.
\begin{figure}[htp]
\input{errorf.tex}
\caption{The error function}\label{fig:erf}
\end{figure}
\end{document}
生产
显然某些设置是错误的;另一方面,我没有收到任何错误。
答案2
问题已解决。此问题开头指出的错误是由于在 gnuplot 命令中使用了引号。应使用撇号代替引号:
set label 1 at -2, 0.5 '$erf(x) = \\frac{2}{\\sqrt{\\pi}}\\int_0^x\\, dt e^{-t^2}$' centre
第二个问题埃格尔gnuplot 文件中的大小设置不正确导致的结果:
set terminal epslatex size 1,1.5 color colortext
这里应该调整大小以适应 .tex 文件中的图像大小。为了不手动调整大小,可以在插入图像时使用 Tex 中的尺寸自动调整功能:
\resizebox{\linewidth}{!}{\input{./img/errorf.tex}}