[NTG-context] Position of MetaPost graphics

Tim Steenvoorden tim.steenvoorden at gmail.com
Wed Apr 6 16:04:24 CEST 2011


Thanks for your tips Wolfgang! I switched to a solution as on the
wiki, using overlays and frames in place of layers. After setting the
boudingboxes right it works! I have to increase the \objectoffset
though, because otherwise the graphic is chopped of:

\setuppapersize[A5][A5]
\setuppagenumbering[alternative=doublesided]

\def\objectoffset{\cutspace}

\startMPinclusions
numeric CutSpace, wavePeriods, waveWidth;
path unitwave;
CutSpace    := \the\cutspace;
wavePeriods := 3 + 1/4;
waveSize    := wavePeriods * 2*pi;
unitwave    := (origin for x=0 step 0.1 until waveSize:
                 .. (x,x*sin(x))
               endfor) scaled (1/waveSize);
\stopMPinclusions

\startuniqueMPgraphic{rightwave}
pickup pencircle scaled 1pt;
draw origin -- (OverlayWidth,0) -- unitwave xscaled CutSpace yscaled
(LineHeight/2) shifted (OverlayWidth,0);
setbounds currentpicture to boundingbox OverlayBox;
\stopuniqueMPgraphic

\startuniqueMPgraphic{leftwave}
pickup pencircle scaled 1pt;
draw reverse unitwave xscaled (-1*CutSpace) yscaled (LineHeight/2) --
(OverlayWidth,0);
setbounds currentpicture to boundingbox OverlayBox;
\stopuniqueMPgraphic

\defineoverlay[rightwave]
  [\uniqueMPgraphic{rightwave}]
\defineoverlay[leftwave]
  [\uniqueMPgraphic{leftwave}]

\setuphead[chapter]
  [style=\ss\bfc,
   page=yes,
   after={\PlaceDecoration\blank[big]}]

\define\PlaceDecoration
  {\framed
     [width=broad,
      frame=off,
      offset=0pt,
      background=\doifoddpageelse{rightwave}{leftwave}]
     {\ss\bfx \date \hfill Author Name}}

\starttext

\chapter{A very long chapter title on two or more lines}

\input knuth

\chapter{A very long chapter title on two or more lines}

\input knuth

\stoptext

The \startchapter[] solution on the wiki is very neat, but it doesn't
work with MKII. Get errors with MKIV to... (Using TeXLive 2010) But
I'll use \setvariables.

Thanks for all your help!
Tim


2011/4/4 Wolfgang Schuster <schuster.wolfgang at googlemail.com>:
> Your problem is that you use {\ss\bfc …} etc. to place the title
> rather than contexts \title command where you can define your own
> command. With such a command you can put all text in a frame with
> your graphic a background.
>
> - http://wiki.contextgarden.net/Generate_Authorlist_from_Head_Content
> - http://wiki.contextgarden.net/Titles#A_complex_graphical_element_under_the_chapter_title
>
> Wolfgang


More information about the ntg-context mailing list