答案1
堆叠和缩放。
\documentclass{article}
\usepackage{xcolor,stackengine,scalerel}
\newcommand\graybox[1][]{\color{gray}%
\fbox{\makebox[\dimexpr\ht\strutbox+\dp\strutbox\relax]{\textcolor{black}{$#1$}\strut}}}
\newcommand\crossbox[2]{\hbox{\fboxsep=-\fboxrule\relax\fbox{%
\fboxrule=.5\fboxrule\relax\stackon[0pt]{\graybox\graybox[#2]}{\graybox[#1]\graybox}}}}
\newcommand\cross[2]{\kern1pt\scalerel*{\crossbox{#1}{#2}}{G}\kern1pt}
\newcommand\crossdot[2]{\stackinset{c}{}{c}{-.31pt}{\textcolor{gray}{$\cdot$}}%
{\cross{#1}{#2}}}
\begin{document}
$\cross{g}{d} \crossdot{a}{b} G$
\end{document}
在这个版本中,\fboxsep
内部的尺寸\crossbox
已被缩小,插入字母的尺寸略有增加。
\documentclass{article}
\usepackage{xcolor,stackengine,scalerel}
\newcommand\graybox[1][]{\color{gray}%
\fbox{\makebox[\dimexpr\ht\strutbox+\dp\strutbox\relax]{\textcolor{black}{$#1$}\strut}}}
\newcommand\crossbox[2]{\hbox{\fboxsep=-\fboxrule\relax\fbox{\fboxsep=-1pt\relax%
\fboxrule=.5\fboxrule\relax\stackon[0pt]{\graybox\graybox[#2]}{\graybox[#1]\graybox}}}}
\newcommand\cross[2]{\kern1pt\scalerel*{\crossbox{#1}{#2}}{G}\kern1pt}
\newcommand\crossdot[2]{\stackinset{c}{}{c}{-.31pt}{\textcolor{gray}{$\cdot$}}%
{\cross{#1}{#2}}}
\begin{document}
$\cross{g}{d} \crossdot{a}{b} G$
\end{document}
答案2
另一个解决方案:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{lmodern}
\newcommand{\cross}[2]{%
\resizebox{11pt}{!}{
\begin{tikzpicture}[font=\tiny, every node/.style={draw=gray, text=black, inner sep=0.5pt, outer sep=0pt, minimum size=8pt}
]
\node (A) {$#1$};
\node[below right=0pt of A] (B) {$#2$};
\draw (A.north west) rectangle (B.south east);
\end{tikzpicture}}}
\newcommand{\crossdot}[2]{%
\resizebox{11pt}{!}{
\begin{tikzpicture}[font=\tiny, every node/.style={draw=gray, text=black, outer sep=0pt, inner sep=0.5pt, minimum size=8pt}]
\node {$#1$};
\node[below right=0pt of A] (B) {$#2$};
\draw (A.north west) rectangle (B.south east);
\fill[gray] (A.south east) circle(1pt);
\end{tikzpicture}}}
\begin{document}
$G$ \cross{a}{b} \cross{m}{g} \crossdot{m}{h}
\end{document}
答案3
您可以优化这两个宏以使其具有共同的主体,但只是开始:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\newcommand\cross[3][]{%
\begin{tikzpicture}[baseline, x=1em, y=1em, #1]
\draw[gray] (0,0) rectangle (1,1);
\draw[gray] (0,0.5) rectangle (1,0.5);
\draw[gray] (0.5,0) rectangle (0.5,1);
\node[inner sep=0pt, font=\tiny] at (0.25,0.75){$#2$};
\node[inner sep=0pt, font=\tiny] at (0.75,0.25){$#3$};
\end{tikzpicture}}
\newcommand\crossdot[3][]{%
\begin{tikzpicture}[baseline, x=1em, y=1em, #1]
\draw[gray] (0,0) rectangle (1,1);
\draw[gray] (0,0.5) rectangle (1,0.5);
\draw[gray] (0.5,0) rectangle (0.5,1);
\fill[gray] (0.5,0.5) circle (1pt);
\node[inner sep=0pt, font=\tiny] at (0.25,0.75){$#2$};
\node[inner sep=0pt, font=\tiny] at (0.75,0.25){$#3$};
\end{tikzpicture}}
\begin{document}
G\cross{a}{b} \crossdot{c}{d} G \cross[scale=0.8, transform shape]{c}{d}
\end{document}