如何防止此 MWE 中的算术溢出和维度过大

如何防止此 MWE 中的算术溢出和维度过大
\documentclass[12pt]{article}
% Errors occur for this invocation.
%    $ MWE=1 pdflatex -interaction=nonstopmode MWE.tex 2>&1|grep "^!"|sort|uniq
% but not for this invocation.
%    $ MWE=  pdflatex -interaction=nonstopmode MWE.tex 2>&1|grep "^!"|sort|uniq

\usepackage{catchfile}
\usepackage{etoolbox}
\usepackage{pgfplots}
\usepackage{tikz}

% Environment variable is useful for comparing FAIL with PASS.
\newcommand{\newgetenv}[2][]{%
    \CatchFileEdef{\temp}{"|kpsewhich --var-value #2"}{\endlinechar=-1\relax}%
    \if\relax\detokenize{#1}\relax\temp\else\edef#1{\temp}\fi%
}

% Gauss function, parameters mu and sigma (This is what causes the failure)
% copied from:
%     https://tex.stackexchange.com/questions/11368/%
%     bell-curve-gaussian-function-normal-distribution-in-tikz-pgf
\newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}

\begin{document}
\newgetenv[\MWE]{MWE}
\typeout{MWE="\MWE"}

\begin{tikzpicture}
\begin{axis}[samples=1000,domain=390:640,xmin=390,xmax=640,ymin=0,ymax=1]
    \addplot[draw=red]{sin(10*x)^2};
    \expandafter\ifstrequal\expandafter{\MWE}{}{
        \typeout{PASS: No limits exceeded}
    }{
        \typeout{FAIL 1: Dimension too large}
        \typeout{FAIL 2: Arithmetic overflow}
        \addplot[draw=blue]{\gauss{420}{1}};  % This plot causes the failure.
    }
\end{axis}
\end{tikzpicture}

\end{document}

\列表:

 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
catchfile.sty    2016/05/16 v1.7 Catch the contents of a file (HO)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
etoolbox.sty    2018/02/11 v2.5e e-TeX tools for LaTeX (JAW)
pgfplots.sty    2017/06/05 v1.15 Data Visualization (1.15)
graphicx.sty    2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  pdftex.def    2018/01/08 v1.0l Graphics/color driver for pdftex
    tikz.sty    2015/08/07 v3.0.1a (rcs-revision 1.151)
     pgf.sty    2015/08/07 v3.0.1a (rcs-revision 1.15)
  pgfrcs.sty    2015/08/07 v3.0.1a (rcs-revision 1.31)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.1a (rcs-revision 1.7)
  pgfsys.sty    2014/07/09 v3.0.1a (rcs-revision 1.48)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.1a (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.1a (rcs-revision 1.1)
  pgffor.sty    2013/12/13 v3.0.1a (rcs-revision 1.25)
 pgfkeys.sty    
 pgfkeys.code.tex
 pgfmath.sty    
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
supp-pdf.mkii
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
pdftexcmds.sty    2018/01/21 v0.26 Utility functions of pdfTeX for LuaTeX (HO)
   ifpdf.sty    2017/03/15 v3.2 Provides the ifpdf switch
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
"|kpsewhich --var-value MWE".tex

相关内容