Discussion:
create white box (multiple lines) which adapts to the text width?
elwood151
2011-10-26 10:16:09 UTC
Permalink
I want to place text information on top of a photograph.
For better visibility of the text I'd like to create a white rectangle with
the black text above.
Linebreaks in the text shall be possible and the rectangle should
automatically adapt to the size of the text.

How can I achieve that?

If I use a minipage element in IPE, I have to define its width manually.
In a normal "label" I can not use a \newline command.
and how could I create the white rectangle in the box?

I think this is easy with LaTeX but I do not see how to do it at the moment.

Kind regards

Martin
--
View this message in context: http://old.nabble.com/create-white-box-%28multiple-lines%29-which-adapts-to-the-text-width--tp32722871p32722871.html
Sent from the Ipe - General mailing list archive at Nabble.com.
Tim Hutt
2011-10-26 10:42:40 UTC
Permalink
You can't make objects track other objects. I think the best you can do is
use the paragraph tool, and then draw the background box manually.

Or write an ipelet...
Post by elwood151
I want to place text information on top of a photograph.
For better visibility of the text I'd like to create a white rectangle with
the black text above.
Linebreaks in the text shall be possible and the rectangle should
automatically adapt to the size of the text.
How can I achieve that?
If I use a minipage element in IPE, I have to define its width manually.
In a normal "label" I can not use a \newline command.
and how could I create the white rectangle in the box?
I think this is easy with LaTeX but I do not see how to do it at the moment.
Kind regards
Martin
--
http://old.nabble.com/create-white-box-%28multiple-lines%29-which-adapts-to-the-text-width--tp32722871p32722871.html
Sent from the Ipe - General mailing list archive at Nabble.com.
_______________________________________________
Ipe-discuss mailing list
http://lists.science.uu.nl/mailman/listinfo/ipe-discuss
M
2011-10-26 11:16:30 UTC
Permalink
@Tim:
thanks for your answer.
When I place
\colorbox{white}{text \par test}
in a label, it is already pretty close to what I need - I just do not manage
to get the linebreak.
Datum: Wed, 26 Oct 2011 11:42:40 +0100
Betreff: Re: [Ipe-discuss] create white box (multiple lines) which adapts to
the text width?
You can't make objects track other objects. I think the best you can do is
use the paragraph tool, and then draw the background box manually.
Or write an ipelet...
Post by elwood151
I want to place text information on top of a photograph.
For better visibility of the text I'd like to create a white rectangle with
the black text above.
Linebreaks in the text shall be possible and the rectangle should
automatically adapt to the size of the text.
How can I achieve that?
If I use a minipage element in IPE, I have to define its width manually.
In a normal "label" I can not use a \newline command.
and how could I create the white rectangle in the box?
I think this is easy with LaTeX but I do not see how to do it at the moment.
Otfried Cheong
2011-10-26 11:22:10 UTC
Permalink
Post by M
When I place
\colorbox{white}{text \par test}
in a label, it is already pretty close to what I need - I just do not manage
to get the linebreak.
What about

\colorbox{white}{\begin{minipage}{\textwidth}
text \par \text
\end{minipage}}

Inside a paragraph object, \textwidth is automatically the width you
assigned to the paragraph object.

Otfried
M
2011-10-26 11:56:46 UTC
Permalink
Otfried, thank you very much.
That sounds great, but it does not work as expected - maybe there's a
misunderstanding?
What's a "paragraph" object?
Type = label or type = minipage?

If I use \textwidth as width in a label, I get a width of 345pt (must be
defined somewhere in my document, however, my "canvas" is larger in IPE).
But the box does not adjust to the width of the content.

