On 2013–03–04 Roland Thiers wrote: > I'm learning a little bit of metapost language, using metafun manual. > I made some background for a title (surely the code is awful, thanks > for suggestions of improvement) but it's static, i'd like to adapt it to > the widthof the text. I don't know if it is possible from my code > and if it is i don't know how to do ! You can use the variable OverlayWidth to obtain the width of the overlay, which is determined by the provided text. You can use it as follows: \setuplayout [backspace=6cm] \startuniqueMPgraphic{essai} path p,p',q,q'; w:=2OverlayWidth; p := (0,0.1cm) -- (w,0.3cm); q := (11cm,-0.7cm) -- (w,2.2cm); p':= (w,1.3cm) -- (-0.4cm,1.4cm); q':= (0.3cm,2.4cm) -- (0.2cm,-0.3cm); pickup pencircle scaled 1mm; drawoptions(withcolor 0.3white); draw p; draw p'; draw q; draw q'; pair A; A:=q'intersectionpoint p'; pair B; B:=q intersectionpoint p'; pair C; C:=p intersectionpoint q; pair D; D:=q'intersectionpoint p; path s; s:= A--B--C--D--cycle; fill s withcolor .8white; \stopuniqueMPgraphic \defineoverlay [encadrement] [\uniqueMPgraphic{essai}] \defineframed [boxframed] [frame=off, foregroundstyle=bolditalic, foregroundcolor=darkred, background=encadrement] \starttext \boxframed{Devoir de mathématiques} \blank [2cm] \boxframed{Devoir de mathématiques and some more text} \stoptext Marco