ConTeXt : フレームの問題

ConTeXt : フレームの問題

ConTeXt でファンシー フレームを定義しようとしていますが、困難に直面しています。この例が多数見つかったため、主に Metapost を使用しましたが、私は TiKz の達人であるため、何が起こっているのかよくわかりません。

最初は framedtext 環境を使用しようとしましたが、図を埋め込むときにうまく動作しませんでした (これはよく必要になります)。これが私が望むフレームです。

\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

ここに画像の説明を入力してください

次に、テキスト背景を試してみました。オーバーレイとフレームテキストの定義を次のように変更しました。

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

これにより、フロートの問題は解決されますが、次の問題が発生します。フレームが必要なスペースではなくページ全体を占めてしまい、端にスペースを確保できなくなります。

ここに画像の説明を入力してください

最後に、Aditya のドキュメントを使用して MP ​​部分を変更してみました。

\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

しかし、動作が悪く、線の太さを変更できないようです (また、multipars 配列に関するドキュメントも見つかりませんでした...)

ここに画像の説明を入力してください

答え1

を使うことをお勧めしますtextbackground。これはページをまたいで分割される可能性があるためです。そこで私はWolfgangの解決策を次のように採用しました。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

ここに画像の説明を入力してください

関連情報