1

How can I add a graph paper background for my framed boxes?

Example:

\documentclass{article}
\usepackage{framed}

\begin{document}
Calculate the Solution of $5+3$

\begin{framed}
\vspace{5cm}
\end{framed}

\end{document}

box

2 Answers 2

2

This can be accomplished with a custom tikz based style for mdframed (instead of 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}

box with graph paper background

1

This can be accomplished with a custom style for tcolorbox (instead of framed)

\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}

solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.