이것이 중복인지 아닌지는 알 수 없지만 중복된 경우 닫을 수 있습니다.
나는 배우려고 노력해 왔습니다 ConTeXt
. 나는 다운로드한 문서에서 Metapost
/ 를 사용하여 얻은 제목 및 페이지 번호 형식을 특히 좋아합니다 Metafun
. 나는 \chapter
(LaTeX에서 egreg
's'를 통해 이 효과를 얻으려고 노력해 왔습니다.gmp
패키지.
이를 위해 다음에서 찾은 여러 파일의 코드를 복사하여 붙여넣었습니다.여기. 이것이 현재 얻고 있는 결과입니다.
이 코드로.
\setuppapersize[A4][A4]
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,
height=middle, width=middle]
\def\MPclipOne#1#2#3#4#5%
{\startuseMPgraphic{clip:one}
w := #1; width := 100; wfactor := w/width;
h := #2; height := 100; hfactor := h/height;
%
color lightred; lightred := (.90,.50,.50);
color lightgray; lightgray := (.95,.95,.95);
color gray; gray := (.50,.50,.50);
%
def random_delta (expr d) =
d-(uniformdeviate 2d)
enddef;
%
z1 = (0,height);
z2 = (0,0);
z3 = (width,0);
z4 = (width,height);
%
z5 = (width+random_delta(.2width),height+random_delta(.2height));
z6 = (.5width+random_delta(.1width),height+random_delta(.1height));
%
pickup pencircle
xscaled (#3/wfactor)
yscaled (#3/(2*hfactor))
rotated 30;
%
draw z5..z1..z2..z3..z4..z6 withcolor #4;
%
pickup pencircle
xscaled (#3/wfactor)
yscaled (#3/hfactor);
%
draw z1 withcolor #5;
draw z2 withcolor #5;
draw z3 withcolor #5;
draw z4 withcolor #5;
draw z5 withcolor #5;
draw z6 withcolor #5;
%
newwidth := (xpart (urcorner currentpicture)) -
(xpart (llcorner currentpicture));
newheight := (ypart (urcorner currentpicture)) -
(ypart (llcorner currentpicture));
%
currentpicture := currentpicture
xscaled (w/newwidth) yscaled (h/newheight);
\stopuseMPgraphic
\useMPgraphic{clip:one}{}}
\defineoverlay
[KopAchtergrond]
[\MPclipOne{\overlaywidth}{\overlayheight}{10pt}{gray}{red}]
\def\HeadCommand#1#2%
{\alignedline{\v!outer}{\v!left}
{\framed
[\c!background=KopAchtergrond,
\c!width=\v!fit,
\c!height=\v!fit,
\c!frame=\v!off,
\c!strut=\v!no,
\c!offset=24pt,
\c!align=\v!middle]
{\doifmode{*sectionnumber}
{#1\kern.5em% strut niet geset, zou wel moeten
\hbox{\color[headrule]{\vrule\!!width1pt\!!height1.5\ht\strutbox\!!depth1.25\dp\strutbox}}%
\kern.5em}%
#2}}}
\setuphead
[\v!chapter]
[\c!command=\HeadCommand,
\v!appendix\c!label=none,
\c!page=,
\c!before=\vskip36pt plus 6pt minus 6pt,
\c!after=\vskip24pt]
\starttext
\chapter{Sample chapter}
\stoptext
여기서 무슨 일이 일어나고 있는지, 그리고 원하는 효과를 얻는 방법을 알려주세요.
답변1
\unprotect
.. 블록 \protect
과 \unexpanded
.
\setuppapersize[A4][A4]
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,
height=middle, width=middle]
\unprotect
\def\MPclipOne#1#2#3#4#5%
{\startuseMPgraphic{clip:one}
w := #1; width := 100; wfactor := w/width;
h := #2; height := 100; hfactor := h/height;
%
color lightred; lightred := (.90,.50,.50);
color lightgray; lightgray := (.95,.95,.95);
color gray; gray := (.50,.50,.50);
%
def random_delta (expr d) =
d-(uniformdeviate 2d)
enddef;
%
z1 = (0,height);
z2 = (0,0);
z3 = (width,0);
z4 = (width,height);
%
z5 = (width+random_delta(.2width),height+random_delta(.2height));
z6 = (.5width+random_delta(.1width),height+random_delta(.1height));
%
pickup pencircle
xscaled (#3/wfactor)
yscaled (#3/(2*hfactor))
rotated 30;
%
draw z5..z1..z2..z3..z4..z6 withcolor #4;
%
pickup pencircle
xscaled (#3/wfactor)
yscaled (#3/hfactor);
%
draw z1 withcolor #5;
draw z2 withcolor #5;
draw z3 withcolor #5;
draw z4 withcolor #5;
draw z5 withcolor #5;
draw z6 withcolor #5;
%
newwidth := (xpart (urcorner currentpicture)) -
(xpart (llcorner currentpicture));
newheight := (ypart (urcorner currentpicture)) -
(ypart (llcorner currentpicture));
%
currentpicture := currentpicture
xscaled (w/newwidth) yscaled (h/newheight);
\stopuseMPgraphic
\useMPgraphic{clip:one}{}}
\defineoverlay
[KopAchtergrond]
[\MPclipOne{\overlaywidth}{\overlayheight}{10pt}{gray}{red}]
\unexpanded\def\HeadCommand#1#2%
{\alignedline{\v!outer}{\v!left}
{\framed
[\c!background=KopAchtergrond,
\c!width=\v!fit,
\c!height=\v!fit,
\c!frame=\v!off,
\c!strut=\v!no,
\c!offset=24pt,
\c!align=\v!middle]
{\doifmode{*sectionnumber}
{#1\kern.5em% strut niet geset, zou wel moeten
\hbox{\color[headrule]{\vrule\!!width1pt\!!height1.5\ht\strutbox\!!depth1.25\dp\strutbox}}%
\kern.5em}%
#2}}}
\setuphead
[\v!chapter]
[\c!command=\HeadCommand,
\v!appendix\c!label=none,
\c!page=,
\c!before=\vskip36pt plus 6pt minus 6pt,
\c!after=\vskip24pt]
\protect
\starttext
\chapter{Sample chapter}
\stoptext
하지만 이것은 정말 오래된 ConTeXt 코드입니다. 여기서 TeX와 Metapost 간의 통신은 매크로 매개변수를 통해 이루어집니다. 통신에는 키-값 매개변수를 사용하겠습니다. 여기에 dotcolot
키를 사용하여 점의 색상을 지정하는 가능한 솔루션이 있습니다 .
\setupexternalfigures[location={local,global}]
\startuseMPgraphic{randomcircle}
width := 100; wfactor := OverlayWidth/width;
height := 100; hfactor := OverlayHeight/height;
%
color dotcolor; dotcolor := \MPcolor{\framedparameter{dotcolor}};
def random_delta (expr d) =
d-(uniformdeviate 2d)
enddef;
%
z1 = (0,height);
z2 = (0,0);
z3 = (width,0);
z4 = (width,height);
%
z5 = (width, height) randomized (0.2width, 0.2height);
z6 = (0.5width, height) randomized (0.1width, 0.1height);
%
pickup pencircle
xscaled (OverlayLineWidth/wfactor)
yscaled (OverlayLineWidth/(2*hfactor))
rotated 30;
%
draw z5..z1..z2..z3..z4..z6 withcolor OverlayLineColor;
%
pickup pencircle
xscaled (OverlayLineWidth/wfactor)
yscaled (OverlayLineWidth/hfactor);
%
draw z1 withcolor dotcolor;
draw z2 withcolor dotcolor;
draw z3 withcolor dotcolor;
draw z4 withcolor dotcolor;
draw z5 withcolor dotcolor;
draw z6 withcolor dotcolor;
%
newwidth := (xpart (urcorner currentpicture)) -
(xpart (llcorner currentpicture));
newheight := (ypart (urcorner currentpicture)) -
(ypart (llcorner currentpicture));
%
currentpicture := currentpicture
xscaled (OverlayWidth/newwidth) yscaled (OverlayHeight/newheight);
\stopuseMPgraphic
\defineoverlay
[randomcircle]
[\useMPgraphic{randomcircle}]
randomcircle
이제 오버레이를 허용하는 모든 명령과 함께 오버레이를 사용할 수 있습니다. 예를 들어 프레임과 그림은 다음과 같습니다.
이는 다음을 사용하여 얻은 것입니다.
\definecolor[gray][r=0.5, g=0.5, b=0.5]
\starttext
\startTEXpage[offset=10mm]
\dontleavehmode
\framed[background=randomcircle, dotcolor=red, framecolor=gray, offset=24pt, rulethickness=10pt, frame=off]
{ Hello World}
\hskip 6em
\externalfigure[cow.pdf]
[width=3cm,
background=randomcircle, dotcolor=red, framecolor=gray,
backgroundoffset=24pt, rulethickness=10pt, frame=off]
\stopTEXpage
\stoptext
command
이제 섹션 제목 주위에 그래픽을 가져오는 것은 단순히 키를 설정하는 문제입니다 \setuphead
.