![如何用方格纸作为背景创建方框](https://linux22.com/image/402140/%E5%A6%82%E4%BD%95%E7%94%A8%E6%96%B9%E6%A0%BC%E7%BA%B8%E4%BD%9C%E4%B8%BA%E8%83%8C%E6%99%AF%E5%88%9B%E5%BB%BA%E6%96%B9%E6%A1%86.png)
答案1
tikz
这可以通过自定义样式来实现mdframed
(而不是framed
)
\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{backgrounds}
\mdfdefinestyle{graphpaper}{%
apptotikzsetting={\tikzset{mdfbackground/.style={}}},
singleextra={%
\scoped[on background layer,yshift=\mdfboundingboxheight]{\draw[step=5mm, line width=0.2mm, black!20!white] (0,0) grid (\mdfboundingboxwidth,-\mdfboundingboxheight);}
},
}
\begin{document}
Calculate the Solution of $5+3$
\begin{mdframed}[style=graphpaper]
\vspace{5cm}
\end{mdframed}
\end{document}
答案2
这可以通过 tcolorbox 的自定义样式(而不是框架)来实现
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{hooks,breakable,skins}
\newtcolorbox{graphpaperBox}[1][]{
enhanced,
sharp corners,
breakable,
colback=white,
underlay={%
\begin{tcbclipinterior}
\draw[step=5mm, line width=0.2mm, black!20!white, shift={(interior.north west)}] (0,0) grid (interior.south east);
\end{tcbclipinterior}
}
#1}
\begin{document}
Calculate the Solution of $5+3$
\begin{graphpaperBox}
\vspace{5cm}
\end{graphpaperBox}
\end{document}