投影机幻灯片中的失控论点

投影机幻灯片中的失控论点

我试图用投影仪制作一个图形,显示一个函数,它的导数和指向该函数的法向量,但我无法编译,它说

Runaway argument?
 \par \draw [line width=1.2pt,color=blue!50!black,smooth,samples=100,\ETC.
! File ended while scanning use of \frame.
<inserted text> 
                \par 

我知道这些错误与留下一些不好的匹配(没有结束的开始)有关,但我没有发现任何类似的东西,并且绘制命令中的选项对我来说似乎并不奇怪。

MWE(应该是)是:

\documentclass[spanish]{beamer}
\pgfplotsset{compat=1.17}
\usepackage{soul}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{tikz, xcolor}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{patterns,hobby}
\begin{document}
\begin{frame}
\frametitle{Aplicaciones geométricas de la derivada}

            Sea una curva $C$ de ecuación $y=f(x)$ donde $f(x)$es continua

            La pendiente de la recta tangente a la curva $C$en el punto $P(x_{0},y_{0}$)
            es $m=f\prime(x_{0})$.
Usando la ecuación punto-pendiente de la recta:
\begin{center}
$y-y_{0}=m(x-x_{0})$
\end{center}
\begin{center}
$y-y_{0}=f\prime(x_{0})(x-x_{0})$
\end{center}
donde $x_{0}$ y $y_{0}$ son las coordenadas del punto de tangencia 

    \begin{tikzpicture}[scale=1]
    
        \draw (-1,0) -- (7.5,0) (0,-.5) -- (0,4.5);
        \node[below left=2pt and 2pt] at (0,0) {$O$}; 
        
        \begin{scope}       
            \clip (-1,0) rectangle (7.5,4.5);
            \draw[line width=1.2pt,color=red,smooth,samples=100,domain=-2.5:7.5] plot(\x,{0.3*((\x)-3.5)*((\x)-3.5)+0.5}); 
        \end{scope}
        
        \def\xA{2.5} \def\yA{0.8}
        \coordinate (A) at (\xA,\yA);
        \draw[dashed] (\xA,0) node[below=2pt] {$x_{0}$} -- (A) -- (0,\yA) node[left] {$y_{0}$};
                
        \def\xM{6.5} \def\yM{3.2}
        \coordinate (M) at (\xM,\yM);
        \draw[dashed] (\xM,0) node[below] {$x_{0}+\Delta x$} -- (M) -- (0,\yM) node[left] {$y_{0}+\Delta x)$};
        \begin{scope}       
            \clip (0.5,-0.5) rectangle (7.5,4.5);

            \foreach \xN/\yN in {5}
                {
                \coordinate (N) at (\xN,\yN);
                \tkzDrawPoint[size=8](N)
                \tkzDrawLine[add=2 and 3,color=orange!50!black](A,N)
                \tkzLabelPoint[line width=1.2pt,color=green!50!black,smooth,samples=100,domain=0.5:5](3,3){Rectas secantes}
                }   
        \end{scope}
        
        \draw[line width=1.2pt,color=blue!50!black,smooth,samples=100,domain=0.5:5] plot(\x,{-0.6*(\x)+2.3}) node[below] {Recta tangente a la curva en $P$};            
        
        \tkzDrawPoints[size=8](A,M)
        \tkzLabelPoint[above=3pt](A){$P$}
        \tkzLabelPoint[above left](M){$Q$}


    \end{tikzpicture}
 \end{frame}

\end{document}    

当它在没有框架环境的情况下编译时,它会得到下一张幻灯片 在此处输入图片描述

更新
定义 \pgfplotsset 和适当的库之后,MWE

\documentclass[spanish]{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin9]{luainputenc}
\usepackage{xcolor}
\usepackage{calc}
\usepackage{amsmath}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\usepackage{subcaption}
\usepackage{pifont}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{angles, quotes}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{amsthm}
\usetikzlibrary{decorations.markings}
\usepackage[makeroom]{cancel}
\usetikzlibrary{datavisualization.formats.functions}
\usepackage{pgfplotstable}
\usepackage{wasysym}
\usetikzlibrary{decorations.pathreplacing}
\setbeamertemplate{navigation symbols}{}
\pgfplotsset{compat=1.17}
\usepackage{soul}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{pifont}
\usetikzlibrary{3d}
\usepackage{tikz, xcolor}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{patterns,hobby}

\begin{document}
\begin{frame}
\frametitle{Aplicaciones geométricas de la derivada}

            Sea una curva $C$ de ecuación $y=f(x)$ donde $f(x)$es continua

            La pendiente de la recta tangente a la curva $C$en el punto $P(x_{0},y_{0}$)
            es $m=f\prime(x_{0})$.
