ConTeXt: problemas de marco

ConTeXt: problemas de marco

Estoy intentando definir marcos elegantes con ConTeXt, pero tengo algunas dificultades. Como encontré muchos ejemplos de esto, utilicé principalmente Metapost, pero como soy más un adepto a TiKz, realmente no entiendo lo que está pasando.

Primero intenté usar un entorno de texto enmarcado, pero se comporta mal al incrustar una figura (que es algo que necesito a menudo). Este es el marco como me gustaría.

\usesymbols[mvs]
\definesymbol[info][{\symbol[martinvogel 2][Info]}]

\startuseMPgraphic{mp:axiomframe}
  draw (OverlayWidth,OverlayHeight) -- (0,OverlayHeight) -- (0,0);
  draw (0.5pt,0) -- (OverlayWidth,0) -- (OverlayWidth,OverlayHeight-
    0.5pt) withpen pencircle scaled 1.2bp;
  fill OverlayBox withcolor 0.95 white;
  fill bbox textext.top("\tfd\symbol[info]") shifted 
   (0.5EmWidth,OverlayHeight-3ExHeight) withcolor white;
  draw textext.top("\tfd\symbol[info]") shifted 
   (0.5EmWidth,OverlayHeight-3ExHeight) ;
  setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\defineoverlay[axiomframe][\useMPgraphic{mp:axiomframe}]
\defineframedtext[theoremFrame]
             [frame=off,
               rulethickness=1pt,
               offset=5pt,
               background=axiomframe,
               width=fit,
               location=middle]

\def\starttheorem{\dosingleempty\doStarttheorem}
\def\doStarttheorem[#1]{
  \starttheoremFrame
    \iffirstargument \hskip2em {\bfa #1} \\ \fi
}
\def\stoptheorem{\stoptheoremFrame}

\useexternalfigure[ctanlion]
  [http://www.ctan.org/lion/ctan_lion_350x350.png][width=5cm]

\starttext
\starttheorem[Hello]
  \placefigure[here,right,none]{}{\externalfigure[ctanlion]}
  \input knuth
\stoptheorem

ingrese la descripción de la imagen aquí

Luego probé con un fondo de texto; Cambié las definiciones de superposición y texto enmarcado con

\definetextbackground[theoremFrame]
                 [mp=mp:axiomframe,
             leftoffset=2\bodyfontsize,rightoffset=.5\bodyfontsize,
             topoffset=.5\bodyfontsize,bottomoffset=.5\bodyfontsize,
             before={\testpage[3]\blank},
             after={\blank[2*medium]},
             width=local]

Esto resuelve el problema del flotador, pero conduce al siguiente problema: el marco ocupa toda la página en lugar del espacio requerido, y no pude conseguir espacios en los bordes:

ingrese la descripción de la imagen aquí

Finalmente, intenté modificar la parte MP usando un documento de Aditya:

\startuseMPgraphic{mp:axiomframe}
  path p;
  for i = 1 upto nofmultipars :
    p = (multipars[i] topenlarged 0pt bottomenlarged 0pt);
    fill p withcolor 0.95white ;
    draw p withcolor black withpen pencircle scaled 
     \MPvar{linewidth};
  endfor;
  fill bbox textext.top("\tfd\symbol[info]") shifted 
    (0.5EmWidth,OverlayHeight-3ExHeight) withcolor white;
  draw textext.top("\tfd\symbol[info]") shifted 
    (0.5EmWidth,OverlayHeight-3ExHeight) ;
  setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

Pero no se comporta bien y no parece permitir un grosor de línea variable (y no pude encontrar ninguna documentación sobre la matriz multipar...)

ingrese la descripción de la imagen aquí

Respuesta1

Recomiendo usar textbackground, porque esto puede dividir las páginas. Por lo tanto adapté la solución de Wolfgang deEncuadre secciones enteras en ConTeXt.

\usesymbols[mvs]
\definesymbol[info][{\symbol[martinvogel 2][Info]}]

\startuseMPgraphic{mp:axiomframe}
  begingroup;
    for i=1 upto nofmultipars :
      % Draw the surrounding box
      path p;
      p := ( llcorner multipars[i]
             -- lrcorner multipars[i]
             -- urcorner multipars[i]
             -- ulcorner multipars[i]
             -- cycle )
             enlarged (EmWidth,EmWidth) ;
      fill p withcolor boxfillcolor ;
      draw p withcolor boxlinecolor ;
      draw (p cutbefore point 2 of p cutafter point 4 of p)
            withpen pencircle scaled 2pt
            withcolor boxlinecolor ;
      % Draw the info symbol
      picture pic;
      pic := textext.ulft("\tfd\symbol[info]");
      pic := pic shifted ulcorner multipars[i];
      fill bbox pic withcolor white;
      draw pic;
    endfor ;
  setbounds currentpicture to OverlayBox ;
  endgroup;
\stopuseMPgraphic

\definetextbackground
  [theoremFrame]
  [mp=mp:axiomframe,
   location=paragraph,
   backgroundcolor=green,
   framecolor=red,
   before={\testpage[3]\blank},
   after={\blank[2*medium]}]

\defineenumeration
  [theorem]
  [text=,
   number=no,
   title=yes,
   titledistance=2em,
   titleleft=,
   titleright=,
   before={\starttextbackground[theoremFrame]},
   after={\stoptextbackground}]

\useexternalfigure[ctanlion]
  [http://www.ctan.org/lion/ctan_lion_350x350.png][width=5cm]

\starttext
\starttheorem[title=Hello]
  \placefigure[here,right,none]{}{\externalfigure[ctanlion]}
  \input knuth
\stoptheorem

\input lorem

\starttheorem[title=Hello]
  \placefigure[here,right,none]{}{\externalfigure[ctanlion]}
  \input knuth
\stoptheorem
\stoptext

ingrese la descripción de la imagen aquí

información relacionada