我试图让mdframed
环境看起来像一堆乱糟糟的纸。
我已经想出了如何使用 tikzpreactions
来获得我想要的那种外观(见下面的代码)。
我希望通过将 a 传递给 来获得相同的外观tikzsetting
,mdframed
但它似乎什么也没做。我做错了什么?
\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw
[preaction={draw=black, fill=white, transform canvas={rotate=1, xshift=2mm, yshift=-2mm}}]
[preaction={draw=black, fill=white, transform canvas={rotate=-1, xshift=.5mm, yshift=-1mm}}]
[fill=white](0,0) rectangle (2,3);
\end{tikzpicture}
\begin{mdframed}[tikzsetting={preaction={draw=black, fill=white, transform canvas={rotate=1, xshift=2mm, yshift=-2mm}},
preaction={draw=black, fill=white, transform canvas={rotate=-1, xshift=.5mm, yshift=-1mm}},
draw=black, fill=white}]
\lipsum[1]
\end{mdframed}
\end{document}
答案1
不是一个mdframed
,而是一个tcolorbox
解决方案,通过应用一个frame code pre
密钥:
\documentclass{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcolorbox}[colback=white,enhanced,sharp corners,
frame code pre={%
\draw[fill=white,transform canvas={rotate=1,xshift=-2mm,yshift=-2mm}] (frame.north west) rectangle (frame.south east);
\draw[fill=white,transform canvas={rotate=-1,xshift=2mm,yshift=2mm}] (frame.north west) rectangle (frame.south east);
}]
\lipsum[1]
\end{tcolorbox}
更新
\documentclass{article}
\usepackage{blindtext}
\usepackage[most]{tcolorbox}
\makeatletter
\newtcolorbox{pileofpaper}[1][]{%
colframe=black,
colback=white,
enhanced,sharp corners,
boxrule=0.5pt,
frame code pre={%
\foreach \al/ \x / \y in {1/-1mm/-2mm,-1/-2mm/3mm,-2/2mm/-1mm,3/-2mm/-2mm} {
\draw[draw=tcbcol@frame,line width=0.2*\kvtcb@left@rule,
fill=tcbcol@back,
transform canvas={rotate=\al,xshift=\x,yshift=\y}
] (frame.north west) rectangle (frame.south east);
}
},
#1
}
\makeatother
\begin{document}
\begin{pileofpaper}[colback=white!95!gray,colframe=blue]
\blindtext
\end{pileofpaper}
\end{document}