[NTG-context] \page inside a block

Hans Hagen pragma at wxs.nl
Thu Mar 16 11:38:46 CET 2006


frantisek holop wrote:
> hi there,
>
> the following is a minimal example of the layout i am working on.
>
>
> -----------------------%<-------------------------
> % output=pdftex
>
> \enableregime[latin2]
>
> \setuppapersize
>   [A5][A5]
>
> \defineparagraphs
>   [poem][n=2]
> \setupparagraphs
>   [poem][1][width=.35\textwidth]
> \setupparagraphs
>   [poem][2][rule=on]
>
> \starttext
>
> \startpoem
> \section{poem}
> \poem\startlines
> line 1
> line 2
> \page
> line 3
> line 4
> \stoplines\stoppoem
> \stoptext
> -----------------------%<-------------------------
>
>
> when the poem gets long, i need to start a new page obviously.
> but page is not working.  what am i missing here?
>   
that it's unbreakable stuff (vbox)
> also, using \page is one thing, good for me, so i could tell,
> flush the page right here, but i thought i'll get an automatic
> pagebreak when the text gets to the bottom....
>
> sorry if this is a very silly question, just getting my feet wet
> with context....  thanks
>   
actually, this is a rather complex situation; one could use a tabulate

the complication is in the line and in the fact that you want to use a 
section command

\setuppapersize[A5][A5]

\starttext

\setupcolors[state=start]

\definetextbackground
  [poem]
  [state=start,
   location=paragraph,
   background=color,
   backgroundcolor=red]

\definehead[Poem][section]
\setuphead[Poem][alternative=poemtitle,before={\blank[2*big]},after={\vskip-\lineheight},page=,style=\bfa]

% works, but may not be that robust)
%
% \defineheadplacement[poemtitle][horizontal]#1#2%
%   {\margintitle{\hskip\measure{SavedLeftSkip}#1\enspace#2}}

\defineheadplacement[poemtitle][vertical]#1#2%
  {\setupparagraphintro[first][{\llap{\hbox to 
\leftskip{#1\enspace#2\hss}}}]}

\setuplines[before=,after=]

\def\StartPoem#1%
  {\startnarrower[5*left]
   % \expanded{\definemeasure[SavedLeftSkip][\the\leftskip]}
   \Poem{#1}
   \starttextbackground[poem]
   \startlines}

\def\StopPoem
  {\stoplines
   \stoptextbackground
   \stopnarrower}

\showframe

\StartPoem{xxx}
line 1
line 2
\StopPoem

\setuptextbackground
  [poem]
  [mp=mpos:par:poem]

\startuseMPgraphic{mpos:par:poem}
  for i = 1 upto nofmultipars :
    draw leftboundary multipars[i]
        shifted (-.5EmWidth,0)
        dashed evenly
        withpen pencircle scaled 1pt
        withcolor .8red ;
  endfor ;
\stopuseMPgraphic

\StartPoem{zzz}
line 1
line 2
\StopPoem

\startuseMPgraphic{mpos:par:poem}
  for i = 1 upto nofmultipars :
    draw multipars[i]
        enlarged .5ExHeight
        rightenlarged -.5ExHeight
        dashed evenly
        withpen pencircle scaled 1pt
        withcolor .8red ;
  endfor ;
\stopuseMPgraphic

\StartPoem{qqq}
line 1
line 2
line 3
\dorecurse{100}{line 4:\recurselevel\par}
\StopPoem

\stoptext

I leave it up to you (or others) to wikify this example. It looks more 
complex than it is. By using a mp graphic you have more options

watch what happens if you add

\page

\startuseMPgraphic{mpos:par:poem}
  for i = 1 upto nofmultipars :
    multipars[i] := multipars[i]
        enlarged .5ExHeight
        rightenlarged -.5ExHeight;
    drawoptions (
        dashed evenly
        withpen pencircle scaled 1pt
        withcolor .8red
    ) ;
    if multilocs[i] = 1 :
        draw
            llcorner multipars[i] --
            ulcorner multipars[i] --
            urcorner multipars[i] --
            lrcorner multipars[i] ;
    elseif multilocs[i] = 3 :
        draw
            ulcorner multipars[i] --
            llcorner multipars[i] --
            lrcorner multipars[i] --
            urcorner multipars[i] ;
    else :
        draw leftboundary multipars[i] ;
        draw rightboundary multipars[i] ;
    fi ;
  endfor ;
\stopuseMPgraphic

\StartPoem{hhh}
\dorecurse{200}{line \recurselevel\par}
\StopPoem


-----------------------------------------------------------------
                                          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
-----------------------------------------------------------------



More information about the ntg-context mailing list