# How to draw arrow between two text lines?

I want to draw this figure. Is it possible ?

I have written the following code to draw that figure :

    \documentclass[11pt,twoside,a4paper]{book}

\usepackage{xypic,wrapfig}
\begin{document}

\xymatrix{
\verb|\begin{wrapfigure}|[12]{r}[34pt]{5cm} &  <figure> &  \verb|\end{wrapfigure}|\\

& [<Number of narrow lines>]{<placement>}[<overhang>]{<width>}&
}

\end{document}


But failed!

@Gonzalo Medina's answer which I have compiled it.

\documentclass{article}
\usepackage{tikz}

\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay]\node[inner ysep=4pt] (#1) {};}

\def\n#1{{\normalfont\ttfamily\small#1}}
\def\cs#1{{\normalfont\ttfamily\small\char\\#1}}
\def\all{{\normalfont\ttfamily\small\char\{}}
\def\cll{{\normalfont\ttfamily\small\char\}}}
\def\aop#1{{\normalfont\ttfamily\small\char$#1\char$}}
\def\aob#1{{\normalfont\ttfamily\small\char\{#1\char\}}}
\def\gr#1{{\normalfont\ttfamily\small<\,#1\,>}}
\def\env#1{\all\n{#1}\cll}

\begin{document}

\hfill\cs{begin}\env{wrapfigure}\aop{\tikzmark{nla}12}%
\aob{\tikzmark{pla}r}\aop{\tikzmark{ova}34pt}\aob{\tikzmark{wia}5cm} %
\gr{figure} \cs{end}\env{wrapfigure}

\vskip20pt

\noindent\aop{\gr{number of \tikzmark{nlb}narrow lines}}%
\aob{\gr{\tikzmark{plb}placement}}\aop{\gr{\tikzmark{ovb}overhang}}%
\aob{\gr{\tikzmark{wib}width}}

\begin{tikzpicture}[remember picture,overlay]
\draw[->] ([xshift=15pt,yshift=3pt]nlb.north) -- ([xshift=5pt]nla.south);
\draw[->] ([xshift=15pt,yshift=3pt]plb.north) -- (pla.south);
\draw[->] ([xshift=15pt,yshift=3pt]ovb.north) -- ([xshift=8pt]ova.south);
\draw[->] ([xshift=15pt,yshift=3pt]wib.north) -- ([xshift=8pt]wia.south);
\end{tikzpicture}

\end{document}


But This gives:

-
A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  texenthusiast Apr 16 '13 at 4:04
Thank you very much for your tip. –  Soumitra Sen Apr 16 '13 at 4:12
You need to compile three times for the code to produce the lines in the right position. –  Gonzalo Medina May 15 '13 at 22:15

One option would be to use the ubiquituous \tikzmark command to place some marks, and then use the marks to draw the arrows:

\documentclass{article}
\usepackage{tikz}

\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay]\node[inner ysep=4pt] (#1) {};}

\def\n#1{{\normalfont\ttfamily\small#1}}
\def\cs#1{{\normalfont\ttfamily\small\char\\#1}}
\def\all{{\normalfont\ttfamily\small\char\{}}
\def\cll{{\normalfont\ttfamily\small\char\}}}
\def\aop#1{{\normalfont\ttfamily\small\char$#1\char$}}
\def\aob#1{{\normalfont\ttfamily\small\char\{#1\char\}}}
\def\gr#1{{\normalfont\ttfamily\small<\,#1\,>}}
\def\env#1{\all\n{#1}\cll}

\begin{document}

\hfill\cs{begin}\env{wrapfigure}\aop{\tikzmark{nla}12}%
\aob{\tikzmark{pla}r}\aop{\tikzmark{ova}34pt}\aob{\tikzmark{wia}5cm} %
\gr{figure} \cs{end}\env{wrapfigure}

\vskip20pt

\noindent\aop{\gr{number of \tikzmark{nlb}narrow lines}}%
\aob{\gr{\tikzmark{plb}placement}}\aop{\gr{\tikzmark{ovb}overhang}}%
\aob{\gr{\tikzmark{wib}width}}

\begin{tikzpicture}[remember picture,overlay]
\draw[->] ([xshift=15pt,yshift=3pt]nlb.north) -- ([xshift=5pt]nla.south);
\draw[->] ([xshift=15pt,yshift=3pt]plb.north) -- (pla.south);
\draw[->] ([xshift=15pt,yshift=3pt]ovb.north) -- ([xshift=8pt]ova.south);
\draw[->] ([xshift=15pt,yshift=3pt]wib.north) -- ([xshift=8pt]wia.south);
\end{tikzpicture}

\end{document}


The commands \n, \cs, \all,...,\env were defined to facilitate the writing of code-like syntax, without using \verb.

The above code needs at least two runs to stabilize.

In my personal opinion, there's no need to use those arrows, I'd rather use something like

\documentclass{article}
\usepackage[margin=3cm]{geometry}
\usepackage{listings}

\lstset{
basicstyle=\small\ttfamily,
breaklines=true
}

\begin{document}

\begin{lstlisting}
\begin{wrapfigure}[<narrow lines>]{<placement>}[<overhang>]{<width>}
(figure code)
\end{wrapfigure}
\end{lstlisting}
Where \lstinline{<narrow lines>} must be a positive integer,...

\end{document}


-
your first answer does not give the picture you have post.I have compiled it and this gives which shown in the following answer. –  Soumitra Sen Apr 16 '13 at 4:59
@SoumitraSen sorry to bother you, but I noticed that although you have up-voted answers, you still haven't accepted any of them. Accepting and up-voting are two different actions: you can up-vote several answers to a question (the ones you consider good), but you can only accept one answer per question, using the check-mark to the left of the answer. Please consider revising your questions and accepting the answers that you consider best solved your problems. In case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Apr 16 '13 at 13:19