Problem joining two tikzpictures

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

Problem joining two tikzpictures

by Ignasi Furió-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

        I've drawn two figures network1 and network2. they are drawn as expected.  
Now I want to join them into the same figure and label each one. So I've  
included each one in a node, labelled the node and aligned. You can see  
how in the example below.
Now the result is wrong, node A in second figure is not aligned with nodes  
CB, CC and CD, and node C in network2 is also missplaced. Could you  
explain me what's wrong? I'm using CVS version of pgf.

        Thank you,

        Ignasi

%---------------------------
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\usetikzlibrary{arrows,positioning}
\begin{document}

\begin{tikzpicture}

\node[label=below:Network 1] (network1) {
\begin{tikzpicture}[font=\small,>=stealth']
\node[rectangle,draw] (A) at (0,0) {Host};
\node[rectangle,draw] (B) at (6,0) {Host};
\draw[-] (A) -- node[above] {Link} (B);
\end{tikzpicture}
};

\node[label=below:Network 2] (network2) [below=of network1] {
\begin{tikzpicture}[font=\small,>=stealth']
\node[rectangle,draw] (A) at (0,0) {Host};
\node[rectangle,draw] (B) at (4,.75) {Host};
\node[rectangle,draw] (C) at (5,-.75) {Host};
\node[rectangle,draw] (D) at (6,.75) {Host};
\node[rectangle,draw] (CB) at (4,0) {};
\node[rectangle,draw] (CC) at (5,0) {};
\node[rectangle,draw] (CD) at (6,0) {};

\draw[-] (A) -- node[above] {Link} (CB) -- (CC) -- (CD);
\draw[-] (CB) -- (B);
\draw[-] (CC) -- (C);
\draw[-] (CD) -- (D);
\end{tikzpicture}
};

\end{tikzpicture}

\end{document}
--
----------------------------------------------------------------------
Ignasi Furió Caldentey
Universitat de les Illes Balears
Escola Politècnica Superior
Dep. Matematiques i Informatica
Cra. Valldemossa, km. 7,5. 07071-Palma. SPAIN
tel: (34) 971.173.196    fax: (34) 971.173.003
e-mail: ignasi dot furio at uib dot cat
http://www.uib.cat
----------------------------------------------------------------------


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: Problem joining two tikzpictures

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

The `below=of...' key fools around with the anchors of nodes. This is
inherited by all the nodes inside the tikzpicture inside the node. You
can `reset' the anchors by adding `anchor=center' to the tikzpicture
options.

Regards

Mark

2009/6/1 Ignasi Furió <ignasi.furio@...>:

> Hi all,
>
>        I've drawn two figures network1 and network2. they are drawn as expected.
> Now I want to join them into the same figure and label each one. So I've
> included each one in a node, labelled the node and aligned. You can see
> how in the example below.
> Now the result is wrong, node A in second figure is not aligned with nodes
> CB, CC and CD, and node C in network2 is also missplaced. Could you
> explain me what's wrong? I'm using CVS version of pgf.
>
>        Thank you,
>
>        Ignasi
>
> %---------------------------
> \documentclass{article}
> \usepackage[latin1]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage{lmodern}
> \usepackage{tikz}
> \usepackage[active,tightpage]{preview}
> \PreviewEnvironment{tikzpicture}
> \setlength\PreviewBorder{5pt}%
>
> \usetikzlibrary{arrows,positioning}
> \begin{document}
>
> \begin{tikzpicture}
>
> \node[label=below:Network 1] (network1) {
> \begin{tikzpicture}[font=\small,>=stealth']
> \node[rectangle,draw] (A) at (0,0) {Host};
> \node[rectangle,draw] (B) at (6,0) {Host};
> \draw[-] (A) -- node[above] {Link} (B);
> \end{tikzpicture}
> };
>
> \node[label=below:Network 2] (network2) [below=of network1] {
> \begin{tikzpicture}[font=\small,>=stealth']
> \node[rectangle,draw] (A) at (0,0) {Host};
> \node[rectangle,draw] (B) at (4,.75) {Host};
> \node[rectangle,draw] (C) at (5,-.75) {Host};
> \node[rectangle,draw] (D) at (6,.75) {Host};
> \node[rectangle,draw] (CB) at (4,0) {};
> \node[rectangle,draw] (CC) at (5,0) {};
> \node[rectangle,draw] (CD) at (6,0) {};
>
> \draw[-] (A) -- node[above] {Link} (CB) -- (CC) -- (CD);
> \draw[-] (CB) -- (B);
> \draw[-] (CC) -- (C);
> \draw[-] (CD) -- (D);
> \end{tikzpicture}
> };
>
> \end{tikzpicture}
>
> \end{document}
> --
> ----------------------------------------------------------------------
> Ignasi Furió Caldentey
> Universitat de les Illes Balears
> Escola Politècnica Superior
> Dep. Matematiques i Informatica
> Cra. Valldemossa, km. 7,5. 07071-Palma. SPAIN
> tel: (34) 971.173.196    fax: (34) 971.173.003
> e-mail: ignasi dot furio at uib dot cat
> http://www.uib.cat
> ----------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: Problem joining two tikzpictures

by Ignasi Furió-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It works!

Thank you, Mark

Ignasi

El Mon, 01 Jun 2009 10:55:50 +0200, Mark Wibrow <m.wibrow@...>  
vau escriure:

> Hi,
>
> The `below=of...' key fools around with the anchors of nodes. This is
> inherited by all the nodes inside the tikzpicture inside the node. You
> can `reset' the anchors by adding `anchor=center' to the tikzpicture
> options.
>
> Regards
>
> Mark
>
> 2009/6/1 Ignasi Furió <ignasi.furio@...>:
>> Hi all,
>>
>>        I've drawn two figures network1 and network2. they are drawn as  
>> expected.
>> Now I want to join them into the same figure and label each one. So I've
>> included each one in a node, labelled the node and aligned. You can see
>> how in the example below.
>> Now the result is wrong, node A in second figure is not aligned with  
>> nodes
>> CB, CC and CD, and node C in network2 is also missplaced. Could you
>> explain me what's wrong? I'm using CVS version of pgf.
>>
>>        Thank you,
>>
>>        Ignasi
>>
>> %---------------------------
>> \documentclass{article}
>> \usepackage[latin1]{inputenc}
>> \usepackage[T1]{fontenc}
>> \usepackage{lmodern}
>> \usepackage{tikz}
>> \usepackage[active,tightpage]{preview}
>> \PreviewEnvironment{tikzpicture}
>> \setlength\PreviewBorder{5pt}%
>>
>> \usetikzlibrary{arrows,positioning}
>> \begin{document}
>>
>> \begin{tikzpicture}
>>
>> \node[label=below:Network 1] (network1) {
>> \begin{tikzpicture}[font=\small,>=stealth']
>> \node[rectangle,draw] (A) at (0,0) {Host};
>> \node[rectangle,draw] (B) at (6,0) {Host};
>> \draw[-] (A) -- node[above] {Link} (B);
>> \end{tikzpicture}
>> };
>>
>> \node[label=below:Network 2] (network2) [below=of network1] {
>> \begin{tikzpicture}[font=\small,>=stealth']
>> \node[rectangle,draw] (A) at (0,0) {Host};
>> \node[rectangle,draw] (B) at (4,.75) {Host};
>> \node[rectangle,draw] (C) at (5,-.75) {Host};
>> \node[rectangle,draw] (D) at (6,.75) {Host};
>> \node[rectangle,draw] (CB) at (4,0) {};
>> \node[rectangle,draw] (CC) at (5,0) {};
>> \node[rectangle,draw] (CD) at (6,0) {};
>>
>> \draw[-] (A) -- node[above] {Link} (CB) -- (CC) -- (CD);
>> \draw[-] (CB) -- (B);
>> \draw[-] (CC) -- (C);
>> \draw[-] (CD) -- (D);
>> \end{tikzpicture}
>> };
>>
>> \end{tikzpicture}
>>
>> \end{document}
>> --
>> ----------------------------------------------------------------------
>> Ignasi Furió Caldentey
>> Universitat de les Illes Balears
>> Escola Politècnica Superior
>> Dep. Matematiques i Informatica
>> Cra. Valldemossa, km. 7,5. 07071-Palma. SPAIN
>> tel: (34) 971.173.196    fax: (34) 971.173.003
>> e-mail: ignasi dot furio at uib dot cat
>> http://www.uib.cat
>> ----------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
>> is a gathering of tech-side developers & brand creativity  
>> professionals. Meet
>> the minds behind Google Creative Lab, Visual Complexity, Processing, &
>> iPhoneDevCamp as they present alongside digital heavyweights like  
>> Barbarian
>> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
>> _______________________________________________
>> pgf-users mailing list
>> pgf-users@...
>> https://lists.sourceforge.net/lists/listinfo/pgf-users
>>



--
----------------------------------------------------------------------
Ignasi Furió Caldentey
Universitat de les Illes Balears
Escola Politècnica Superior
Dep. Matematiques i Informatica
Cra. Valldemossa, km. 7,5. 07071-Palma. SPAIN
tel: (34) 971.173.196    fax: (34) 971.173.003
e-mail: ignasi dot furio at uib dot cat
http://www.uib.cat
----------------------------------------------------------------------


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users