pgfplots 错误消息“/pgfplots@addplotimpl@expression@curly”

pgfplots 错误消息“/pgfplots@addplotimpl@expression@curly”

我目前正在使用 pgf plots 制作一些图表;但是,当我排版文档时,我收到一条奇怪的错误消息,导致无法生成 PDF。错误消息指出:“扫描使用 \pgfplots@addplotimpl@expression@curly 时文件结束。”我已将错误消息和代码附加到下面。

谢谢。

错误信息

%latex
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[mathscr]{euscript}
\usepackage{pgfplots}
\usepackage{tikz}


% Theorem Styles
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
% Definition Styles
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}%[section]
\newtheorem{example}[theorem]{Example}%[section]

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{note}[theorem]{Note}
\newtheorem{question}[theorem]{Question}%[section]
\input {xy}
\xyoption{all}

\newcommand{\R}{\mathbb{R}}

\begin{document}

%+Title
\title{Article Title}
\maketitle
%-Title

%+Contents
\tableofcontents
%-Contents

\section{Differentiable Function}

The curve $ \{ (x,y) \ : \ y=f(x) \}$ where $f:\R \to \R$ can be approximated with a tangent line.
\vspace{0.05in}
\newline
The surface $ \{ (x,y,z) \ : \ z=f(x,y) \}$ where $f:\R^2 \to \R$ can be approximated with a tangent plane.
\vspace{0.05in}
\newline 
In single-variable calculus, we defined a function $f:\R \to \R$ to be differentiable at $x_0$ if the following limit existed:
\begin{align*}
f'(x_0)=\lim_{h \to 0} \frac{f(x_0+h)-f(x_0)}{h}
\end{align*}
Notice that this expression represents the slope of the secant line:
\vspace{0.1in}
\begin{center}
\pgfplotsset{
        compat=1.12,
        standard/.style={
        axis lines=middle,
        enlarge x limits=0.15,
        enlarge y limits=0.15,
        every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
        every axis y label/.style={at={(current axis.above origin)},anchor=north east},   
    }
}
\begin{tikzpicture}
\begin{axis}[
    standard,
    xlabel = $x$,
    ylabel = {$y$},
    xtick={\empty},
    ytick={\emtpy},
    extra x ticks={1,4},
    extra x tick labels={$x_0$,$x_0+h$},
]
\addplot [
domain=0:5,
samples=100,
color=black,
]
{x^2};
\addplot [
domain=0:5,
samples=100,
color=black,
]
{5*x-4}
\end{axis}
\end{tikzpicture}
\end{center}

\begin{note}
$f(x)=\|x\|$ is not differentiable at $x=0$ because $\lim_{h \to 0}\frac{f(0+h)-f(0)}{h}$ does not exist:

\begin{align*}
\lim_{h \to 0^+} \frac{f(0+h)-f(0)}{h}=\lim_{h \to 0^+} \frac{h}{h}=1 \\
\lim_{h \to 0^-} \frac{f(0+h)-f(0)}{h}=\lim_{h \to 0^-} \frac{h}{h}=-1  
\end{align*}
\end{note}

