ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Vit Zyka <vit.zyka@seznam.cz>
Subject: Re: baseline alignment
Date: Thu, 09 Sep 2004 16:36:55 +0200	[thread overview]
Message-ID: <41406A87.5020502@seznam.cz> (raw)
In-Reply-To: <4117FD0A.6020509@wxs.nl>

Hi All,

first of all I want to apologize not being responding to several your 
emails (e.g. this one). My email provider has filtered tens of them as 
spam... I sighted them just now when I became suspicious of the email 
delivery.

Hans Hagen wrote:

> Vit Zyka wrote:
> 
>> Hallo,
>>
>> for text positioning in a layer I needed alignment to baseline. I do 
>> not known if I missed something but I did not find it in the current 
>> ConTeXt. So I did that. Baseline is choosen by capital 'B' in the 
>> position parameter. ('B' is adopted from grahicx LaTeX/plain package.)
>>
>> Also I add \ctop, \ltop, and \rtop in sence of \cbox, \lbox, and rbox, 
>> respectively.
>>
>> I suggest to add the macros to core-box and supp-box.
>>
>> Vit Zyka
>>
>> %-------------------------------------------- baseline alignment
>> \setvalue{\??ab\??ab  B}{\baselinebox}
>> \setvalue{\??ab\??ab  Bl}{\baselineleftbox}
>> \setvalue{\??ab\??ab  Bc}{\baselinecenterbox}
>> \setvalue{\??ab\??ab  Br}{\baselinerightbox}
>> \setvalue{\??ab\??ab  lB}{\leftbaselinebox}
>> \setvalue{\??ab\??ab  cB}{\centerbaselinebox}
>> \setvalue{\??ab\??ab  rB}{\rightbaselinebox}
>> \def\baselinecenterbox#1%
>>   {\normalhbox
>>      {\setbox0\placedbox{#1}%
>>       \global\boxhdisplacement-.5\wd0
>>       \global\advance\boxhdisplacement-\boxoffset
>>       \global\boxvdisplacement-\boxoffset
>>       \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
>> \def\baselineleftbox#1%
>>   {\normalhbox
>>      {\setbox0\placedbox{#1}%
>>       \global\boxhdisplacement-\wd0
>>       \global\advance\boxhdisplacement-\boxoffset
>>       \global\boxvdisplacement-\boxoffset
>>       \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
>> \def\baselinerightbox#1%
>>   {\normalhbox
>>      {\setbox0\placedbox{#1}%
>>       \global\boxhdisplacement\boxoffset
>>       \global\boxvdisplacement-\boxoffset
>>       \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
>> \let\baselinebox=\baselinecenterbox
>> \let\leftbaselinebox=\baselineleftbox
>> \let\rightbaselinebox=\baselinerightbox
> 
> 
> hm, in that case we probably need a few more -)
> 
> See example below, there is already a grid option; also, keep an eye on 
> topskip (we may need s sl sc sr but who can remember that)

Like this? If so, I can prepare the rest alternatives and to test them.

\setvalue{\??ab\??ab  s}{\topskipcenterbox}
\def\topskipcenterbox#1%
   {\normalhbox
     {\setbox0\placedbox{#1}%
      \global\boxhdisplacement-.5\wd0
      \global\advance\boxhdisplacement-\boxoffset
      \global\boxvdisplacement-\boxoffset
      \global\advance\boxvdisplacement by\topskip
      \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}

> I dislike the capital B but the g  is available (g from gridline)

OK. But is not better to use also \gridrightbox instead of 
\baselinerightbox, etc. ?

 > i can add that to the kernel if tested

I tested your code and it is all right.

> \unprotect
> 
> % \v!grid is taken
> 
> \setvalue{\??ab\??ab  m}{\middlebox}
> 
> \setvalue{\??ab\??ab  g}{\baselinemiddlebox}
> \setvalue{\??ab\??ab gl}{\baselineleftbox}
> \setvalue{\??ab\??ab gc}{\baselinemiddlebox}
> \setvalue{\??ab\??ab gr}{\baselinerightbox}
> 
> \setvalue{\??ab\??ab \v!regel         }{\baselinemiddlebox} % \v!grid is 
> taken
> \setvalue{\??ab\??ab \v!regel\v!links }{\baselineleftbox}
> \setvalue{\??ab\??ab \v!regel\v!midden}{\baselinemiddlebox}
> \setvalue{\??ab\??ab \v!regel\v!rechts}{\baselinerightbox}
> 
> \def\baselinemiddlebox#1%
>  {\normalhbox
>     {\setbox0\placedbox{#1}%
>      \global\boxhdisplacement-.5\wd0
>      \global\advance\boxhdisplacement-\boxoffset
>      \global\boxvdisplacement-\boxoffset
>      \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
> 
> \def\baselineleftbox#1%
>  {\normalhbox
>     {\setbox0\placedbox{#1}%
>      \global\boxhdisplacement-\wd0
>      \global\advance\boxhdisplacement-\boxoffset
>      \global\boxvdisplacement-\boxoffset
>      \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
> 
> \def\baselinerightbox#1%
>  {\normalhbox
>     {\setbox0\placedbox{#1}%
>      \global\boxhdisplacement\boxoffset
>      \global\boxvdisplacement-\boxoffset
>      \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}}
> 
> \protect
> 
> \definelayer[text] \setupbackgrounds[text][background=text]
> \setuplayer[text][width=\textwidth,height=\textheight]
> 
> \showgrid
> 
> \starttext
> 
> \setlayer
>  [text]
>  [location=grid,line=13]
>  {\vtop{\strut \input ward \endstrut}}
> 
> \setlayer
>  [text]
>  [corner={right,top},
>   voffset=\topskip, % \topskipgap,
>   location=gl]
>  {\vtop{\begstrut \input ward \endstrut}}
> 
> x
> 
> \stoptext
> 
> i can add that to the kernel if tested


>> %------------------------------ \ltop, \rtop, \ctop
>> \def\lrctop#1#2#%
>>   {\vtop#2\bgroup
>>    \let\\=\endgraf
>>    \forgetall#1\let\next=}
>> \def\ltop{\lrctop\raggedleft}
>> \def\rtop{\lrctop\raggedright}
>> \def\ctop{\lrctop\raggedcenter}


> ok, i've patched/added:
> 
> \def\lbox{\makelrcbox\normalvbox\raggedleft}
> \def\cbox{\makelrcbox\normalvbox\raggedcenter}
> \def\rbox{\makelrcbox\normalvbox\raggedright}
> 
> \def\ltop{\makelrcbox\normalvtop\raggedleft}
> \def\ctop{\makelrcbox\normalvtop\raggedcenter}
> \def\rtop{\makelrcbox\normalvtop\raggedright}
> 
> \def\makelrcbox#1#2#3#%
>  {#1#3\bgroup \forgetall \let\\=\endgraf #2\let\next=}

Great, thank you, Hans.

Vit Zyka

      reply	other threads:[~2004-09-09 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-22  8:59 Vit Zyka
2004-08-09 22:39 ` Hans Hagen
2004-09-09 14:36   ` Vit Zyka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41406A87.5020502@seznam.cz \
    --to=vit.zyka@seznam.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).