0

Following is my code and the corresponding beamer slide:

'\documentclass{beamer}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{textcomp}
\usetikzlibrary{arrows, positioning, shapes.geometric}

\begin{document}
% Definition of blocks:

%------------------------------------------------
\tikzstyle{block} = [rectangle, minimum width=1.5cm, minimum height=1cm, text centered, text width=1.5cm, draw=black, fill=white]
\tikzstyle{dormant.block} = [rectangle, minimum width=1.5cm, minimum height=1cm, text centered, text width=1.5cm, draw=black, fill=gray!30]
\tikzstyle{text.block} = [rectangle, minimum width=0.5cm, minimum height=1cm, text centered, text width=0.5cm, draw=white, fill=white]
\tikzstyle{label.block} = [rectangle, minimum width=1.5cm, minimum height=1cm, text centered, text width=1.5cm, draw=white, fill=white]
\tikzstyle{s.block} = [rectangle, minimum width=0.5cm, minimum height=1cm, text centered, text width=0.5cm, draw=white, fill=white]

 %------------------------------------------------
 \tikzstyle{FIX} = [circle,minimum size=1em,text centered, draw=white]
 \tikzstyle{adder} = [circle,minimum size=1em,text centered, draw=black]

  %------------------------------------------------
  \tikzstyle{arrow} = [thick,->,>=stealth]
  \tikzstyle{rarrow} = [thick,<-,>=stealth]

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 \begin{frame}
 \frametitle{Dummy}
 \begin{center} 
 \begin{tikzpicture}[node distance=2 cm]
 \node(ref.pnt) at (-9.5,3.4) [FIX]{};
 \node(b1)  [text.block, right of=ref.pnt, xshift=-3.33cm]  {B1};
 \node(b2)  [block, right of=b1, xshift=-0.0cm]             {B2};
 \node(b3)  [s.block, right of=b2, xshift=0.3cm]            {*};
 \node(b4)  [block, right of=b3, xshift=0.3cm]              {B4};
 \node(b5)  [block, right of=b4, xshift=0.8cm]              {B5};
 \node(b6)  [adder, below of=b5, yshift=0.5cm]              {+};
 \node(b7)  [text.block, right of=b6, xshift=-0.75cm]       {B7};
 \node(b8)  [block, below of=b6, yshift=0.5cm]              {B8};
 \node(b9)  [block, left of=b8, xshift=-0.8cm]              {B9};
 \node(b10) [s.block, left of=b9, xshift=-0.3cm]            {*};
 \node(b11) [s.block, below of=b10, xshift=-0.0cm]          {*};
 \node(b12) [block, left of=b10, xshift=-0.3cm]             {B12};
 \node(b13) [text.block, left of=b12, xshift=0.0cm]         {B13};

 \draw [arrow]  (b1)    --   (b2);
 \draw [arrow]  (b2)    --   (b3);
 \draw [arrow]  (b3)    --   (b4);
 \draw [arrow]  (b4)    --   (b5);
 \draw [arrow]  (b5)    --   (b6);
 \draw [arrow]  (b7)    --   (b6);
 \draw [arrow]  (b6)    --   (b8);
 \draw [arrow]  (b8)    --   (b9);
 \draw [arrow]  (b9)    --   (b10);
 \draw [arrow]  (b10)   --   (b12);
 \draw [arrow]  (b12)   |-   (b11);
 \draw [arrow]  (b12)   --   (b13);
 \draw [rarrow] (b9.south)++(-.3,0) |- (b11.east); 
 \draw [arrow]  (b9.south)++(.3,0) |- ++(0,-1.5) -| (b8);

 \node(type2)  [label.block, below of=b11, yshift=0.8cm] {$Type-II$};

 \end{tikzpicture}
 \end{center}
 \end{frame}

 \end{document}`

enter image description here

I want to make the two loops

  1. B8-B9-B8
  2. B9-$\lambda$-B12-$\gamma$-B9

equal in size. How can I do this. I have tried using 'xshift' but it moves the whole diagram to left and right and not the individual nodes. Secondly I want to replace \node(ref.pnt) at (-9.5,3.4) [FIX]{}; with something more friendly. I defined ref.pnt so that all my blocks are plotted wrt to this fixed point.

  • Change the xshift of the B9 node? That can't possibly move the whole diagram ;). – cfr Mar 4 '16 at 1:00
  • 1
    There are libraries to make this stuff much, much easier, you know. Or even just setting things on a grid. – cfr Mar 4 '16 at 1:00
  • Where is s.block defined? – cfr Mar 4 '16 at 1:07
  • @ cf...Code updated. I am not familiar with relevant libraries. Would appreciate if you add some reference. – NAASI Mar 4 '16 at 1:08
  • Actually I am trying to move B1 to left so that all blocks also move to left from their current position. But I can't do that. – NAASI Mar 4 '16 at 1:14
1

I'm not sure what the point of the reference point is since everything is relative anyway. (Not just a point about physics, but TikZ.)

There are various ways of making this easier: using a grid, using different packages, using libraries. I quite like chains for this kind of thing, but that may just be my preference.

You can either rely on the automatic numbering which names the chains or specify node names. Here, I use a mixture depending on what's easiest. The disadvantage of the automatic method is that inserting a node changes later names in the chain. But I guess any automated naming has that kind of issue.

Note that \tikzstyle is deprecated, as is the arrows library.

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{arrows.meta,positioning,chains,scopes}
\begin{document}
\tikzset{%
  block/.style = {rectangle, minimum width=1.5cm, minimum height=1cm, text centered, text width=1.5cm, draw=black, fill=white},
  s.block/.style = {rectangle, minimum width=0.5cm, minimum height=1cm, text centered, text width=0.5cm, draw=black, fill=white},
  text.block/.style = {rectangle, minimum width=0.5cm, minimum height=1cm, text centered, text width=0.5cm, draw=white, fill=white},
  label.block/.style = {rectangle, minimum width=1.5cm, minimum height=1cm, text centered, text width=1.5cm, draw=white, fill=white},
  adder/.style = {circle,minimum size=1em,text centered, draw=black},
  arrow/.style = {thick,->,>=Stealth},
  rarrow/.style = {thick,<-,>=Stealth},
}

\begin{tikzpicture}[node distance=2cm, start chain=b going right, every on chain/.append style={join}, every join/.append style=arrow]
  \node [on chain, text.block] {B1};
  \node [on chain, block] {B2};
  \node [on chain, s.block] {*};
  \node [on chain, block] {B4};
   {[every join/.style=thick]\node [on chain, coordinate] {};}
  \node [on chain, block] {B5};
  {[continue chain=b going below]
    \node [on chain, adder] {*};
    {[start branch=A going right, every join/.style=rarrow]
      \node [on chain, text.block] {B7};
    }
    \node [on chain, block] {B8};
  }
  {[continue chain=b going left]
    {[every join/.style=thick]\node [on chain, coordinate] {};}
    \node [on chain, block] {B9};
    \node (b10) [on chain, s.block] {*};
    \node (b12) [block, on chain] {B12};
    {[start branch=C going below, every join/.style=thick]
      \node [on chain, shape=coordinate] {};
    }
    \node [on chain, text.block] {B13};
  }
  {[continue chain=b/C going right]
    \node (b11) [s.block, label={[label.block]below:$Type-II$}] at (b10 |- b/C-2) {*};
    \chainin (b11);
  }
  \draw [arrow] (b11) -| ([xshift=-5pt]b-10.south);
  \draw [arrow] ([xshift=5pt]b-10.south) |- (b-9 |- b/C-2) -| (b-8.south);
\end{tikzpicture}
\end{document}

chain of nodes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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