\shadowbox
如何使用 ConTeXt获得与 LaTeX 相同的结果?
%\usepackage{fancybox}
\shadowbox{text}
这是我尝试使用 Metapost,这是我的 MWE:
\setupcolors[state=start]
\usecolors[crayola]
\startuniqueMPgraphic{cadre}
path q; q := (0.5,-1) -- (OverlayWidth+0.5,-1) -- (OverlayWidth+0.5, OverlayHeight) -- (0.5, OverlayHeight) -- (0.5,-1) -- cycle;
path p; p := (0,0) -- (OverlayWidth,0) -- (OverlayWidth, OverlayHeight) -- (0, OverlayHeight) -- (0,0);
fill q withpen pencircle scaled 5pt withcolor \MPcolor{black} ;
fill p withpen pencircle scaled 1pt withcolor gray ;
setbounds currentpicture to boundingbox OverlayBox;
\stopuniqueMPgraphic
\defineoverlay[cadre][\useMPgraphic{cadre}]
\defineframedtext[shadowbox][frame=off,background=cadre,width=\makeupwidth]
\starttext
\startshadowbox
\input knuth
\stopshadowbox
\stoptext
答案1
我不确定这是否算作重复,但如果有帮助的话,我会发布答案。有关如何定义您自己的 MetaPost 背景的示例,您可以查看Wolfgang Schuster 的回答。文本背景替代选项包括,例如,always
(应用于整个文本)paragraph
和text
(应用于单词)。
在 MetaPost 方面,boundingbox
有一个宏用于绘制每个页面/段落/行的边界框,正如您所想象的那样,nofmultipars
它只是要处理的单元数。在我们的例子中,always
仅跨页面分隔。
%\setuppapersize[A6]
\startuseMPgraphic{shadowed}
begingroup;
path MyFrame, MyShadow;
numeric MyThickness; MyThickness := 4bp;
for i=1 upto nofmultipars:
MyFrame := boundingbox multipars[i] enlarged (EmWidth,EmWidth);
MyShadow := MyFrame shifted (1/2MyThickness*(1,-1));
draw MyFrame;
draw (
(MyThickness*right + llcorner MyShadow)
--lrcorner MyShadow
--(MyThickness*down + urcorner MyShadow)
)
withpen pensquare scaled MyThickness;
endfor
endgroup;
\stopuseMPgraphic
\definetextbackground
[shadowed]
[mp=shadowed,
location=always]
\starttext
\startshadowed
\input knuth
\stopshadowed
\stoptext