ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Aligning hboxes on top instead of on baseline
@ 2000-11-14  9:32 Berend de Boer
  2000-11-14 11:34 ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Berend de Boer @ 2000-11-14  9:32 UTC (permalink / raw)


Hello All,

I want to `align' text on the top of their boxes instead of using the
baselineskip or whatever is causing the problem.

I've defined a chapter that puts its number in the right margin.
However, the number is much larger than the chapter title. TeX aligns
these on the bottom of the text, so the number `pushes' the chapter
title down. But I want them aligned at the top, so the number should
stick out to the bottom.

Is this possible to do independent of the body font and the selected
number font size?  I've done things like this by manual shifting things
down until it looked good, but perhaps their is a more elegant solution.

Demo:

-------------------------------
% interface=en

\setupbodyfont
  [ber,pos,ss]

% put chapter title above paragraph, number in right margin
\def\myhead#1#2%
  {\doifsomething{#1}%
     {\rlap{\hskip\tekstbreedte\hskip\rechtermargeafstand#1}}%
   #2}

\setuphead
  [chapter]
  [style=\bfc,
   numberstyle={\switchtobodyfont[36pt]},
   command=\myhead]

\starttext

\chapter{Test}

\input tufte.tex

\stoptext
--------------------------------------

Groetjes,

Berend. (-:


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

* Re: Aligning hboxes on top instead of on baseline
  2000-11-14  9:32 Aligning hboxes on top instead of on baseline Berend de Boer
@ 2000-11-14 11:34 ` Hans Hagen
  2000-11-14 13:01   ` Berend de Boer
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2000-11-14 11:34 UTC (permalink / raw)
  Cc: ntg-context

At 10:32 AM 11/14/00 +0100, Berend de Boer wrote:
>Hello All,
>
>I want to `align' text on the top of their boxes instead of using the
>baselineskip or whatever is causing the problem.
>
>I've defined a chapter that puts its number in the right margin.
>However, the number is much larger than the chapter title. TeX aligns
>these on the bottom of the text, so the number `pushes' the chapter
>title down. But I want them aligned at the top, so the number should
>stick out to the bottom.
>
>Is this possible to do independent of the body font and the selected
>number font size?  I've done things like this by manual shifting things
>down until it looked good, but perhaps their is a more elegant solution.
>
>
>Demo:
>
>-------------------------------
>% interface=en
>
>\setupbodyfont
>  [ber,pos,ss]
>
>% put chapter title above paragraph, number in right margin
>\def\myhead#1#2%
>  {\doifsomething{#1}%
>     {\rlap{\hskip\tekstbreedte\hskip\rechtermargeafstand#1}}%
>   #2}

\inrightmargin takes care of a 'unbiased' placement in the right margin,
which saves you some hard coded values,  

\def\myhead#1#2%
  {\setbox0=\ruledhbox{#1}%
   \setbox2=\ruledhbox{#2}%
   \setbox0=\hbox{\lower\ht0\hbox{\raise\ht2\box0}}%
   \ht0=\ht2 \dp0=0pt
   \hbox{\box2\inrightmargin{\box0}}}

The lower and raise commands make sure that the number hangs, and the ht/dp
assignment obscures the number, 
of course you need to remove the 'ruled' after you see what happens. 

Hans
-------------------------------------------------------------------------
                                                  Hans Hagen | PRAGMA ADE
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

* Re: Aligning hboxes on top instead of on baseline
  2000-11-14 11:34 ` Hans Hagen
@ 2000-11-14 13:01   ` Berend de Boer
  2000-11-14 13:55     ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Berend de Boer @ 2000-11-14 13:01 UTC (permalink / raw)
  Cc: ntg-context

Hans Hagen wrote:

> \inrightmargin takes care of a 'unbiased' placement in the right margin,
> which saves you some hard coded values,

That's a new one (I tried \inright, \inmargin, \inword, etc. already :-)
)

Thanks, it worked great.

Groetjes,

Berend. (-:


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

* Re: Aligning hboxes on top instead of on baseline
  2000-11-14 13:01   ` Berend de Boer
@ 2000-11-14 13:55     ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2000-11-14 13:55 UTC (permalink / raw)
  Cc: ntg-context

At 02:01 PM 11/14/00 +0100, you wrote:
>Hans Hagen wrote:
>
>> \inrightmargin takes care of a 'unbiased' placement in the right margin,
>> which saves you some hard coded values,
>
>That's a new one (I tried \inright, \inmargin, \inword, etc. already :-)
>)

Actually an old one, used low level, but not (yet) advertised, 

\inleftmargin 
\inrightmargin
\inleftedge
\inrightedge

are rather stupid but sometimes handy 'lap'ing commands. Since they will
not disappear, it's safe to use them,

Hans
-------------------------------------------------------------------------
                                                  Hans Hagen | PRAGMA ADE
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

end of thread, other threads:[~2000-11-14 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-14  9:32 Aligning hboxes on top instead of on baseline Berend de Boer
2000-11-14 11:34 ` Hans Hagen
2000-11-14 13:01   ` Berend de Boer
2000-11-14 13:55     ` 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).