Bertolt Meyer | 1 Sep 2009 15:53
Picon
Favicon

Problem with line spacing of text in rectangles

Dear List,

I'm a pgf/tikz newbie and searching the list archive and the tikz/pgf  
manuel did not answer my following issue regarding the line spacing of  
text embedded into tikz pictures. I do however apologize in advance if  
I overlooked something obvious.

I want to put some single-line spaced text into a box. However, when I  
do this:

\begin{tikzpicture}[scale = 1.0, pos=.5]
\draw (0,0) rectangle node[text width = 3.5cm, text ragged]  
{\scriptsize Some sample text some sample text some sample text}  
(3.5,0.5);
\end{tikzpicture}

the text appears to be typeset double-spaced, i.e. with a full blank  
line between the two lines of text. Therefore, the text is out of the  
bounds of the box. It would however fit into the box if it wasn't  
typeset with double line spacing, as the following code illustrates:

\draw (0,0) rectangle node[above = -3pt, text ragged] {\scriptsize  
Some sample text some sam-} node[below = -3pt, text ragged]  
{\scriptsize ple text some sample text}(3.5,0.5);

However, this is a no-go as the text is centered and I have to do line  
breaks and hyphenation manually. Is there a simpler way to achieve  
what I want in the way of the first example?

Any help would be greatly appreciated.
(Continue reading)

Mark Wibrow | 1 Sep 2009 16:16

Re: Problem with line spacing of text in rectangles

Hi,

Not entirely sure of the overall effect you are after, but in general,
font size commands should be passed to nodes using the font key, as
this allows the text stuff (most of which TikZ defines itself) to be
set up correcty:

\begin{tikzpicture}[scale = 1.0, pos=.5]
\draw (0,0) rectangle node[text width = 3.5cm, text ragged, font=\scriptsize]
{Some sample text some sample text some sample text}
(3.5,0.5);
\end{tikzpicture}

Regards

Mark

2009/9/1 Bertolt Meyer <bmeyer <at> sozpsy.uzh.ch>:
> Dear List,
>
> I'm a pgf/tikz newbie and searching the list archive and the tikz/pgf
> manuel did not answer my following issue regarding the line spacing of
> text embedded into tikz pictures. I do however apologize in advance if
> I overlooked something obvious.
>
> I want to put some single-line spaced text into a box. However, when I
> do this:
>
> \begin{tikzpicture}[scale = 1.0, pos=.5]
> \draw (0,0) rectangle node[text width = 3.5cm, text ragged]
(Continue reading)

Bertolt Meyer | 1 Sep 2009 16:25
Picon
Favicon

Re: Problem with line spacing of text in rectangles

Mark,

Thanks, but that doesn't solve the problem: after the first line  
break, the text inside the box seems to get a second line break before  
it is continued, i.e.:

Some sample text some sam-

ple text some sample text

Maybe it is not a full empty line, but there is a considerable white  
space between the two lines of text, much larger than in regular LaTeX  
typeset. I want to get rid of that space.

Regards,
Bertolt

Am 01.09.2009 um 16:16 schrieb Mark Wibrow:

> Hi,
>
> Not entirely sure of the overall effect you are after, but in general,
> font size commands should be passed to nodes using the font key, as
> this allows the text stuff (most of which TikZ defines itself) to be
> set up correcty:
>
> \begin{tikzpicture}[scale = 1.0, pos=.5]
> \draw (0,0) rectangle node[text width = 3.5cm, text ragged, font= 
> \scriptsize]
> {Some sample text some sample text some sample text}
(Continue reading)

Bertolt Meyer | 1 Sep 2009 16:27
Picon
Favicon

Re: Problem with line spacing of text in rectangles

Whoops, actually, that did solve the problem! Pasted your code in the  
wrong example on my system... apologies.
So thank you and please do ignore the second post. How embarrassing.

Regards,
Bertolt

Am 01.09.2009 um 16:16 schrieb Mark Wibrow:

> Hi,
>
> Not entirely sure of the overall effect you are after, but in general,
> font size commands should be passed to nodes using the font key, as
> this allows the text stuff (most of which TikZ defines itself) to be
> set up correcty:
>
> \begin{tikzpicture}[scale = 1.0, pos=.5]
> \draw (0,0) rectangle node[text width = 3.5cm, text ragged, font= 
> \scriptsize]
> {Some sample text some sample text some sample text}
> (3.5,0.5);
> \end{tikzpicture}
>
> Regards
>
> Mark
>
> 2009/9/1 Bertolt Meyer <bmeyer <at> sozpsy.uzh.ch>:
>> Dear List,
>>
(Continue reading)

