Effectively, what I want to do is very simple but I am not sure where to go.

I have several nodes of the following form

\node (1) at (0,0) {text1 $\rightarrow$ text2};
\node (2) at (0,2) {text2 $\rightarrow$ text3};
\node (3) at (0,4) {text3 $\rightarrow$ text4};

I would like to replace the text arrow ($\rightarrow$) with a tikz arrow with a certain decorated arrow head. However, I do not want to specify the start and end of these arrows in each case. Is there a way to say

XXXXXXa (arrow from a.right where a is a character of text, to b.left, where b is also a text character) bXXXXXX

and further do this within the text for a node? I can then move this node wherever and the arrow stays between my two words of text.

I have been looking at nesting tikzenvironments however this seems to be bad practice so am hoping there is another way.


You can define a macro to do the drawing:

enter image description here


  • The length of the arrow is determined by \ArrowLength so that can either be set globally or changed locally with \renewcommand{\ArrowLength}{<length>}.



    \tikz [-stealth, red, yshift=0.5ex, baseline] 
        \draw [-stealth, #1] (0,0) -- (\ArrowLength,0) ;

    \node (1) at (0,0) {text1 \MyRightArrow text2};
    \node (2) at (0,1) {text2 \MyRightArrow[blue]text3};
    \node (3) at (0,2) {text3 \MyRightArrow[red, densely dashed]text4};
  • This is nesting tikz environments though correct? – James Oct 9 '14 at 6:22
  • I am not sure that using an inline \tikz is the equivalent of nesting a tikzpicture within a tikzpicture. The cover picture of the tikz-pgf manual actually uses \tikz within a \tikzpicture so I think it is ok. – Peter Grill Oct 9 '14 at 6:29
  • Ah ok. Maybe a somewhat duplicate question then. I asked separately as was assuming it was nested and there are similar questions about nesting environments etc. – James Oct 9 '14 at 6:43

You can use tikzmarks


   \begin{tikzpicture}[remember picture, myarrow/.style={->,yshift=.3em,shorten <=3pt,shorten >=3pt}]

     \node (1) at (0,0) {text1\tikzmark{t1} \phantom{$\rightarrow$} \tikzmark{t2}text2};
     \draw[myarrow](pic cs:t1)--(pic cs:t2);

     \node (2) at (0,2) {text3\tikzmark{t3} \phantom{$\rightarrow$} \tikzmark{t4}text4};
     \draw[myarrow](pic cs:t3)--(pic cs:t4);

     \node (3) at (0,4) {text5 $\rightarrow$ text6};

enter image description here

It needs two runs to draw the arrows in the correct positions. You can further tweak the style of the arrow (myarrow in the mwe) if you want to make it exactly the same as $\rightarrow$. I used phantoms to keep the distance between text.

tcolorbox solution

Another possibility is to load tcolorbox and draw an invisible box around the text you want to connect inside a node:


    enhanced jigsaw,
    on line,
    remember as=#1,

   \begin{tikzpicture}[remember picture,myarrow/.style={->,shorten <=3pt,shorten >=3pt}]

    \node (1) at (0,0) {\mybox{b1}{text1} \phantom{$\rightarrow$} \mybox{b2}{text2}};

When you have the text boxed you can connect the boxes using standard node anchors (north, south, etc.) as if it were a node inside a node. This spare you from adjusting the xshift of the arrow, since you can anchor it to box.east. It still needs two compilations and the final result is basically the same as before.

  • 1
    I feel \tikz is an easier answer. \tikzmarks seem very useful though, thanks, I'll have to check them out. – James Oct 9 '14 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.