箭头中间的图片

箭头中间的图片

我正在使用 beamer 工作,想将图片放在箭头中间,如下所示: 在此处输入图片描述

问题是,我想要图片在前景中。我尝试使用图层,但我觉得图层会被 beamer 类图层覆盖。

接下来的事情:

\draw [myarrow2] (A1) to (B1.north west);
\path (A1) -- (B1.north west) coordinate[midway] (r);
\node at (r) {\includegraphics[width=3em]{sensor.png}};

我也尝试使用 \draw 中的节点定义,但结果是一样的。

有什么办法可以让它工作吗?

提前致谢!

編輯:MWE

\documentclass[17pt,t,table]{beamer}
\usepackage{graphicx}
\graphicspath{{./figs/}}
\RequirePackage{pgfpages}
\RequirePackage{tikz,tikzscale,pgfplots}
\usetikzlibrary{shapes.arrows,calc,fadings,shadows.blur,positioning,spy,arrows,decorations.text,decorations.markings,quotes,angles,babel,backgrounds}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}   %% some additional layers for demo
\begin{document}
    \begin{frame}{Übersicht}
    \begin{columns}[onlytextwidth,T]
        \column{\textwidth}
%       \vspace*{-5em}
\begin{tikzpicture}
\tikzset{myarrow2/.style={->, >=latex, shorten >=2pt,shorten <=.5em,line width=.6em,color=red}}
    \node[](A1) at (0,0) {};
\node[right =of A1](A2) {}; 
\draw [myarrow2] (A1) to (A2);
\path (A1) -- (A2) coordinate[midway] (r);
\node at (r) {\includegraphics[width=3em]{sensor.png}};
    \end{tikzpicture}
\end{columns}
\end{frame}
\end{document}

答案1

几乎不可能帮助您,因为您没有提供完整的小文档,这将显示您的问题。因此,代码片段中使用的所有定义都是未知的。

看看以下解决方案是否适合您:

\documentclass[tikz, margin=3mm, demo]{standalone}
\usetikzlibrary{arrows.meta}
 \begin{document}
\begin{tikzpicture}
\path [draw=teal, line width=4mm, -Triangle] 
    (0,0) to node {\includegraphics[width=3em, height=3em]{sensor.png}} +(5,0);
\end{tikzpicture}
\end{document}

在此处输入图片描述

通过pos=...向节点添加选项,您可以将节点位置移动到您估计比现在更好的位置(在默认位置:)pos=0.5,例如

\path [draw=teal, line width=4mm, -Triangle] 
    (0,0) to node[pos=0.4] {\includegraphics[width=3em, height=3em]{sensor.png}} 

给出:

在此处输入图片描述

附录: 关于您在编辑的问题中的mwe:

您的箭头被节点中的图片覆盖。您有两个选择:使图像变窄或使箭头变长。例如:

\documentclass[17pt,t,table, demo]{beamer}
\graphicspath{{./figs/}}
\RequirePackage{pgfpages}
\RequirePackage{tikz,tikzscale,pgfplots}
\usetikzlibrary{angles, arrows,
                backgrounds,
                calc,
                decorations.text, decorations.markings,
                fadings,
                positioning,
                quotes,
                shadows.blur,shapes.arrows,
                spy,
                babel,}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}   %% some additional layers for demo
\begin{document}
    \begin{frame}{Übersicht}
    \begin{columns}[onlytextwidth,T]
        \begin{column}{0.5\textwidth} 
your solution: 

\begin{tikzpicture}
\tikzset{myarrow2/.style={draw=red, -latex, line width=.6em,
                          shorten >=2pt, shorten <=.5em}
        }
\node   (A1) {};
\node[right=of A1] (A2) {};
\draw[myarrow2] (A1) to node {\includegraphics[width=3em] {sensor.png}} (A2);
% to see your arrow
\draw[myarrow2] (A1) to (A2);
    \end{tikzpicture}
\end{column}

\begin{column}{0.5\textwidth}
suggested correction:    
    \begin{tikzpicture}[
    node distance = 44mm,
myarrow2/.style={draw=red, -latex, line width=.6em}
                        ]
\node               (A1) {};
\node[right=of A1]  (A2) {};
\draw[myarrow2] (A1) to node[pos=0.4] {\includegraphics[width=3em] {sensor.png}} (A2);
    \end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\end{document}

在此处输入图片描述

答案2

感谢您的 MWE!从您的图片中,我得知您希望将箭头置于背景中,并使箭头透明。为了做到这一点,必须使用(而不仅仅是声明)图层(但它们无论如何都包含在您正在加载的背景库中),并使用透明组以使箭头不出现故障。此外,箭头有点短,以至于被您的图片覆盖,我也修复了这个问题。

\documentclass[17pt,t,table]{beamer}
\RequirePackage{tikz}
\usetikzlibrary{positioning,backgrounds}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}   %% some additional layers for demo
\begin{document}
\begin{frame}{\"Ubersicht}
\begin{columns}[onlytextwidth,T]
\column{\textwidth}
\begin{tikzpicture}
\tikzset{myarrow2/.style={->, >=latex, shorten >=2pt,shorten <=.5em,line width=.6em,color=red}}
\node[](A1) at (0,0) {};
\node[right =5cm of A1](A2) {}; 
\begin{scope}[transparency group,opacity=0.5]
\draw[myarrow2] (A1) to coordinate[midway] (r) (A2) ;
\end{scope}
\begin{scope}[on background layer]
\node at (r) {\includegraphics[width=3em]{example-image-duck}};
\end{scope}
\end{tikzpicture}

Without transparency group
\begin{tikzpicture}
\tikzset{myarrow2/.style={->, >=latex, shorten >=2pt,shorten <=.5em,line width=.6em,color=red}}
\node[](A1) at (0,0) {};
\node[right =5cm of A1](A2) {}; 
\draw[myarrow2,opacity=0.5] (A1) to coordinate[midway] (r) (A2) ;
\begin{scope}[on background layer]
\node at (r) {\includegraphics[width=3em]{example-image-duck}};
\end{scope}
\end{tikzpicture}
\end{columns}
\end{frame}
\end{document}

在此处输入图片描述

嗯,没有透明度就容易得多。

\documentclass[17pt,t,table]{beamer}
\RequirePackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}{\"Ubersicht}
\begin{columns}[onlytextwidth,T]
\column{\textwidth}
\begin{tikzpicture}
\tikzset{myarrow2/.style={->, >=latex, shorten >=2pt,shorten <=.5em,line width=.6em,color=red}}
\node[](A1) at (0,0) {};
\node[right =5cm of A1](A2) {}; 
\draw[myarrow2] (A1) to node[midway]{\includegraphics[width=3em]{example-image-duck}}
 (A2) ;
\end{tikzpicture}
\end{columns}
\end{frame}
\end{document}

在此处输入图片描述

相关内容