Sadly I didn't found any source showing this. I just need a grid behind some math. Usually I box equations using:




\newcommand{\frameGrid}[1]{\tikz[baseline=(X.base)]\node [draw = gray,fill=gray!20, inner sep=0pt] (X) {#1};}



It'd be cool to have squared paper inside the box as well. Even if I can't imagine how.

3 Answers 3


Sticking with your tikz solution and modifying it:




        preaction={fill, black!10!white},
        pattern={Hatch[distance=#1, xshift=0.5*#1, yshift=0.5*#1, line width=0.05*#1]},
        pattern color=black!20!white,
        inner sep=0pt
    ] (X) {#2};



equation grid

  • Looks exactly like the pattern I'm searching. It just gives me " Package pgf Error: Undefined pattern `Hatch' ". Following exactly your code
    – Leon
    Commented Nov 14, 2021 at 21:17
  • 1
    Try updating your TeX distribution. I don't know when the Hatch pattern was added to patterns.meta but maybe your version of tikz is to old.
    – mais
    Commented Nov 15, 2021 at 9:37

With tcolorbox package

\tcbset{enhanced, colframe=green!80!black, colback=yellow!10!white,
            \draw[help lines, step=5mm, red!20, shift={(interior.north west)}]
                (interior.south west) grid (interior.north east);

enter image description here


The following draws a 25 by 6 grid (grid size 0.75em) and places a formula in its center. The color of the grid is set through \special{ps:...} commands.

\newdimen\grid \grid=.75em
\def\gridrow#1#2{\hbox{\leaders\hbox{\hskip.3\grid\vrule height#2\grid
\special{ps:gsave 0.75 setgray}
\vbox to0pt{
  \leaders\vbox{\gridrow{25}{.3}\hrule\vskip-.4pt\gridrow{25}{.7}}\vskip 6\grid
\vbox to 6\grid{\vfil\hbox to25\grid{\hfil$1=2$\hfil}\vfil}

enter image description here

  • 1
    Extra points for the elaborate formula of alternative math!
    – thymaro
    Commented Nov 15, 2021 at 1:00
  • @thymaro worth a bounty! Commented Nov 15, 2021 at 4:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .