答案1
尝试
\documentclass{article}
\usepackage{tikz}
\newcommand{\mygrid}{\tikz{\draw[step=2.5mm] (0,0) grid (1,1);}}
\begin{document}
\begin{tikzpicture}
\node[rectangle, draw, inner sep=0]
{
\mygrid
};
\end{tikzpicture}
\end{document}
答案2
使用path picture
\documentclass[tikz, margin=5pt]{standalone}
\usepackage{tikz}
\def\Height{3}
\def\Width{5}
\begin{document}
\begin{tikzpicture}
\node[rectangle, draw,
text width=\Width cm, text height=\Height cm,
] [inner sep=0, path picture={
\draw[step=0.5, red] (path picture bounding box.south west) grid (path picture bounding box.north east);
}]{Possible text in the node};
\end{tikzpicture}
\end{document}