ConTeXt: problemas de quadro

ConTeXt: problemas de quadro

Estou tentando definir frames sofisticados com o ConTeXt, mas tenho algumas dificuldades. Como encontrei muitos exemplos disso, usei principalmente o Metapost, mas como sou mais adepto do TiKz, não entendo realmente o que está acontecendo.

Primeiro tentei usar um ambiente de texto emoldurado, mas ele se comporta mal ao incorporar uma figura (que é algo que preciso com frequência). Este é o quadro como eu gostaria.

\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

insira a descrição da imagem aqui

Então tentei com um textbackground; Alterei as definições de sobreposição e texto emoldurado com

\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]

Isso resolve o problema de flutuação, mas leva ao seguinte problema: o quadro ocupa toda a página em vez do espaço necessário e não consegui espaços nas bordas:

insira a descrição da imagem aqui

Por fim, tentei modificar a parte MP usando um documento do 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

Mas não se comporta bem e não parece permitir espessura de linha variável (e não consegui encontrar nenhuma documentação sobre o array multipars...)

insira a descrição da imagem aqui

Responder1

Eu recomendo usar textbackground, porque isso pode quebrar as páginas. Portanto adaptei a solução de Wolfgang deEnquadrar seções inteiras no 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

insira a descrição da imagem aqui

informação relacionada