Hi Hans,
Some time ago, you offered this code to respond to a specific request from me. I used this code again and wanted to know if it was possible for the title "Algorithm" to be automatically centered based on the content.
Thank you
Fabrice
\definecolor[MyBlue][c=0.2 , m=0.03, y=0.00, k=0.00]
\definecolor[maincolor] [b=.5]
\defineframedtext
[MyFrame]
[frame=off,
background=MyFrame,
width=fit,
height=fit,
style=small]
\startuseMPgraphic{MyFrame}
path b;
picture p;
p := textext.rt("\tfx\bf\white\framedtextparameter{Title}");
p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth topenlarged .5EmWidth bottomenlarged .5EmWidth ;
fill OverlayBox withcolor "MyBlue" ;
fill b withcolor \MPcolor{maincolor} ;
draw p ;
setbounds currentpicture to boundingbox currentpicture enlarged 2mm ;
\stopuseMPgraphic
\defineoverlay
[MyFrame]
[\useMPgraphic{MyFrame}]
\starttext
\MyFrame[Title=Algorithme]{%
\m{a\gets 2x-1}
\m{b\gets a²-1}
\m{c\gets b\div 4}
\m{d\gets c-a+x}
}
\stoptext