# New Symbols in Latex

I want to define the following commands directly in latex.

• \cross{a}{b} which should create a black square, with a grey cross inside it and the symbols $a$ and $b$ arranged along the diagonal. Obs: the letters a and b are passed as arguments. I'm only intersted in the case in which the arguments are single lowercase letters.

• \crossdot{a}{b} which is similar to \cross{a}{b}, except that a grey circle should be added to the middle of the cross.

Both new symbols should be used in the text, and therefore I would like them to have approximately the size of a capital $G$. A little bit larger would be ok. A picture illustrating what I want is given below.

How do I create commands for such symbols in latex?

• How big should be \cross{ab}{cd} (or \cross{a_{min}}{b_{max}} ? Or the argument are just single letters? – Rmano Sep 21 '16 at 9:36
• @Rmano Thanks for asking. The argument are always single lowercase letters. – verifying Sep 21 '16 at 9:37

## 3 Answers

Stack and scale.

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


In this version, the \fboxsep inside the \crossbox has been reduced to grow the size of the inset letters slightly.

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


Another solution:

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


You can optimize the two macros to have a common body, but just to start:

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