James Samir Ismail | 1 Sep 2009 23:43

tikz matrix placement

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 <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Alain Matthes | 2 Sep 2009 01:18
Picon
Gravatar

Re: tikz matrix placement


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
Flavio Costa | 3 Sep 2009 01:20
Picon
Favicon

tree growth function

Hi,

I'm drawing a tree with the code below:

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{trees}

\begin{document}

\begin{tikzpicture}[
    every node/.style={draw},
    single/.style={
        %grow=south,
        grow via three points={one child at (0,-1) and two children at (1,-1) and (1,-2)},
        edge from parent path=(\tikzparentnode) -- (\tikzchildnode)},
    level 2/.style={
        grow via three points={one child at (1,-1) and two children at (1,-1) and (1,-2)},
        edge from parent path=(\tikzparentnode) |- (\tikzchildnode)}]

\node {Root}[edge from parent fork down,sibling distance=30mm]
    child {node {Item 1}
        child {node {Item 1.1}}
        child {node {Item 1.2}}}
    child {node {Item 2}
        child[single] {node {Item 2.1}}}
    child {node {Item 3}
        child {node {Item 3.1}}
        child {node {Item 3.2}}
        child {node {Item 3.3}}}
    child {node {Item 4}
        child {node {Item 4.1}}
        child {node {Item 4.2}}
        child {node {Item 4.3}}
        child {node {Item 4.4}}}
        ;
\end{tikzpicture}

\end{document}

It produces the desired effect, but I feel that it could be made simpler. For the [single] style, if I replace
"grow via three points" by "grow=south" the child node gets misaligned vertically. Why does this happen?

Is it possible to get the same effect without having to create a separate [single] style? I tried playing
with "grow via three points" possibilites, but none worked as expected.

Thanks.

Flavio Costa

      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

------------------------------------------------------------------------------
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
Hans Meine | 3 Sep 2009 10:53
Picon

Re: multicolumn in matrix?

On Monday 24 August 2009 18:16:28 Jonathan Geisler wrote:
> Is there a way to accomplish something similar to \multicolumn for
> LaTeX's tabular environment within PGF's matrix command?  I'd like to
> create a node that fills two columns in the matrix, but if I give it
> an explicit size, then it increases the size of the column to fit the
> bigger size.

That would certainly be nice to have.

So far, I think you need either nested matrices/nodes, or you place the 
multicolumn node as "overlay" using the anchors provided by the matrix 
(possibly using the fit library).

HTH,
  Hans

------------------------------------------------------------------------------
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
JL Diaz | 3 Sep 2009 13:31
Picon

Re: tree growth function

On Thu, Sep 3, 2009 at 1:20 AM, Flavio Costa<flaviocosta <at> yahoo.com.br> wrote:
> Hi,
>
> I'm drawing a tree with the code below:
[ ... ]

> It produces the desired effect, but I feel that it could be made simpler. For the [single] style, if I
replace "grow via three points" by "grow=south" the child node gets misaligned vertically. Why does this happen?

Because the default distance among levels is not 1cm (as it is for the
other siblings, due to your (0,1) specification).

> Is it possible to get the same effect without having to create a separate [single] style? I tried playing
with "grow via three points" possibilites, but none worked as expected.

It is possible to simplify your single style, using grow=south instead
of grow via three points. you have to add [level distance=10mm] option
to your Root node. However, I cannot imagine any way for getting rid
of the [single] style.

Regards,
--JL Diaz

------------------------------------------------------------------------------
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
Flavio Costa | 3 Sep 2009 18:31
Picon
Favicon

Res: tree growth function

> It is possible to simplify your single style, using grow=south instead

> of grow via three points. you have to add [level distance=10mm] option
> to your Root node. However, I cannot imagine any way for getting rid
> of the [single] style.

Hi,

[grow=south,level distance=10mm] works perfectly, thanks for the explanation.

Flavio Costa

      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

------------------------------------------------------------------------------
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

Gmane