3

I am trying to get the text that I place inside a curved arrow to curve with the arrow. I have the following code that generates that given picture, but I wonder how I can get the text to curve with the arrow. I have found a solution proposal here, but I could not adapt it to my case. In particular, I would really like to get the definition of vecArrow to be modified to do what I want (ideally with the text as an argument). Any help would be appreciated.

\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}

enter image description here

ozsu
  • 2,385
  • decorations.text. If you don't use a decoration to draw the arrow (but just make the arrow an arrow), then you can use the text along path decoration straightforwardly, I think. – cfr Aug 13 '14 at 17:37
  • Thanks much. However, as you can see from the code, I am unfortunately using decorations to draw the arrow. If I put text along path inside the decorations (in vecArrow definition) then it doesn't put an arrow head. – ozsu Aug 13 '14 at 18:24
  • Why can't you draw the arrow head not as a decoration? – cfr Aug 13 '14 at 20:53

1 Answers1

3

Here is one way to do it:

\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}

Text on curved arrow

cfr
  • 198,882
  • @ozsu Glad it helped. Don't forget that the local way of saying 'thanks' is to vote an answer up and/or, after a couple of days, to accept the most helpful of the answers you get. (You probably wouldn't want to accept anything at this point, though, as it is too soon.) – cfr Aug 13 '14 at 23:14
  • Sorry, I forgot to vote up -- I just did. – ozsu Aug 14 '14 at 01:07
  • @ozsu No problem. It always feels wrong to ask but usually if somebody says something would work great, they generally mean to do the equivalent of up-voting even if the answer is not ideal. I hope somebody will answer your question by showing how to combine the decorations as that would be really useful but I've no idea how to do it or even if it can be done. – cfr Aug 14 '14 at 01:21