我在这里插入了图片,以便在我的 Beamer 演示文稿中进行解释
我用时间序列数据从 Python 中绘制了该图。我想用这个 latex 代码解释公式,同时解释这两条虚线
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\newcommand\tikzmark[1]{
\tikz[remember picture,overlay] \coordinate (#1);
}
\begin{document}
\begin{frame}
\frametitle{example}
\begin{block}{example}
\[
\tikzmark{ar}AR\tikzmark{i}I\tikzmark{ma}MA
\]
\begin{tikzpicture}[
remember picture,
overlay,
expl/.style={draw=orange,fill=orange!30,rounded corners,text width=3cm},
arrow/.style={red!80!black,ultra thick,->,>=latex}
]
\node[expl]
(artext)
at (2,-2cm)
{Autoregressive};
\node[expl]
(itext)
at (4,3.5cm)
{Integrated};
\node[expl]
(matext)
at (9,-3cm)
{Moving Average};
\draw[arrow]
(artext) to[out=100,in=180] ([yshift=0.ex]{ar});
\draw[arrow]
(itext.west) to[out=180,in=180] ([yshift=0.5ex]{i});
\draw[arrow]
(matext.east) to[out=0,in=0]([yshift=0.5ex]{ma});
\end{tikzpicture}
\end{block}
\end{frame}
\end{document}
如果不可能,我怎样才能在 tikz 中绘制这张图片并使用带有方框文字的箭头来解释两条虚线?
这是我的 MWE for tex 代码
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz,graphicx}
\begin{document}
\begin{frame}
\frametitle{~}
\begin{block}{~}
\begin{figure}[H]
\includegraphics[width=\linewidth, height=3cm]{C:/Users/user/Desktop/storeimage.png}
\end{figure}
\end{block}
\end{frame}
\end{document}
您可以右键单击下载图像并将其放在桌面上以使其成为您的目录。
答案1
抱歉,在过去的一个小时里,我并没有真正理解你的问题。你可以在修订。
嗯,你必须手动找到坐标,这并不方便。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{example}
\begin{block}{example}
\centering
\begin{tikzpicture}[remember picture]
\path (0,0) node {\includegraphics[scale=0.5]{l9QEp.png}};
% here you have to find the coordinates manually according to your diagram
\coordinate (redline) at (-2,0);
\coordinate (greenline) at (1.4,-1.3);
\end{tikzpicture}
\end{block}
\begin{tikzpicture}[remember picture,overlay,
arrow/.style={red!80!black,ultra thick,>=latex},
expl/.style={draw=orange,fill=orange!30,rounded corners,text width=3cm}]
\draw[<-,arrow] (redline) to[out=120,in=-30] ++ (-1,3.5) node[anchor=-30,expl] {red line};
\draw[<-,arrow] (greenline) to[out=-60,in=180] ++ (1,-2) node[right,expl] {green line};
\end{tikzpicture}
\end{frame}
\end{document}
不过,我建议使用pgfplots
数据来绘制图表,而不是导入 PNG 图像。如你所见,导入时,PNG 图像会变得模糊,这显然不是一件好事。
答案2
这是一个基于的解决方案Jake 的回答在这里。outertikzpicture
将我们想要指向的有趣位置定义为具有形状的节点coordinate
,在我的示例中称为below e
和。它使用选项使这些坐标从外部可见。绘制箭头的图片使用选项(以便能够通过名称访问位于另一张图片中的目标节点)和(以便就 TeX 而言不占用页面上的任何空间)。below m
remember picture
tikzpicture
remember picture
overlay
当然,一旦找到了想要绘制的箭头的目标点(我称之为“有趣的地方”)的良好坐标,您应该注释掉或删除绘制网格和相关刻度的代码 - 这些只是为了帮助您找到“有趣的地方”的合适坐标。
第一个例子
下面的示例使用在具有形状的节点内框起来的文本rounded rectangle
作为箭头的来源——因为问题中提到了框起来的文本。rounded rectangle
来自shapes.misc
Ti钾Z 库。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.misc}
\begin{document}
\begin{frame}
\frametitle{The frame title}
\begin{figure}[H]
\begin{tikzpicture}[remember picture]
\node[anchor=south west, inner sep=0] (image) at (0,0)
{\includegraphics[width=0.6\linewidth, height=3cm]{example-image}};
\begin{scope}[x={(image.south east)}, y={(image.north west)},
every node/.style={font=\tiny}]
\draw[help lines, xstep=.1, ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,9}
{ \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9}
{ \node [anchor=east] at (0,\y/10) {0.\y}; }
% Define nodes here for the “interesting places” (i.e., where we
% want the arrows to point to).
\coordinate (below e) at (0.7,0.42);
\end{scope}
\end{tikzpicture}%
\begin{tikzpicture}[remember picture, overlay]
\draw node[rounded rectangle, draw=gray!80, fill=gray!10,
right=0.8em of image.east] (box) {Boxed text}
(box) [->, red!60!black] to[out=-150, in=-70] (below e);
\end{tikzpicture}
\end{figure}
This is below the picture.
\end{frame}
\end{document}
第二个例子
以下示例使用不同的技巧:箭头可以从幻灯片中的任何位置开始beamer
。我们绘制两个箭头,一个从段落中的单词或标点符号后开始,另一个从段落开头之前的边距开始(请注意,也可以使用\vadjust
,使箭头从段落中间包含特定单词的行的开头或结尾的空白处开始 - 这本质上是 TeXbook 的练习 14.28,如果你抽象 Ti钾基于Z的实现)。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{The frame title}
\begin{figure}[H]
\begin{tikzpicture}[remember picture]
\node[anchor=south west, inner sep=0] (image) at (0,0)
{\includegraphics[width=0.6\linewidth, height=3cm]{example-image}};
\begin{scope}[x={(image.south east)}, y={(image.north west)},
every node/.style={font=\tiny}]
\draw[help lines, xstep=.1, ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,9}
{ \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9}
{ \node [anchor=east] at (0,\y/10) {0.\y}; }
% Define nodes for interesting places (here: where we want the
% arrows to point to).
\coordinate (below e) at (0.7,0.42);
\coordinate (below m) at (0.4,0.42);
\end{scope}
\end{tikzpicture}
\end{figure}
This is below the picture. Here is an arrow pointing below the ``e'' of
our image: % one space token
\begin{tikzpicture}[remember picture, overlay, baseline=-0.5ex]]
\draw[->, red!80!black] (0,0) to[out=0, in=-120] (below e);
\end{tikzpicture}
\hspace*{-0.1em}% we'll start the second arrow in the left margin
\begin{tikzpicture}[remember picture, overlay, baseline=-0.7ex]]
\draw[->, blue!80!black] (0,0) to[out=180, in=-95] ++(-0.6em,5ex)
to[out=85, in=-90] (below m);
\end{tikzpicture}%
\hspace{0.1em}%
A second arrow pointing below the ``m''.
\end{frame}
\end{document}