我正在遵循这个例子这里绘制从图片上的一个位置到另一个位置的箭头。我成功地复制了回答,但无法使其与我在图形上绘制的节点一起工作。
我的 tikz 设置是
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\tikzstyle{every picture}+=[remember picture]
包含图像并且位置指定如下(我还想在图像顶部添加一些矩形和更多文本,这样就可以正常工作):
\includegraphics[width=.45\textwidth]{./white.png}
\hspace{-.45\textwidth}
\resizebox{.45\textwidth}{!}{
\tikz[baseline,remember picture]{
\useasboundingbox (0,0) rectangle (580pt,300pt);
\draw[color=black] (330pt,200pt) node[fill=green!20] (bad) {see how bad it is};
}
}
该图像white.png
宽 580 像素,高 300 像素。(对于这个最小示例,图像仅为纯白色)
(我对同一帧上的两个单独的图像执行此操作。然后调用第二张图像中的节点good
)
我尝试在两者之间画箭头
\begin{tikzpicture}[remember picture,overlay]
\path[draw=magenta,thick,->] ([yshift=2mm]bad.north) to [out=0, in=0,distance=1in] (good.east);
\end{tikzpicture}
但是这个箭头没有画出来。我确实确定我可以在图像中绘制箭头
\includegraphics[width=.45\textwidth]{./white.png}
\hspace{-.45\textwidth}
\resizebox{.45\textwidth}{!}{
\tikz[baseline,remember picture]{
\useasboundingbox (0,0) rectangle (580pt,300pt);
\draw[color=black] (330pt,200pt) node[fill=green!20] (bad) {~};
\draw[color=black] (330pt,100pt) node[fill=green!20] (good) {~};
\path[draw=magenta,thick,->] ([yshift=2mm]bad.north) to [out=0, in=0,distance=1in] (good.east);
}
}
完整文件如下:
\documentclass[8pt,xcolor=dvipsnames,table]{beamer}
\linespread{1.1}
\xdefinecolor{darkgreen}{RGB}{000, 128, 000}
\mode<presentation>
{
\usetheme{Rochester}
\usecolortheme[named=BrickRed]{structure}
\setbeamercovered{invisible}
\setbeamertemplate{mini frames}[box]
\setbeamertemplate{navigation symbols}{}}
\usepackage{appendixnumberbeamer}
\beamertemplateshadingbackground{Red!01!White}{White}
\usepackage[absolute,overlay]{textpos}
\useinnertheme{rectangles}
\useoutertheme{infolines}
\usepackage[UKenglish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes}
\tikzstyle{every picture}+=[remember picture]
\title{some title}
\author[pseyfert]{just me}
\date{\today}
\subject{}
\begin{document}
\begin{frame}
\frametitle{runstats}
\includegraphics[width=.45\textwidth]{./white.png}
\hspace{-.45\textwidth}
\resizebox{.45\textwidth}{!}{
\tikz[baseline,remember picture]{
\useasboundingbox (0,0) rectangle (580pt,300pt);
\draw[color=black] (330pt,200pt) node[fill=green!20] (bad) {see how bad it is};
}
}
\includegraphics[width=.45\textwidth]{./white.png}
\hspace{-.45\textwidth}
\resizebox{.45\textwidth}{!}{
\tikz[baseline,remember picture]{
\useasboundingbox (0,0) rectangle (580pt,300pt);
\draw[color=black] (320pt,200pt) node[fill=green!20] (good) {here it's much better};
}
}
\begin{tikzpicture}[remember picture,overlay]
\path[draw=magenta,thick,->] ([yshift=2mm]bad.north) to [out=0, in=0,distance=1in] (good.east);
\end{tikzpicture}
\end{frame}
\end{document}
我使用以下方式创建文档xelatex minimum.tex
,结果如下所示
我希望有一个从左到右的箭头
答案1
可能有些东西我没看到,但为什么不直接把所有东西都加到一起呢tikzpicture
?如果这两张带注释的图片就是框架中的全部内容,我想这会让事情变得更容易。
一个简单的例子:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}
\frametitle{runstats}
\begin{tikzpicture}
\node (bad) {\includegraphics[width=4cm]{example-image-a}};
\node (good) [right=of bad] {\includegraphics[width=4cm]{example-image-b}};
\node (a) [fill=yellow!20,draw] at (bad.center) {This is bad};
\node (b) [fill=yellow!20,draw] at (good.center) {This is good};
\draw [ultra thick,magenta,->] (a) to[bend left] (b);
\end{tikzpicture}
\end{frame}
\end{document}