[NTG-context] Text with background (overlay with a line by MP)

Aditya Mahajan adityam at umich.edu
Sat Mar 19 23:13:46 CET 2011


On Sat, 19 Mar 2011, Procházka Lukáš wrote:

> Hello,
>
> I'm trying to create an overlay - text with a line drawn bellow.
>
> The following code:
>
> ---
>
> \defineoverlay[Label][\useMPgraphic{Label}]
>
> \startuniqueMPgraphic{Label}
> path p; p := (0,0) -- (OverlayWidth,0);
> draw p yshifted -1cm withpen pencircle scaled 1mm withcolor .667red;
> \stopuniqueMPgraphic
>
> \def\Text#1{\inframed[background=Label,frame=off]{#1}}
>
> \starttext
> AAA
> \Text{BBB}
> CCC
> \stoptext
>
> ---
>
> results in a horizontal line going exactly through the middle of the text.
>
> And I'd like to draw it bellow; thus "yshifted -1cm".
>
> How to do it?

You do not need yshifted. But you need to set the bounding box of the 
resulting image correctly.

\startuniqueMPgraphic{Label}
  path p; p := (0,0) -- (OverlayWidth,0);
  draw p withpen pencircle scaled 1mm withcolor .667red;
  setbounds currentpicture to boundingbox OverlayBox ;
\stopuniqueMPgraphic

Aditya


More information about the ntg-context mailing list