Usando la ecuación punto-pendiente de la recta:
\begin{center}
$y-y_{0}=m(x-x_{0})$
\end{center}
\begin{center}
$y-y_{0}=f\prime(x_{0})(x-x_{0})$
\end{center}
donde $x_{0}$ y $y_{0}$ son las coordenadas del punto de tangencia 

    \begin{tikzpicture}[scale=1]
    
        \draw (-1,0) -- (7.5,0) (0,-.5) -- (0,4.5); % Axis
        \node[below left=2pt and 2pt] at (0,0) {$O$}; % Origin
        
        \begin{scope}       
            \clip (-1,0) rectangle (7.5,4.5);
            \draw[line width=1.2pt,color=red,smooth,samples=100,domain=-2.5:7.5] plot(\x,{0.3*((\x)-3.5)*((\x)-3.5)+0.5}); 
        \end{scope}
        
        \def\xA{2.5} \def\yA{0.8}
        \coordinate (A) at (\xA,\yA);
        \draw[dashed] (\xA,0) node[below=2pt] {$x_{0}$} -- (A) -- (0,\yA) node[left] {$y_{0}$};
                
        \def\xM{6.5} \def\yM{3.2}
        \coordinate (M) at (\xM,\yM);
        \draw[dashed] (\xM,0) node[below] {$x_{0}+\Delta x$} -- (M) -- (0,\yM) node[left] {$y_{0}+\Delta x)$};
        \begin{scope}       
            \clip (0.5,-0.5) rectangle (7.5,4.5);

            \foreach \xN/\yN in {5}
                {
                \coordinate (N) at (\xN,\yN);
                \tkzDrawPoint[size=8](N)
                \tkzDrawLine[add=2 and 3,color=orange!50!black](A,N)
                \tkzLabelPoint[line width=1.2pt,color=green!50!black,smooth,samples=100,domain=0.5:5](3,3){Rectas secantes}
                }   
        \end{scope}
        
        \draw[line width=1.2pt,color=blue!50!black,smooth,samples=100,domain=0.5:5] plot(\x,{-0.6*(\x)+2.3}) node[below] {Recta tangente a la curva en $P$};            
        
        \tkzDrawPoints[size=8](A,M)
        \tkzLabelPoint[above=3pt](A){$P$}
        \tkzLabelPoint[above left](M){$Q$}
        
      

    \end{tikzpicture}
 \end{frame}

\end{document}

答案1

编辑(1): 为了提供解决方案,在附录框架中添加了给定函数 f(x) 的切线计算程序。

编辑(2): 似乎提供的结果图像有误:割线应该经过点 P 和 Q(即A变为切线)。通过对 MWE 的切线计算表示进行这种修正,切线计算的表示变得正确,并且其代码也变得更简单一些。

图表的格式略有修改。由于只使用了pfplots包,因此正切是通过函数导数计算的(参见 MWE 中的附录),对于方程组,定义计算正切的规则使用包align中定义的环境amsmath(由 加载beamer):

\documentclass[spanish]{beamer}
\setbeamertemplate{frametitle continuation}{\hfill%
(\insertcontinuationcount)}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage[low-sup]{subdepth}

\begin{document}
\begin{frame}[fragile]
\frametitle{Aplicaciones geométricas de la derivada}

Sea una curva $C$ de ecuación $y=f(x)$ donde $f(x)$ es continua

La pendiente de la recta tangente a la curva $C$en el punto $P(x_{0},y_{0})$ es $m=f'(x_{0})$. Usando la ecuación punto-pendiente de la recta:
    \begin{align*}
y-y_{0}    & = m(x-x_{0})                  \\
y-y_{0}    & = f'(x_{0})(x-x_{0})
    \end{align*}
