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 draw such a diagram. Is there any tikz package for drawing such thing? Is there any example tex code for the same? How do I draw such diagrams?

enter image description here

I have tried drawing it. My tex code is as follows:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[margin=15mm]{geometry}
\usetikzlibrary{shapes,arrows,fit,calc,positioning}
\usepackage{scalefnt}

\begin{document}


\begin{tikzpicture}
[my shape/.style={rectangle split, rectangle split parts=#1, draw}]
\tikzset{input/.style={}}

\draw (0,0)--++(0,-10cm);
\draw (5,0)--++(0,-10cm);

\draw[->] (0,-1) coordinate (a) -- 
node [near end,sloped, above=2mm,my shape=2, rectangle split horizontal]    (n3) {0\nodepart{two}$m_0$}
node [left=3 cm of n3,sloped,above=2mm,my shape=2, rectangle split horizontal]  (n4) {0\nodepart{two}$m_0$}
++(5,-.5) coordinate (b);

\node [left =1mm of a,my shape=2, rectangle split horizontal] (n1) {0\nodepart{two}$m_0$};
\coordinate [below=1mm of b] (c) ;

\node [right=1mm of c, my shape=2, rectangle split horizontal] (n3)  {0\nodepart{two}$m_0$};
\coordinate [below=1mm of c] (d);
\draw[->] (d) -- ++(-5,-.5);

\path (a)--node[cross out,draw=red]{} (b);

\end{tikzpicture}


\end{document}

I am getting something like this : enter image description here

I want to have nodes above the arrow to be at the same distance from vertical lines. How do I do that?

Any help?

share|improve this question
    
I want the rectangle boxes to float with arrow. Any tex code? –  tikzlearner May 30 '12 at 5:55
3  
This question is too broad in its current form, you can't just post an image and say "I need to draw this". Take a look at TeXample.net, the pgfmanual or some of the tikz-pgf questions on this site to get started, and edit the question to be more concrete if you get stuck. –  Jake May 30 '12 at 6:23
2  
I think you can even refer to this question as starting point. –  Claudio Fiandrino May 30 '12 at 6:57
add comment

1 Answer

up vote 2 down vote accepted

Here you have a possible solution. Tikz is so flexible that you will find some more. What I've done is first draw the vertical lines and use them to place nodes on the left and right side. In fact I've drawn first arrow and name starting and finishing coordinates a and b. Paquet nodes are placed relative to a and b. Hope you could understand the code.

If your red beam means a broken link or some transmission problem I prefer to use some symbol over the link. In this example I've used a cross out node.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc,positioning}
\usepackage{scalefnt}

\begin{document}

\begin{tikzpicture}
[my shape/.style={rectangle split, rectangle split parts=#1, draw}]
\tikzset{input/.style={}}

\draw (0,0)--++(0,-10cm);
\draw (4,0)--++(0,-10cm);

\draw[->] (0,-.5) coordinate (a) -- 
node [near end,sloped, above=2mm,my shape=2, rectangle split horizontal] (n3) {0\nodepart{two}$m_0$}
++(4,-.5) coordinate (b);

\node [left =1mm of a,my shape=2, rectangle split horizontal] (n1) {0\nodepart{two}$m_0$};

\node [right=1mm of b, my shape=2, rectangle split horizontal] (n2)  {0\nodepart{two}$m_0$};

\draw[->,red] (b) -- ++(-4,-.5);

\path (a)--node[cross out,draw=red]{} (b);

\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thanks :) One doubt : How to put nodes above the arrow at same angle such that it looks good? –  tikzlearner May 30 '12 at 12:39
1  
@user1280282: Just add option sloped to node options list. –  Ignasi May 30 '12 at 13:05
    
I have edited my question. I have one more doubt. –  tikzlearner May 31 '12 at 4:30
    
@user1280282: as Peter Grill suggested in your other question, use pos=0.7 instead of near end. In fact near end, near start, ... are particular replacements for pos=... –  Ignasi May 31 '12 at 5:39
    
Thanks a lot :) –  tikzlearner May 31 '12 at 5:55
add comment

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.