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

Wolfgang Schuster schuster.wolfgang at googlemail.com
Sun Mar 20 08:22:02 CET 2011


Am 19.03.2011 um 23:13 schrieb Aditya Mahajan:

> On Sat, 19 Mar 2011, Procházka Lukáš wrote:
> 
>> Hello,
>> 
>> I'm trying to create an overlay - text with a line drawn bellow.
>> 
>> [...]
>> 
>> 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


You can also use the \framed-parameters:

\startuniqueMPgraphic{Label}
path p; p := (0,0) -- (OverlayWidth,0);
draw p withpen pencircle scaled \frameddimension{rulethickness} withcolor \MPcolor{\framedparameter{framecolor}};
setbounds currentpicture to boundingbox OverlayBox ;
\stopuniqueMPgraphic

\defineoverlay[Label][\useMPgraphic{Label}]

\defineframed[Text][background=Label,frame=off,location=low,framecolor=darkred,rulethickness=1mm]

\starttext
AAA \Text{BBB} CCC \Text[framecolor=blue]{DDD} EEE
\stoptext

Wolfgang



More information about the ntg-context mailing list