在 Beamer 演示文稿中包含 Tikz 图形时出错

在 Beamer 演示文稿中包含 Tikz 图形时出错

我想在 beamer 演示文稿中包含外部 tikz 文件。我收到以下错误:Missing number, treated as zero

梅威瑟:

.tex 文件的内容:

\documentclass[xcolor=pst]{beamer}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\setbeamercovered{transparent}

\usepackage{amsmath,amssymb}
\usepackage{pgfplots} %howtotex.com/packages/beautiful-matlab-figures-in-latex
\newlength\figureheight
\newlength\figurewidth
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={decoration={
  markings,
  mark=at position .5 with {\arrow{>}}},postaction={decorate}}}
% argument #1: any options
\newenvironment{customlegend}[1][]{%
    \begingroup
    % inits/clears the lists (which might be populated from previous
    % axes):
    \csname pgfplots@init@cleared@structures\endcsname
    \pgfplotsset{#1}%
}{%
    % draws the legend:
    \csname pgfplots@createlegend\endcsname
    \endgroup
}%

% makes \addlegendimage available (typically only available within an
% axis environment):
\def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}

\begin{document}

\begin{frame}{test}
\input{0pics/example.tikz}
\end{frame}

\end{document}

内容example.tikz

% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\begin{tikzpicture}

\begin{axis}[%
%added
    axis equal image,
width=0.432\figurewidth,
height=0.576\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=0,
xmax=15,
xlabel={$i$},
ymin=-3,
ymax=0,
axis background/.style={fill=white},
legend style={at={(0.289,0.335)},anchor=south west,legend cell align=left,align=left,draw=white!15!black}
]
\addplot[const plot,color=black,solid,mark=*,mark options={solid}] plot table[row sep=crcr] {%
0   -3\\
1   -1.89528461000566\\
2   -1.2165417194998\\
3   -0.782365188677032\\
};
\addlegendentry{$x^{(1)}(i)$};

\addplot[const plot,color=black,dashed,mark=*,mark options={solid}] plot table[row sep=crcr] {%
0   -2.9\\
1   -1.89305581954404\\
2   -1.25193496088527\\
3   -0.834104149748474\\
};
\addlegendentry{$x^{(2)}(i)$};

\addplot[const plot,color=black,dashed,forget plot] plot table[row sep=crcr] {%
0   0\\
15  0\\
};
\end{axis}

\begin{axis}[%
width=0.432\figurewidth,
height=0.576\figureheight,
at={(0.568\figurewidth,0\figureheight)},
scale only axis,
xmin=0,
xmax=15,
xlabel={$i$},
ymin=-0.8,
ymax=0.2,
axis background/.style={fill=white},
legend style={legend cell align=left,align=left,draw=white!15!black}
]
\addplot[const plot,color=black,dashed,mark=*,mark options={solid}] plot table[row sep=crcr] {%
0   -0.0942343027470984\\
1   -0.0710987760069185\\
2   -0.0721957724782892\\
3   -0.0336261350013048\\
};
\addlegendentry{$u(i)$};

\addplot[const plot,color=black,solid,mark=*,mark options={solid}] plot table[row sep=crcr] {%
0   -0.678266260177511\\
1   -0.451145429034797\\
2   -0.322832466389642\\
3   -0.200078970945606\\

};
\addlegendentry{$v(i)$};

\addplot[const plot,color=black,dashed,forget plot] plot table[row sep=crcr] {%
0   0\\
14  0\\
};
\end{axis}
\end{tikzpicture}%

答案1

根据要求,我发布我的评论作为答案。

中的一些尺寸和坐标example.tikz以两个长度\figurewidth和表示,但这些未在文件中定义。在主文件\figureheight的前言中,和定义为长度(使用),但没有分配值(例如使用)。.tex\figurewidth\figureheight\newlength\setlength

答案2

正如LucaD所回答的,\figurewidth\figureheight没有定义。

相关内容