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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am interested to make some diagrams like the sample picture. I am not sure whether it can be done using Latex or not. Can anybody give any idea. Thanks.

Sample Image

share|improve this question
    
It certainly can if you don't mind the time and the learning curve. Take a look at TikZ and PS Tricks. Also, there's a nice comparison of the two here tex.stackexchange.com/questions/6676/… – Au101 Feb 10 at 23:22
    
thank u so much. thats what i was looking for. – jhon_wick Feb 10 at 23:45
up vote 15 down vote accepted

For starting point in your learning (in case that as basic tool you select TikZ package) can serve the following MWE:

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{chains,decorations.pathreplacing}

\begin{document}
    \begin{tikzpicture}[
node distance=0pt,
 start chain = A going right,
    X/.style = {rectangle, draw,% styles of nodes in string (chain)
                minimum width=2ex, minimum height=3ex,
                outer sep=0pt, on chain},
    B/.style = {decorate,
                decoration={brace, amplitude=5pt,
                pre=moveto,pre length=1pt,post=moveto,post length=1pt,
                raise=1mm,
                            #1}, % for mirroring of brace, if necessary
                thick},
    B/.default=mirror, % by default braces are mirrored
                        ]
\foreach \i in {0,1,1,0,0,0,1,0,0,
                0,1,0,1,0,0,0,1,0,
                0,0,1,1,0,0,1,0,0}% <-- content of nodes
    \node[X] {\i};
\draw[B] ( A-1.south west) -- node[below=2mm] {Channel 1 Links} ( A-9.south east);
\draw[B] (A-10.south west) -- node[below=2mm] {Channel 2 Links} (A-18.south east);
\draw[B] (A-19.south west) -- node[below=2mm] {Channel 3 Links} (A-27.south east);
\node (B1) [inner sep=1pt,above=of A-10.north west] {$\times$};
\node (B2) [inner sep=1pt,above=of A-19.north west] {$\times$};
\draw[B=](B1.north) -- node[above=2mm] {Crossover Points}(B2.north);
    \end{tikzpicture}
\end{document}

which gives:

enter image description here

Short explanation of code: Above code is (very) concise, so for it understanding some experience with TikZ package is necessary. In it design I considered the following:

  • The simple structure of picture. It has 27 nodes with equal shapes which form a chain. Therefore the chains library from TikZ is used for their positioning. It is defined by option start chain = A going right, where A is chain name. Consequently nodes in chain are named A-1, A-2, ... , A-27.

  • Distances between nodes in chain is determined by node distance. Its default value is 15 mm, so with node distance=0pt it is set to zero, so nodes are separated only by outer sep parameter of shapes. That border lines are properly overlapped, also this distance is set to zero (in definition of nodes' style, it is named X)

  • In the TikZ the foreach loops is intended to do repeating task. Such task is setting nodes in chain. with

    \forach \i in {...}\node[X] {\i};

    are formed a chain of nodes (with style X), with content determined by list in curly braces. Since their positions are determined by chain, the loop actually only determine their number and content.

  • Braces below and above nodes is drawn by use of decorations.pathreplacing library. In it definition among their parameters the parameter mirror is select as free parameter which is can be determined later. Since the three from four braces are mirrored, this is set as default and exception is determined "locally".

  • Braces is designed so, that they are 1pt shorter on each side than is distance between coordinates, and with raise=1mm is move below (when is mirrored) or above (when is not mirrored) from given coordinates.

  • The crosses above begin and end of "channel 2 links" is set on "classic way" with above=of <coordinate name> and for it is used math symbol for multiplying.

More deep description of principle of TikZ which are used heree is in TikZ manual:

  • for chains: chapter 46 Chains, page 541
  • for \foreach loop: chapter 83 Repeating Things: The Foreach Statement, page 901
  • for braces: subsection 48.3 Path Replacing Decorations, page 581
share|improve this answer
    
would you be willing to annotate that code a bit? For example, is the code from node distance through the \foreach loop all one command? – dedded Feb 11 at 2:38
    
I will, very soon :-) – Zarko Feb 11 at 11:03

A short code with pstricks:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage{pstricks-add, multido}
\usepackage{auto-pst-pdf}

\begin{document}
\sffamily

 \begin{pspicture}
  \psset{dimen=middle, linewidth=0.6pt, braceWidthOuter=4pt, braceWidthInner=4pt, braceWidth=0.8pt, labelsep =-2ex}
  \multido{\i = 0 + 1, \n=0+0.5}{27}{\fnode[framesize=0.5](\n, 0){A\i}}%
  \rmultiput{$0$}(A0)(A3)(A4)(A5)(A7)(A8)(A9)(A11)(A13)(A14)(A15)(A17)(A18)(A19)(A22)(A23)(A25)(A26)
  \rmultiput{$1$}(A1)(A2)(A6)(A10)(A12)(A16)(A20)(A21)(A24)
  \psset{rot=90, nodesepB=2ex}
  \multido{\ia=0 + 9, \ib=8 + 9}{3}{\pnode[-0.15, -0.35](A\ia){B\ia}\pnode[0.15, -0.35](A\ib){B\ib}\psbrace(B\ia)(B\ib){\clap{Channel\,1 Links}}}
  \multido{\i=8 + 9}{2}{\pnode[0.25,0.6](A\i){C\i}\uput{1pt}[d](C\i){$\times$}}
  \psbrace[rot=-90, nodesepB=-0.5ex](C17)(C8){\clap{Crossover Points}}
\end{pspicture}

\end{document} 

enter image description here

share|improve this answer

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.