2

I want to implement a raster graphic like this but i don't want to insert the image file. Does anybody know how to create some in latex?:enter image description here

3

EDIT: Added \bordercolor as a parameter, in addition to \thk rule thickness and \gsize grid size.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor, graphicx}
\newsavebox{\Bbox}\newsavebox{\Gbox}
\def\thk{.5pt}                   % RULE THICKNESS
\def\gsize{.65cm}                % GRID SIZE
\def\bordercolor{black}          % GRID BORDER COLOR
\def\coresize{\dimexpr\gsize-2\dimexpr\thk}
\setstackgap{S}{-\thk}
\def\Grid#1{\kern-\thk\fboxsep=0pt\relax\fboxrule=\thk\relax%
  \textcolor{\bordercolor}{\fbox{\textcolor{#1}{\rule[-.5\coresize]{\coresize}{\coresize}}}}}
\newcommand\Cgeneric[2][]{\stackinset{c}{.0pt}{c}{-.4pt}{\sffamily#1}{\Grid{#2}}}
\newcommand\Cw[1][]{\Cgeneric[#1]{white}\ignorespaces}
\newcommand\Ct[1][]{\Cgeneric[#1]{brown!40!gray!40}\ignorespaces}
\newcommand\Cb[1][]{\Cgeneric[#1]{cyan!30}\ignorespaces}
\begin{document}
\Shortstack{%
      \Ct\Ct   \Ct   \Ct   \Ct\\
      \Ct\Ct[C]\Ct[B]\Ct[D]\Ct\\
      \Ct\Ct[A]\Cb[X]\Cw   \Cw\\
      \Cw\Cw   \Cw   \Cw   \Cw\\
      \Cw\Cw   \Cw   \Cw   \Cw
}
\end{document}

enter image description here

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.