答案1
编辑:除了规则厚度和网格大小\bordercolor
之外,还添加为参数。\thk
\gsize
\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor, graphicx}
\newsavebox{\Bbox}\newsavebox{\Gbox}
\def\thk{.5pt} % RULE THICKNESS
\def\gsize{.65cm} % GRID SIZE
\def\bordercolor{black} % GRID BORDER COLOR
\def\coresize{\dimexpr\gsize-2\dimexpr\thk}
\setstackgap{S}{-\thk}
\def\Grid#1{\kern-\thk\fboxsep=0pt\relax\fboxrule=\thk\relax%
\textcolor{\bordercolor}{\fbox{\textcolor{#1}{\rule[-.5\coresize]{\coresize}{\coresize}}}}}
\newcommand\Cgeneric[2][]{\stackinset{c}{.0pt}{c}{-.4pt}{\sffamily#1}{\Grid{#2}}}
\newcommand\Cw[1][]{\Cgeneric[#1]{white}\ignorespaces}
\newcommand\Ct[1][]{\Cgeneric[#1]{brown!40!gray!40}\ignorespaces}
\newcommand\Cb[1][]{\Cgeneric[#1]{cyan!30}\ignorespaces}
\begin{document}
\Shortstack{%
\Ct\Ct \Ct \Ct \Ct\\
\Ct\Ct[C]\Ct[B]\Ct[D]\Ct\\
\Ct\Ct[A]\Cb[X]\Cw \Cw\\
\Cw\Cw \Cw \Cw \Cw\\
\Cw\Cw \Cw \Cw \Cw
}
\end{document}