Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
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

1 Answer 1

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

share|improve this answer
    
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
3  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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