5

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. An example of Square Picture.

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

The results I would like to get.

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

The Results I get with the code below.

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}

\begin{equation}
\left\{ \squarepicture, \squarepicture, \squarepicture  \right\}
\end{equation}

\begin{equation}
\left( \squarepicture, \squarepicture, \squarepicture  \right)
\end{equation}

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

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\font`A]{squarepicture}%
  }}}%
}

\begin{document}

\begin{equation}
\{ \squarepicture, \squarepicture, \squarepicture \}
\end{equation}

\begin{equation}
( \squarepicture, \squarepicture, \squarepicture )
\end{equation}

\begin{equation}
\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}
\end{equation}

\Huge
\begin{equation}
\{ \squarepicture, \squarepicture, \squarepicture \}
\end{equation}

\end{document}

enter image description here

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. – Werner Aug 24 '15 at 2:19
  • Thanks a lot. The resulting matrix is precisely what I need. The brackets are also nice. – verifying Aug 24 '15 at 6:52
  • @Werner \begin{tabular}{@{}c@{}}\includegraphics[height=\fontcharht\font`A]{squarepicture}\end{tabular} is package free. – egreg Aug 24 '15 at 8:20
3

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);}}

\newcommand*\adjustheight[1]{\mathpalette\doadjustheight{#1}}
\newcommand*\doadjustheight[2]
  {\ensuremath{\vcenter{\hbox{$#1#2$}}}}

\begin{document}

\begin{equation}
\left\{ \adjustheight{\squarepicture, \squarepicture, \squarepicture} \right\}
\end{equation}

\begin{equation}
\left( \adjustheight{\squarepicture, \squarepicture, \squarepicture} \right)
\end{equation}

\end{document}

If you prefer a more LaTeXy definition you can use

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

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.