# Object Formatting: Graphics as In-line Symbols

I'm trying to create an in-line symbol that is a specific shape. I'm wondering how I can have something like this in my document:

• I'd need them to be colored too... Aug 18, 2013 at 19:10
• Can you get spell check in LaTeX? Aug 18, 2013 at 19:18
• Since you're looking for different shapes, supply a list, or something that describes the object generically. As it stands now, this question is too broad.
– Werner
Aug 18, 2013 at 19:21
• The "general shape" would be every combination of fill-able cells for the 2-grid, namely the thing that looks like this: $\boxplus$ Aug 18, 2013 at 19:25
• I understand. There's no MathJax formatting on this site. You tagged the question with tikz-pgf; is this your preferred solution? What have you tried thus far?
– Werner
Aug 18, 2013 at 19:29

\documentclass{article}
\usepackage{xcolor}
\usepackage{stackengine}
\def\block#1{\color{#1}\rule{1ex}{1ex}}
\begin{document}
\parbox{3in}{%
\ldots here we can see that since the bla bla bla conjecture asserts that
{\def\stackalignment{r}\stackon[0pt]{\block{blue}}{\block{green}\block{magenta}}}
is different from
{\block{blue}}
\ldots
}
\end{document}


• I get the following error: ! LaTeX Error: File stackengine.sty' not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty) Enter file name:  Aug 18, 2013 at 19:41
• @LoieBenedicte It's a relatively new package. It can be found at ctan.org/tex-archive/macros/latex/contrib/stackengine. Putting the sty file in your current directory will allow the code to compile. In the longer term, you should find the directory where LaTeX would like it installed. Aug 18, 2013 at 19:44
• @LoieBenedicte Likewise in ctan.org/tex-archive/macros/latex/contrib/readarray Aug 18, 2013 at 19:48
• Hmm... How can you make the blocks bigger? Aug 18, 2013 at 19:52

You can define a set of block-commands that defines a hierarchy:

\documentclass{article}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\newcommand{\oneblock}[2][1ex]{{\color{#2}\rule{#1}{#1}}}
\newcommand{\twoblock}[3][1ex]{\oneblock[#1]{#2}\oneblock[#1]{#3}}
\newcommand{\fourblock}[5][1ex]{\leavevmode\rlap{%
\raisebox{#1}{\twoblock[#1]{#2}{#3}}}% Upper \twoblock
\twoblock[#1]{#4}{#5}}% Lower \twoblock
\begin{document}
Here we can see that since the bla bla bla conjecture asserts that
\fourblock{green}{magenta}{white}{blue} is different from \oneblock{blue} and
\twoblock{green}{magenta!50} or even \twoblock[1.5ex]{red!80!black}{orange!70}.
\end{document}

• \oneblock[<wd>]{<col1>} prints one block of width <wd> and colour <col1>;
• \twoblock[<wd>]{<col1>}{<col2>} prints \oneblock[<wd>]{<col1>}\oneblock[<wd>]{<col2>};
• \fourblock[<wd>]{<col1>}{<col2>}{<col3>}{<col4>} prints a raised \twoblock[<wd>]{<col1>}{<col2>} on top of \twoblock[<wd>]{<col3>}{<col4>}.

The default width is 1ex`, which can be changed via the first optional argument.

Of course, enhancements are possible, and even the interface can be changed, if needed.