[Tex/LaTex] How to draw arrow between two text lines

arrowsxy-pic

I want to draw this figure. Is it possible ?
enter image description here

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:

enter image description here

Best Answer

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}

enter image description here

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}

enter image description here