5

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:

enter image description here

7
  • 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

2 Answers 2

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

enter image description here

8
2

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

enter image description here

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

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.