[NTG-context] typing midaligned

Peter Münster pmlists at free.fr
Tue May 9 18:07:59 CEST 2006


On Tue, 9 May 2006, Hans Hagen wrote:

> ? wrote:
> >
> > I don't understand, it's still not centred...
> > Or do you mean, I have to put the typing into a box,
> > measure the width of the box, and then calculate the
> > right margin ((\textwidth - \typingwidth) / 2) ?
> >   
> indeed this is teh only way since in typing each line is a par 

Ok, this seems to work:

\def\startTypeMidaligned{%
  \dostartbuffer[typemidaligned][startTypeMidaligned][stopTypeMidaligned]}
\def\stopTypeMidaligned{\setuptyping[margin=0pt]%
  \setbox\scratchbox\hbox{%
    \framed[frame=off,offset=overlay,align=lohi]{\typebuffer[typemidaligned]}}%
  \setuptyping[margin=\dimexpr (\textwidth - \wd\scratchbox) / 2 \relax]%
  \typebuffer[typemidaligned]}
\starttext
\input tufte
\startTypeMidaligned
bla bla bla
bla bla bla bla bla bla bla bla bla bla bla
\stopTypeMidaligned
\input tufte
\startTypeMidaligned
bla bla bla
blub
\stopTypeMidaligned
\input tufte
\stoptext

Can be wikified ;)
Cheers, Peter

-- 
http://pmrb.free.fr/contact/


More information about the ntg-context mailing list