Problem with line spacing of text in rectangles

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

Problem with line spacing of text in rectangles

by bertolt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

Best regards,
Bertolt

--
Dr. Bertolt Meyer
Senior research and teaching associate
Social Psychology, Institute of Psychology, University of Zurich
Binzmuehlestrasse 14, Box 15
CH-8050 Zurich
Switzerland

bmeyer@...
tel:   +41446357282
fax:   +41446357279




------------------------------------------------------------------------------
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: Problem with line spacing of text in rectangles

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>:

> 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.
>
> Best regards,
> Bertolt
>
> --
> Dr. Bertolt Meyer
> Senior research and teaching associate
> Social Psychology, Institute of Psychology, University of Zurich
> Binzmuehlestrasse 14, Box 15
> CH-8050 Zurich
> Switzerland
>
> bmeyer@...
> tel:   +41446357282
> fax:   +41446357279
>
>
>
>
> ------------------------------------------------------------------------------
> 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
>

------------------------------------------------------------------------------
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: Problem with line spacing of text in rectangles

by bertolt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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}
> (3.5,0.5);
> \end{tikzpicture}
>
> Regards
>
> Mark
>
> 2009/9/1 Bertolt Meyer <bmeyer@...>:
>> 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.
>>
>> Best regards,
>> Bertolt
>>
>> --
>> Dr. Bertolt Meyer
>> Senior research and teaching associate
>> Social Psychology, Institute of Psychology, University of Zurich
>> Binzmuehlestrasse 14, Box 15
>> CH-8050 Zurich
>> Switzerland
>>
>> bmeyer@...
>> tel:   +41446357282
>> fax:   +41446357279
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>>


------------------------------------------------------------------------------
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: Problem with line spacing of text in rectangles

by bertolt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>:
>> 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.
>>
>> Best regards,
>> Bertolt
>>
>> --
>> Dr. Bertolt Meyer
>> Senior research and teaching associate
>> Social Psychology, Institute of Psychology, University of Zurich
>> Binzmuehlestrasse 14, Box 15
>> CH-8050 Zurich
>> Switzerland
>>
>> bmeyer@...
>> tel:   +41446357282
>> fax:   +41446357279
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>>


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