donde $x_{0}$ y $y_{0}$ son las coordenadas del punto de tangencia:
\begin{center}
    \begin{tikzpicture}[
dot/.style = {circle, fill, inner sep=2pt,
              fill opacity=0.5, text opacity=1,
              label={[inner sep=1pt]#1}, node contents={}},
every node/.append style = {sloped, align=center,
                            font=\scriptsize, text depth=0.25ex},
                        ]
\begin{axis}[width=90mm, height=60mm,
    axis lines=middle,
    ylabel=y,
    ylabel style = {rotate=270},
    xlabel=x,
    ymin=-1.1,  ymax=5.0,   ytick=\empty,
    xmin=-1.5,  xmax=7.5,   xtick=\empty,
    no marks
            ]
\node[below left] at (0,0) {0}; % Origin
%
\addplot +[ultra thick, samples=101,domain=-0.2:7.2]
    plot {0.3*(\x-3.5)^2 + 0.5};
% tangent
\draw[red,  shorten <=-2mm,  shorten >=-9mm ]
    (0,2.975) -- (3.3,0)
    node[at end] {Recta tangente\\ a la curva en $P$};
% P and Q coordinates
\draw[densely dashed]
    ( 2.0,-0.10)  node[below] {$x_0$} |-
    (-0.1,1.175)  node[left]  {$y_0$}
                  node (p) [pos=0.5, dot=$P$];
\draw[densely dashed]
    (6.5,-0.1) node[below] {$x_0+\Delta x$} |-
    (-0.1,3.2) node[left]  {$y_0+\Delta y$}
               node (q) [pos=0.5, dot=$Q$];
% secant
\draw[purple, shorten <=-12mm, shorten >=-9mm]
    (p) --  node {Rectas\\ secantes}  (q);
\end{axis}
    \end{tikzpicture}
\end{center}
\end{frame}


\begin{frame}[fragile, allowframebreaks]
\frametitle{Appendix:\\
            calculation of the $f(x)$ tangent at the point $P(x_0,y_0)$}
\small

Rule (again):
{\color{blue}
    \begin{align*}
y-y_{0}    & = m(x-x_{0})                  \\
y-y_{0}    & = f'(x_{0})(x-x_{0})
    \end{align*}
}
Graph $p(x)$ at point $P(x_0=2,y)$:
    \begin{align*}
f(x)    & = 0.3(x-3.5)^2 + 0.5  \\
P(2)    & = 0.3(2-3.5)^2 + 0.5 = 0.3(-1.5)^2 + 0.5 = \boxed{1.175}
    \end{align*}

    \begin{flalign*}
\text{Point $P$:}
  && P(2,y) & = P\bigl(2,p(2)\bigr) = (2,0.3(2-3.5)+0.5) && \\
  &&        & = \boxed{$P(2,1.175)$}    &&
    \end{flalign*}
Derivative of $f(x)$:
    \begin{align*}
f'(x)   & = 0.3.2(x-3.5)^1 = 0.6x - 2.1 \\
f'(2)   & = 1.2 - 2.1 = \boxed{-0.9}
    \end{align*}

\framebreak
Tangent:
    \begin{align*}
y - 1.175
    & = f'(2)(x - 2)    \Rightarrow     y = -0.9(x - 2) = -0.9x +1.8    \\
y   & = -0.9x + 1.8 + 1.175     \\
    & = \boxed{-0.9x + 2.75}
    \end{align*}
    \begin{align*}
\text{value $y$ at $x=0$:} && y & = 2.975 \\
\text{value $x$ at $y=0$:} && x & = \frac{2.975}{0.9} = 3.305^\cdot
    \end{align*}

\begin{center}
    \begin{tikzpicture}[
dot/.style = {circle, fill, inner sep=2pt,
              fill opacity=0.5, text opacity=1,
              label={[inner sep=1pt]#1}, node contents={}},
every node/.append style = {sloped, font=\scriptsize, align=center},
        every pin/.style = {pin edge={<-}, inner sep=1pt,
                            pin distance=3mm, font=\tiny}
                        ]
\begin{axis}[width=90mm, height=45mm,
    axis lines=middle,
    ylabel=y,
    ylabel style = {rotate=270},
    xlabel=x,
    ymin=-1.5,  ymax=5.5,   ytick=\empty,
    xmin=-2.0,  xmax=7.5,   xtick=\empty,
    no marks
            ]
\node[below left] at (0,0) {0}; % Origin

\addplot +[ultra thick, samples=101,domain=-0.2:7.2]
    plot {0.3*(\x-3.5)^2 + 0.5};
% tangent
\draw[red,  shorten <=-2mm,  shorten >=-9mm ]
    (0,2.975) coordinate (a) --
    (3.3,0)   coordinate (b)
    node[at end] {Recta tangente\\ a la curva en $P$};
\path   (a) node[inner sep=0pt, pin=225:2.975]{}
        (b) node[inner sep=0pt, pin=265:$3.305^\cdot$] {};
% P and Q coordinates
\draw[densely dashed]
    ( 2.0,-0.10)  node[below] {$x_0=2$} |-
    (-0.1,1.175)  node[left]  {$y_0$=1.175}
                  node (p) [pos=0.5, dot=$P$];
\draw[densely dashed]
    (6.5,-0.1) node[below] {$x_0+\Delta x$} |-
    (-0.1,3.2) node[left]  {$y_0+\Delta y$}
               node (q) [pos=0.5, dot=$Q$];
% secant
\draw[purple, shorten <=-12mm, shorten >=-9mm]
    (p) --  node {Rectas\\ secantes}  (q);
\end{axis}
    \end{tikzpicture}
\end{center}
\end{frame}
\end{document}

在此处输入图片描述

(未显示带附录的框架)

相关内容