1

I am trying to change my theorem environment, and I played a little with MetaPost (that I don't know well, being more of a TiKz user). I ended with this layout (which I really like) with the help of this manual, but the behavior doesn't fit : it uses the last \MPtext for all calls to the textbackground (see MWE below). When I place a big chunk of text and theorems in a bufer, the behavior is even worse. Is there a way to correctly handle this ?

Thank you in advance,

\startuseMPgraphic{mp:axiomframe}
  begingroup;
    numeric u; u := 1EmWidth;
    for i=1 upto nofmultipars :
      pair bl, br, ul, ur;
      bl := llcorner multipars[i]; br := lrcorner multipars[i];
      ul := ulcorner multipars[i]; ur := urcorner multipars[i];
      % Draw the surrounding box
      path p;
      p := ( bl -- br -- ur -- ul -- cycle ) enlarged (-0.5u,0.5u) ;
      fill p withcolor 0.95 white ;
      draw p withcolor 0.8 white ;
      draw (p cutbefore point 0 of p cutafter point 2 of p) withpen pencircle scaled 1.2bp withcolor 0.8 white ;
      p := ( ul -- (ul shifted (0,-2u)) -- (ur shifted (0,-2u)) -- ur -- cycle) enlarged (-0.5u,0.5u);
      picture lab;
      lab = thelabel.lrt(\MPstring{TitreTh},ul) shifted (2u,u);
      p := (llcorner lab -- lrcorner lab -- urcorner lab -- ulcorner lab -- cycle) enlarged (0.5u,0.5u);
      draw p withpen pencircle scaled 1.2bp withcolor 0 white ;
      fill p withcolor 0.8 white;
      draw lab; 
    endfor ;
  setbounds currentpicture to OverlayBox ;
  endgroup;
\stopuseMPgraphic

\definetextbackground [theoremFrame] [mp=mp:axiomframe, location=always, leftoffset=1em,rightoffset=1em, topoffset=0ex,bottomoffset=0ex, frameoffset=5\bodyfontsize, before={\testpage[3]\blank}, after={\blank[medium]}]

\def\starttheorem[#1]{ \setMPtext {TitreTh} {\bf #1} \starttextbackground[theoremFrame] \vskip 1em } \def\stoptheorem{\flushsidefloats\stoptextbackground\\blank[big]}

\starttext \starttheorem[Knuth] \input knuth \stoptheorem

\vskip 2em

\starttheorem[A formula] \startformula a + c = x \stopformula \stoptheorem \stoptext

Same title everywhere

  • It might ; I tinkered another solution in the meantime by superimposing a framedtext on another, but it would be more flexible with this. I will try as soon as I can. – A. Licari-Guillaume Mar 19 '21 at 16:53

0 Answers0