我正在尝试让放置在弯曲箭头内的文本随箭头弯曲。我有以下代码可以生成给定的图片,但我不知道如何让文本随箭头弯曲。我找到了一个解决方案建议这里,但我无法将其调整到适合我的情况。特别是,我真的很想修改 vecArrow 的定义以执行我想要的操作(最好使用文本作为参数)。任何帮助都将不胜感激。
\documentclass[table,xcolor=pdftex,dvipsnames]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,snakes,positioning,decorations.text,decorations.pathmorphing,decorations.markings}
\begin{document}
\begin{frame}
\frametitle{Curved Arrow}
\tikzset{
vecArrow/.style={
line width=3ex,
decoration={markings,mark=at position
1 with {\arrow[scale=2, blue!20!white]{triangle 60}}},
blue!20!white,
shorten >= 32pt,
line width=4pt,
preaction = {decorate},
postaction = {draw=blue!20!white,line width=3ex, shorten >= 30pt}
}
}
\begin{tikzpicture}
\node[rectangle,draw,minimum width=2in, minimum height=1in] (box1) {};
\node[rectangle,draw,minimum width=2in, minimum height=1.5in,below right=of box1] (box2) {};
\draw[vecArrow] (box1.east) to[in=135,out=45] node[black,rotate=-47,anchor=west,xshift=-6mm]{\scriptsize Subgraph Match} (box2.north);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
以下是一种方法:
\documentclass[table,xcolor=pdftex,dvipsnames]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending,positioning,decorations.text}
\begin{document}
\tikzset{
vecArrow/.style={
draw, line width=3ex, blue!20!white, -{Triangle[bend, angle=60:1pt 2]}, shorten >=6pt, postaction=decorate, decoration={text along path, text color=black, text align=center, text={|\scriptsize|#1 ||}}
}
}
\begin{frame}
\frametitle{Curved Arrow}
\begin{tikzpicture}
\node[rectangle,draw,minimum width=2in, minimum height=1in] (box1) {};
\node[rectangle,draw,minimum width=2in, minimum height=1.5in,below right=of box1] (box2) {};
\path [vecArrow=Subgraph Match] (box1.east) to[in=135,out=45] (box2.north);
\end{tikzpicture}
\end{frame}
\end{document}