And if I use a type: minipage object, I have to define the width by hand
(that's what I want to avoid).

@Tim: same behavior for your example, \the\columnwidth gives 345.0 pt.
Is this an error I built in in a style sheet?!

Kind regards

Martin
Datum: Wed, 26 Oct 2011 20:22:10 +0900
Betreff: Re: [Ipe-discuss] create white box (multiple lines) which adapts to
the text width?
Post by M
When I place
\colorbox{white}{text \par test}
in a label, it is already pretty close to what I need - I just do not manage
to get the linebreak.
What about
\colorbox{white}{\begin{minipage}{\textwidth}
text \par \text
\end{minipage}}
Inside a paragraph object, \textwidth is automatically the width you
assigned to the paragraph object.
Otfried
_______________________________________________
Ipe-discuss mailing list
http://lists.science.uu.nl/mailman/listinfo/ipe-discuss
Tim Hutt
2011-10-26 12:18:59 UTC
Permalink
Post by M
And if I use a type: minipage object, I have to define the width by hand
(that's what I want to avoid).
Yeah... but how else would the paragraph width be defined? Or do you
want the paragraphs to never break and only occupy one line? I
couldn't quite get it to work, but start with something like this:

Preamble:


\newlength{\parawidth}

\newcommand{\whitepara}[1]{
\settowidth{\parawidth}{#1}
\colorbox{white}{\parbox{\parawidth}{#1}}
}

In a paragraph object (minipage type label):

\whitepara{My paragraph \\ another paragraph}

It doesn't really work because \settowidth doesn't split stuff up into
paragraphs. If your latex-foo is strong then you may be able to write
code to split #1 into an array of paragraphs, call \settowidth on each
and select the maximum. I have no idea how though.
Tim Hutt
2011-10-26 11:24:26 UTC
Permalink
Ah cool I didn't know about colorbox. I test this and it works if you
put it inside a paragraph object:

\colorbox{white}{\parbox{\columnwidth}{A paragraph.

Another paragraph.
}}

You can then edit the width in the usual way (right-click->Change Width).
Post by M
thanks for your answer.
When I place
\colorbox{white}{text \par test}
in a label, it is already pretty close to what I need - I just do not manage
to get the linebreak.
Datum: Wed, 26 Oct 2011 11:42:40 +0100
Betreff: Re: [Ipe-discuss] create white box (multiple lines) which adapts to
the text width?
You can't make objects track other objects. I think the best you can do is
use the paragraph tool, and then draw the background box manually.
Or write an ipelet...
Post by elwood151
I want to place text information on top of a photograph.
For better visibility of the text I'd like to create a white rectangle with
the black text above.
Linebreaks in the text shall be possible and the rectangle should
automatically adapt to the size of the text.
How can I achieve that?
If I use a minipage element in IPE, I have to define its width manually.
In a normal "label" I can not use a \newline command.
and how could I create the white rectangle in the box?
I think this is easy with LaTeX but I do not see how to do it at the moment.
M
2011-10-26 19:00:46 UTC
Permalink
@Otfried:
thank you, yes that's exactly what I want:
Linebreaks are set manually and the width is adapted to the longest line.

(It's about labels which contain only 1..3 words to explain the different
parts of a photograph.
As the width of them shall not be "too long", I want to set linebreaks
manually.
And the white box in the background shall make them better readable.)

Any idea how to do that with LaTeX?

Kind regards

Martin
Datum: Wed, 26 Oct 2011 21:19:44 +0900
Betreff: Re: [Ipe-discuss] create white box (multiple lines) which adapts to
the text width?
But Latex requires a text width to be able to do linebreaking. I'm not
sure what you really want to do - you want to indicate all linebreaks
manually, and the box should adjust to the longest line?
Otfried Cheong
2011-10-27 00:08:03 UTC
Permalink
Post by M
Linebreaks are set manually and the width is adapted to the longest line.
(It's about labels which contain only 1..3 words to explain the different
parts of a photograph.
As the width of them shall not be "too long", I want to set linebreaks
manually.
And the white box in the background shall make them better readable.)
Any idea how to do that with LaTeX?
The obvious solution I can think of - make a label object and put:

\colorbox{white{\begin{tabular}{l}line 1\\line 2\\line 3 is
longer\end{tabular}}

You may have to tinker with the spacing.

Cheers,
Otfried
M
2011-10-27 08:21:53 UTC
Permalink
Dear Otfried,
Post by Otfried Cheong
\colorbox{white{\begin{tabular}{l}line 1\\line 2\\line 3 is
longer\end{tabular}}
thank you very much!
Seems, I'm not LaTeX geek enough to recognize a table as the obvious
solution for a multi-line environment, but you're absolutely right! ;-)
Thank you!

In the meantime I found solutions involving other packages like varwidth
which can create a minipage-like environment, that adapts its width to the
longest line:

see http://www.tex.ac.uk/cgi-bin/texfaq2html?label=varwidth

Thank you very much for your quick help!

Kind regards

Martin
Post by Otfried Cheong
Organisation: Ipe Headquarters
Datum: Thu, 27 Oct 2011 09:08:03 +0900
Betreff: Re: [Ipe-discuss] create white box (multiple lines) which adapts to
the text width?
Post by M
Linebreaks are set manually and the width is adapted to the longest line.
(It's about labels which contain only 1..3 words to explain the different
parts of a photograph.
As the width of them shall not be "too long", I want to set linebreaks
manually.
And the white box in the background shall make them better readable.)
Any idea how to do that with LaTeX?
\colorbox{white{\begin{tabular}{l}line 1\\line 2\\line 3 is
longer\end{tabular}}
You may have to tinker with the spacing.
Cheers,
Otfried
_______________________________________________
Ipe-discuss mailing list
http://lists.science.uu.nl/mailman/listinfo/ipe-discuss
Continue reading on narkive:
Loading...