tikz matrix placement

View: New views
2 Messages — Rating Filter:   Alert me  

tikz matrix placement

by James Ismail :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I've been using tikZ matrices to generate some really wonderful block diagrams.  However, I feel I have no control over the final placement as they always come out too far to the right.  I tried using the positioning library but I wasn't able to move the block diagram at all.

Below is some code that is an example of what I'm working with.  I would like to know how to control the placement of the block diagram so that I can center it better.  Any advice would be much appreciated.


Thanks,
James


\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,arrows,positioning}

\begin{document}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\tikzset{every node/.style={scale=0.750}}

% define styles
\tikzstyle{sumJunction} = [draw, circle,inner sep=2pt,minimum size=3pt,] % use this style to show routing points
\tikzstyle{controller} = [draw, fill=blue!20, text width=5em,text centered, minimum height=4em]
\tikzstyle{plant} = [draw, fill=red!20, text width=5em,text centered, minimum height=3em]
\tikzstyle{point} = [coordinate]
\tikzstyle{separator} = [minimum size=12mm]
\tikzstyle{scalarSignal} = [draw,-latex']
\tikzstyle{vectorSignal} = [scalarSignal,line width=1.5pt]
\tikzstyle{nonTerminal} = [-]


\parindent0pt
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis enim velit. Sed eleifend pulvinar porttitor. Vestibulum diam arcu, dictum suscipit pretium sed, dictum eget dolor. Sed suscipit, odio nec faucibus vestibulum, enim nunc commodo justo, pretium dapibus neque lacus et ipsum. Phasellus ut lacus eu libero commodo dapibus in sed magna. Duis posuere magna vitae libero rhoncus fringilla. Nunc imperdiet auctor lectus a mattis. Fusce id nibh nulla, non accumsan est. Proin congue ullamcorper dolor, pulvinar ornare arcu porttitor quis. Vivamus tempor dolor eget arcu sodales quis eleifend ligula interdum. Quisque diam arcu, facilisis eu hendrerit eu, ornare ac urna. In congue hendrerit nulla. Sed adipiscing quam a urna bibendum pellentesque.

\begin{tikzpicture}

% blocks
\matrix [row sep=1mm,column sep=2mm] {
\path node [separator] (p1) {}; &

% sum
\path (p1.east) node (sum1) [sumJunction] {+};
\path ($(sum1)!3.0!(sum1.west)$) node [point,label=above:$r$] (u1) {}; &
\path (sum1.east) node [separator] (p1a) {}; &

% C
\path (sum1.east) node (blockC) [controller] {C}; &

% r
\path (blockC.east) node (p2a) {}; &
% H
\path (p2a.east) node (blockH) [controller] {H}; &
% separator column
\path (blockH.east) node (p22) [separator] {}; &

% CPU & GPU
\path (blockH.-60 -| p22.east) node (Z) [plant] {Z};
\path (blockH.60  -| p22.east) node (Y) [plant] {Y}; &

% signal - f
\path (Y.east |- p22) node (sum2) [sumJunction] {+}; &

% separator column
\path (sum2.east) node (p3) {}; &

% F
\path (p3) node (blockF) [plant] {F}; &

% signal - y
\path (blockF.east) node [point,label=above:$y$] (p51a) {};

\\};

% signal lines
% r -> sum1
\path [scalarSignal] ($(sum1)!6.0!(sum1.west)$) -> (sum1.west);
% sum1 -> C
   \path [scalarSignal] (sum1) -> (blockC);

% C -> H
   \path [scalarSignal] (blockC) -> (blockH);
   % H -> CPU & GPU
   \path [scalarSignal] (blockH.-20) -- (blockH.-20 -| p22) |- (Z);
   \path [scalarSignal] (blockH.20) -- (blockH.20 -| p22) |- (Y);

   % CPU & GPU -> F
   \path [scalarSignal] (Y) -| (sum2);
   \path [scalarSignal] (Z) -| (sum2);

   % sum2 -> F
   \path [scalarSignal] (sum2) -> (blockF);

   % F -> sum1
   \path ($(blockF)!1.5!(Z.south -| blockF.east)$) node (a) {};
   \path (a -| sum1) node (b) {};
\path [scalarSignal] (blockF.east) -| (a.base) -- (b.base) -> (sum1);

   \begin{pgfonlayer}{background}

       \path ($(blockC)!1.5!(blockC.south west)$) node (a) {};
       \path ($(blockH)!1.5!(blockH.north east)$) node (b) {};
       \path[fill=blue!10, draw=black!50]
           (a) rectangle (b);
           
       \path ($(Z)!1.5!(Z.south west)$) node (a) {};
       \path ($(blockF)!1.25!(Y.north -| blockF.east)$) node (b) {};
       \path[fill=red!10, draw=black!50]
           (a) rectangle (b);
           
   \end{pgfonlayer}
\end{tikzpicture}
\parindent0pt
Vivamus vitae mauris lectus, vitae ullamcorper purus. Integer a urna eu arcu fermentum scelerisque. Cras non neque a erat elementum aliquam eu sit amet sapien. Fusce iaculis, massa at imperdiet porta, tellus arcu tempor augue, nec placerat elit augue eget eros. Praesent cursus dui rhoncus enim cursus tincidunt. Morbi lectus eros, hendrerit quis accumsan vel, aliquet a augue. Maecenas accumsan felis in lectus venenatis volutpat. Aliquam erat volutpat. Mauris egestas vehicula tincidunt. Etiam suscipit rhoncus laoreet. Nullam sodales viverra lobortis. Ut convallis diam nisi.

\end{document}


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: tikz matrix placement

by Alain Matthes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Le 1 sept. 2009 à 23:43, James Samir Ismail a écrit :

> Hello,
>
> I've been using tikZ matrices to generate some really wonderful  
> block diagrams.  However, I feel I have no control over the final  
> placement as they always come out too far to the right.  I tried  
> using the positioning library but I wasn't able to move the block  
> diagram at all.
>
> Below is some code that is an example of what I'm working with.  I  
> would like to know how to control the placement of the block diagram  
> so that I can center it better.  Any advice would be much appreciated.



> \begin{tikzpicture}
>
> % blocks
> \matrix [row sep=1mm,column sep=2mm] {
>
> \path node [separator] (p1) {}; &

Hi,

  why "separator" at the beginning ?

\node (p1) {};

and with
>
> \tikzstyle{separator} = [minimum size=12mm]
>

and perhaps, 10 mm instead of 12mm


Best Regards

Alain Matthes
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users