Suppose that $f'(x_0)$ exists. We then know that:
\begin{align*}
    \lim_{h \to 0} \frac{f(0+h)-f(0)}{h}-f'(x_0)=0 \\
    \lim_{h \to 0} \frac{f(0+h)-f(0)-hf'(x_0)}{h}=0
\end{align*}
We can use $f(x_0)+hf'(x_0)$ as a linear approximation of $f(x_0+h)$:

\begin{center}

\begin{tikzpicture}
\begin{axis}[
    standard,
    clip=true,
    clip mode=individual,
    restrict y to domain=0:2.3,
    axis lines=middle,
    xlabel = $x$,
    ylabel = {$y$},
    xtick={\empty},
    ytick={\empty},
    extra x ticks={1,3},
    extra x tick labels={$x_0$,$x_0+h$},
    extra y ticks={1, 1.73, 2},
    extra y tick labels={$f(x_0)$, $f(x_0+h)$, $f(x_0+h)+h'(x_0+h)$},
    ymax=3,
    xmax=5 
]
\addplot [
domain=0:4.5,
samples=100,
color=black,
]
{(1/2)*x+(1/2)} node [above,pos=1] {$f(x_0)+hf'(x_0)$}

\addplot [
domain=0.1:4,
samples=100,
color=black,
]
{sqrt(x)}
\addplot [dashed,
domain=0.1:4,
samples=2,
]
{1}
\addplot [dashed,
domain=0:4,
samples=2,
]
{sqrt(3)}
\addplot [dashed,
domain=0:4,
samples=2,
]
{2}
\end{axis}
\end{tikzpicture}
\end{center}

\begin{definition} Function is never really linear but it looks more and
more linear as we zoom in.
\end{definition} 

\begin{definition}
Let $f:\R \to \R$ be a function at $a \in \R$. We say $f$ is differentiable at $a$ if the following limit exists:

\end{definition}

\marginpar{Hardest concept of the course}


\end{document}

答案1

每个语句末尾\addplot都需要一个分号。宏中有\empty一处拼写错误,并且使用了未定义的样式standard

其他说明:

  • 我认为这\newline\vspace{0.05in}不是个好主意,只需添加一个空行来表示段落分隔符即可。如果您坚持不缩进并且段落之间有一些垂直空间(我不会这样做),请添加\usepackage{parskip}

  • 不要align*对所有东西都使用 。如果只有一个方程,则使用equation*。如果有几个方程不应该对齐(例如在等号处),则使用gather*

  • 显示数学运算之前和之后不要有空行(段落分隔符),例如gather*

  • amsart至少加载amsmath

\documentclass{amsart}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[mathscr]{euscript}
\usepackage{pgfplots}
\usepackage{tikz}


% Theorem Styles
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
% Definition Styles
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}%[section]
\newtheorem{example}[theorem]{Example}%[section]

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{note}[theorem]{Note}
\newtheorem{question}[theorem]{Question}%[section]
\input {xy}
\xyoption{all}

\newcommand{\R}{\mathbb{R}}

%\usepackage{parskip}


\begin{document}

%+Title
\title{Article Title}
\maketitle
%-Title

%+Contents
\tableofcontents
%-Contents

\section{Differentiable Function}

The curve $ \{ (x,y) \ : \ y=f(x) \}$ where $f:\R \to \R$ can be approximated with a tangent line.


The surface $ \{ (x,y,z) \ : \ z=f(x,y) \}$ where $f:\R^2 \to \R$ can be approximated with a tangent plane.


In single-variable calculus, we defined a function $f:\R \to \R$ to be differentiable at $x_0$ if the following limit existed:
\begin{equation*}
f'(x_0)=\lim_{h \to 0} \frac{f(x_0+h)-f(x_0)}{h}
\end{equation*}
Notice that this expression represents the slope of the secant line:

\begin{center}
\pgfplotsset{
        compat=1.12,
        standard/.style={
        axis lines=middle,
        enlarge x limits=0.15,
        enlarge y limits=0.15,
        every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
        every axis y label/.style={at={(current axis.above origin)},anchor=north east},   
    }
}
\begin{tikzpicture}
\begin{axis}[
    standard,
    xlabel = $x$,
    ylabel = {$y$},
    xtick={\empty},
    ytick={\empty},
    extra x ticks={1,4},
    extra x tick labels={$x_0$,$x_0+h$},
]
\addplot [
domain=0:5,
samples=100,
color=black,
]
{x^2};
\addplot [
domain=0:5,
samples=100,
color=black,
]
{5*x-4};
\end{axis}
\end{tikzpicture}
\end{center}

\begin{note}
$f(x)=\|x\|$ is not differentiable at $x=0$ because $\lim_{h \to 0}\frac{f(0+h)-f(0)}{h}$ does not exist:
\begin{gather*}
\lim_{h \to 0^+} \frac{f(0+h)-f(0)}{h}=\lim_{h \to 0^+} \frac{h}{h}=1 \\
\lim_{h \to 0^-} \frac{f(0+h)-f(0)}{h}=\lim_{h \to 0^-} \frac{h}{h}=-1  
\end{gather*}
\end{note}

Suppose that $f'(x_0)$ exists. We then know that:
\begin{gather*}
    \lim_{h \to 0} \frac{f(0+h)-f(0)}{h}-f'(x_0)=0 \\
    \lim_{h \to 0} \frac{f(0+h)-f(0)-hf'(x_0)}{h}=0
\end{gather*}
We can use $f(x_0)+hf'(x_0)$ as a linear approximation of $f(x_0+h)$:
\begin{center}
\begin{tikzpicture}
\begin{axis}[
%    standard,
    clip=true,
    clip mode=individual,
    restrict y to domain=0:2.3,
    axis lines=middle,
    xlabel = $x$,
    ylabel = {$y$},
    xtick={\empty},
    ytick={\empty},
    extra x ticks={1,3},
    extra x tick labels={$x_0$,$x_0+h$},
    extra y ticks={1, 1.73, 2},
    extra y tick labels={$f(x_0)$, $f(x_0+h)$, $f(x_0+h)+h'(x_0+h)$},
    ymax=3,
    xmax=5 
]
\addplot [
domain=0:4.5,
samples=100,
color=black,
]
{(1/2)*x+(1/2)} node [above,pos=1] {$f(x_0)+hf'(x_0)$};

\addplot [
domain=0.1:4,
samples=100,
color=black,
]
{sqrt(x)};
\addplot [dashed,
domain=0.1:4,
samples=2,
]
{1};
\addplot [dashed,
domain=0:4,
samples=2,
]
{sqrt(3)};
\addplot [dashed,
domain=0:4,
samples=2,
]
{2};
\end{axis}
\end{tikzpicture}
\end{center}

\begin{definition} Function is never really linear but it looks more and
more linear as we zoom in.
\end{definition} 

\begin{definition}
Let $f:\R \to \R$ be a function at $a \in \R$. We say $f$ is differentiable at $a$ if the following limit exists.
\end{definition}

\marginpar{Hardest concept of the course}


\end{document}

相关内容