
ConTeXt를 사용하여 멋진 프레임을 정의하려고 하는데 몇 가지 어려움이 있습니다. 이에 대한 예를 많이 발견했기 때문에 Metapost를 주로 사용했지만 TiKz에 더 능숙하기 때문에 무슨 일이 일어나고 있는지 잘 모르겠습니다.
먼저 프레임 텍스트 환경을 사용하려고 시도했지만 그림을 삽입할 때 제대로 작동하지 않습니다(자주 필요한 기능입니다). 제가 원하는 프레임은 이렇습니다.
\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