ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Blank figure hack: is there a better way?
@ 2004-08-10 17:47 Brooks Moses
  2004-08-10 18:44 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Brooks Moses @ 2004-08-10 17:47 UTC (permalink / raw)


I'm doing a document which has a large logo in the upper right corner of 
the page.  The logo (which is on a background layer) intrudes into the text 
area by a small amount, and so it would be nice to have the text wrap 
around it rather than having to do the wrapping by manual spacers and 
line-breaks.

The "obvious" solution that I came up with for this is to put a blank 
right-aligned float at the top of each page (it's a presentation where all 
the page breaks are hand-coded, so that's easy to do), of about the size of 
the part of the logo that intrudes into the text.  I defined a class of 
floats just for this:

   \definefloat[logospacer][logospacer]

(Using the same name for the singular and plural was a hack to get around 
the fact that the manual doesn't indicate which of the two the \setupfloat 
command uses.  Which is it?)

So far, so good.  Except that it's exceptionally hard to _get_ a blank 
float in ConTeXt, particularly one of a specified size.

If I do this (and specify the size in a \setupfloat command):

   \placelogospacer[right, force]{none}{}

I get a nice float exactly the size I want, but with a frame around it and 
the word "undefined" in the middle.

If I put something in the float -- say, a letter, or a non-breaking space:

   \placelogospacer[right, force]{none}{~}

The float suddenly becomes \textwidth wide, which is of course all wrong, 
but at least I have a blank float that's not undefined.

If I put an \hbox in the float, with a fixed width, it stops stretching to 
fill the pagewidth, but unless I put something that actually makes a mark 
on the page, it still comes up with "undefined".  (The "~" that worked 
earlier doesn't work if it's in an \hbox.)  I tried a number of tricks -- 
hiding the nothing in a macro, using a zero-height rule, and so forth -- 
and ConTeXt was sufficiently clever to see through them all.

There's also the annoyance that I have to specify the size of the float by 
the size of the \hbox, rather than in a convenient [width=...,height=...] 
fashion.

Eventually, what I came up with was putting the mark somewhere off the 
page, with the following command:

   \placelogospacer[right, force]{none}{\hbox to 1cm{\hskip 5cm x}}

This of course gives "overfull \hbox" errors, and is a really ugly hack, 
but the results are acceptable -- a float of size 1cm by 1 x-height, which 
doesn't put marks on the physical page.

How can I do this better?  Better yet, how can I do this properly?

Thanks,
- Brooks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Blank figure hack: is there a better way?
  2004-08-10 17:47 Blank figure hack: is there a better way? Brooks Moses
@ 2004-08-10 18:44 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2004-08-10 18:44 UTC (permalink / raw)


Brooks Moses wrote:

> I'm doing a document which has a large logo in the upper right corner 
> of the page.  The logo (which is on a background layer) intrudes into 
> the text area by a small amount, and so it would be nice to have the 
> text wrap around it rather than having to do the wrapping by manual 
> spacers and line-breaks.
>
> The "obvious" solution that I came up with for this is to put a blank 
> right-aligned float at the top of each page (it's a presentation where 
> all the page breaks are hand-coded, so that's easy to do), of about 
> the size of the part of the logo that intrudes into the text.  I 
> defined a class of floats just for this:
>
>   \definefloat[logospacer][logospacer]
>
> (Using the same name for the singular and plural was a hack to get 
> around the fact that the manual doesn't indicate which of the two the 
> \setupfloat command uses.  Which is it?)
>
> So far, so good.  Except that it's exceptionally hard to _get_ a blank 
> float in ConTeXt, particularly one of a specified size.
>
> If I do this (and specify the size in a \setupfloat command):
>
>   \placelogospacer[right, force]{none}{}
>
> I get a nice float exactly the size I want, but with a frame around it 
> and the word "undefined" in the middle.
>
> If I put something in the float -- say, a letter, or a non-breaking 
> space:
>
>   \placelogospacer[right, force]{none}{~}
>
> The float suddenly becomes \textwidth wide, which is of course all 
> wrong, but at least I have a blank float that's not undefined.
>
> If I put an \hbox in the float, with a fixed width, it stops 
> stretching to fill the pagewidth, but unless I put something that 
> actually makes a mark on the page, it still comes up with 
> "undefined".  (The "~" that worked earlier doesn't work if it's in an 
> \hbox.)  I tried a number of tricks -- hiding the nothing in a macro, 
> using a zero-height rule, and so forth -- and ConTeXt was sufficiently 
> clever to see through them all.
>
> There's also the annoyance that I have to specify the size of the 
> float by the size of the \hbox, rather than in a convenient 
> [width=...,height=...] fashion.
>
> Eventually, what I came up with was putting the mark somewhere off the 
> page, with the following command:
>
>   \placelogospacer[right, force]{none}{\hbox to 1cm{\hskip 5cm x}}
>
> This of course gives "overfull \hbox" errors, and is a really ugly 
> hack, but the results are acceptable -- a float of size 1cm by 1 
> x-height, which doesn't put marks on the physical page.
>
> How can I do this better?  Better yet, how can I do this properly?

the placeholder can be set up quite easily: 

\starttext

\definefloat[logospacer][logospacer]
\setupfloat[logospacer][default={right,none},width=1mm,height=1mm,empty=yes]

\placelogospacer{}{}

\input ward

\stoptext

As you can see, we also can set the default placement. The 'empty=yes' is not documented (since it is not that old -) 

An alternative would have been 

\startsetups placeholder

  \placefigure[right,none]{}{\framed[width=1mm,height=1mm,frame=off]{}}

\stopsteups

..... \setups[placeholder] ....  

framed boxes without frames are quite handy 

Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-10 18:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-10 17:47 Blank figure hack: is there a better way? Brooks Moses
2004-08-10 18:44 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).