# Square pictures as symbols

I have some square pictures in eps format which should be regarded as mathematical symbols. Each square picture consists of a blank square with some drawing in the center. I would like to be able to do essentially two things with these pictures.

1. (Most important) Make matrices out of these pictures. Problem: I need the final matrix to be a square. The lines dividing each column and each row of the matrix must match precisely the borders of the square pictures. The result that I get using the array matrix is not satisfactory because the final matrix is not really a square, and the lines dividing columns and lines do not match borders of pictures.

2. (Also important) I need to write sequences of these pictures, enclosed into several types of brackets, such as (),[],{} , and such that the pictures are separated by commas. The result I get is not satisfactory because for some reason I get huge spaces under the pictures.

For instance, the following is an example of square picture.

Below, it is an example of the things I would like to do with square pictures.

But what I actually get with the minimal example given below is the following, which is unsatisfactory.

A minimal example of my code is given below.

\documentclass[a4paper]{article}
\usepackage{graphicx,amsmath,amssymb}

\newcommand{\squarepicture}{{\includegraphics[scale=0.8]{squarepicture.eps}}}
\begin{document}

$$\left\{ \squarepicture, \squarepicture, \squarepicture \right\}$$

$$\left( \squarepicture, \squarepicture, \squarepicture \right)$$

$$\begin{array}{|c|c|c|} \hline \squarepicture & \squarepicture & \squarepicture \\ \hline \squarepicture & \squarepicture & \squarepicture \\ \hline \squarepicture & \squarepicture & \squarepicture \\ \hline \end{array}$$
\end{document}


You can adjust the symbol to be slightly moved down, with \vcenter. I'd avoid scaled, and favor setting height, so the symbol with scale along with the current font size.

\documentclass[a4paper]{article}
\usepackage{graphicx,amsmath,amssymb}

\makeatletter
\newcommand{\squarepicture}{%
\ensuremath{\vcenter{\hbox{%
\includegraphics[height=\fontcharht\fontA]{squarepicture}%
}}}%
}

\begin{document}

$$\{ \squarepicture, \squarepicture, \squarepicture \}$$

$$( \squarepicture, \squarepicture, \squarepicture )$$

$$\renewcommand{\arraystretch}{0} \begin{array}{@{\vline}c@{\vline}c@{\vline}c@{\vline}} \hline \squarepicture & \squarepicture & \squarepicture \\ \hline \squarepicture & \squarepicture & \squarepicture \\ \hline \squarepicture & \squarepicture & \squarepicture \\ \hline \end{array}$$

\Huge
$$\{ \squarepicture, \squarepicture, \squarepicture \}$$

\end{document}


By the way, this is the Metapost source for the picture:

beginfig(1);
fill (0,0)--(100,0)--(100,100)--(0,100)--cycle withcolor (1,1,0);
pickup pencircle scaled 4;
draw fullcircle scaled 90 shifted (50,50);
draw (5,50)--(95,50);
draw (50,5)--(50,95);
pickup pencircle scaled 10;
drawdot (30,70);
drawdot (70,30);
endfig;

end.

• What about using adjustbox with the export option, and then valign=c. Aug 24 '15 at 2:19
• Thanks a lot. The resulting matrix is precisely what I need. The brackets are also nice. Aug 24 '15 at 6:52
• @Werner \begin{tabular}{@{}c@{}}\includegraphics[height=\fontcharht\fontA]{squarepicture}\end{tabular} is package free. Aug 24 '15 at 8:20

I propose another solution for the vertical alignment problem. A macro that vertically adjusts the argument to get the correct delimiters. For the array, egreg solution seems good.

\documentclass{scrartcl}
\usepackage{tikz}

\newcommand*\squarepicture
{\tikz[scale=.5]{\fill[yellow](-1,-1)rectangle(1,1);
\draw circle(.8)(0,.8)--(0,-.8)(.8,0)--(-.8,0)
(.35,-.35)circle(.1)(-.35,.35)circle(.1);}}

{\ensuremath{\vcenter{\hbox{$#1#2$}}}}

\begin{document}

$$\left\{ \adjustheight{\squarepicture, \squarepicture, \squarepicture} \right\}$$

$$\left( \adjustheight{\squarepicture, \squarepicture, \squarepicture} \right)$$

\end{document}


If you prefer a more LaTeXy definition you can use

\newcommand*\doadjustheight[2]
{\raisebox{\dimexpr-.5\height+\fontdimen22\textfont2}{$#1#2$}}


• thanks! this is a nice refinement. I accepted egreg's answer since the matrix was the most important. Aug 24 '15 at 6:53