Latex Beamer \shade

Latex Beamer \shade

我有这个代码:

\begin{frame}
\pagestyle{empty}
  \frametitle{Tvorba grafu}
    \begin{tikzpicture}[scale=1.7]
      \shade[top color=blue,bottom color=gray] 
        (0,0) parabola (1.25,2.5) |- (0,0);
      \draw[line width=0.25, ->] (0,0) -- (4,0) node[above]  {$x$};
      \draw[line width=0.25, ->] (0,0) -- (0,4) node[right]  {$y$};
      \draw[style=help lines] (0.001,0.001) grid (3.9,3.9);
      \draw (0,0.25) parabola bend(0,0) (2,4) node[below right] {$x^2$};
      \foreach \x/\xtext in {1/1, 2/2, 3/3}
        \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};
      \foreach \y/\ytext in {1/1, 2/2,3/3}
        \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};
        \draw (1.1cm,2pt) node[above] {$\displaystyle\int_0^{3} \!\!x^2\mathrm{d}x$};
    \end{tikzpicture}
\end{frame}

问题出在: shade[top color=blue,bottom color=gray] (0,0) parabola (1.25,2.5) |- (0,0);有问题,Latex 错误。

但如果我有这个命令:

\shade[top color=blue,bottom color=gray] (0,0) parabola (1.25,2.5) -| (0,0);

它的工作,没有错误。

答案1

两个着色命令均按预期工作。使用

\shade[top color=blue,bottom color=gray]
      (0,0) parabola (1.5,2.25) |- (0,0);% shaded below of parabola

你获得

在此处输入图片描述

\shade[top color=blue,bottom color=gray]
      (0,0) parabola (1.5,2.25) -| (0,0);% shaded left of parabola

在此处输入图片描述

为了我的测试,我稍微重写了你的 MWE(来自 TikZ 和 PGF 手册的示例,第 874 页):

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{mathtools}

\begin{document}
\begin{frame}[plain]
  \frametitle{Tvorba grafu}
    \begin{tikzpicture}[scale=1.5]
% grid
\draw[help lines] (0,0) grid (3.9,3.9);
% axis
\draw[->] (0,0) -- (4,0) node[above]  {$x$};
\draw[->] (0,0) -- (0,4) node[right]  {$y$};
\foreach \i in {1, 2, 3}
{
    \draw (2pt,\i) -- + (-4pt,0) node[left]  {$\i$};
    \draw (\i,2pt) -- + (0,-4pt) node[below] {$\i$};
}
% parabola
\draw (0,0) parabola bend (0,0) (2,4) node[below right] {$x^2$};
\draw (1.05,0) node[above] {$\displaystyle\int_0^{3}\kern-1.75ex x^2\,\mathrm{d}x$};
\scoped[on background layer] 
\shade[top color=blue,bottom color=gray]
      (0,0) parabola (1.5,2.25) |- (0,0);
    \end{tikzpicture}
\end{frame}
\end{document}

正交坐标|-是指先竖直后水平,然后-|相反。这是你的问题吗?

相关内容