TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way in latex to scan a cell of a table with horizontal, vertical, diogonal with lines?

I want similar thing as in below figure.



share|improve this question
What do you mean by scan? – Bernard Jul 24 '14 at 11:26
Maybe “fill” rather than ”scan”? – egreg Jul 24 '14 at 12:47
up vote 1 down vote accepted

Something like this. matrix of nodes is used where a table style is defined then each node can have its own pattern given with coloring capability. A special pattern called mixed is defined as a macro taking two cell-position arguments

enter image description here


  matrix of nodes,
  row sep=-\pgflinewidth,
  column sep=-\pgflinewidth,
  nodes={draw,rectangle,text width=2cm,align=center},
  text depth=1.5ex,
  text height=4.5ex,
  nodes in empty cells

\foreach \i in {1,2,...,11}
\draw[] ([xshift=\i mm]mat-#1-#2.south west) -- ([xshift=\i mm]mat-#1-#2.north west);
\fill[pattern=horizontal lines]([xshift=11 mm]mat-#1-#2.south west)-- (mat-#1-#2.north east)--(mat-#1-#2.south east);
\fill[pattern=north east lines]([xshift=11 mm]mat-#1-#2.south west)-- (mat-#1-#2.north east) -- ([xshift=11 mm]mat-#1-#2.north west);


% the matrix entries
\matrix (mat) [table]
 \node[pattern=fivepointed stars,pattern color=green,]{};  &   & 
 \node[pattern=crosshatch dots,pattern color=red]{};       &  &  \\
   &   \node[pattern=dots,pattern color=blue]{};           &  &
  \node[pattern=north west lines,pattern color=red]{};  &        \\
   &   &\node[pattern=north east lines,pattern color=brown]{};  &  
      \node[pattern=horizontal lines]{}; &                       \\
   & \node[pattern=bricks,pattern color=red]{};  &  &
      \node[pattern=vertical lines,pattern color=red]{}; 
   &                                                             \\

share|improve this answer

You can do this easily enough with tikz/PGF. What I have drawn is a little squarer than your diagram but you can scale it if you wish (using, for example, \begin{tikzpicture}[xscale=1.2]).

enter image description here

Here's the latex code (the only slighty tricky bit is the triangle):



  \draw(0,0) grid (4,4);
  \filldraw[pattern=horizontal lines] (0,1) rectangle (1,2);
  \filldraw[pattern=vertical lines] (1,0) rectangle (1.25,1);
  \filldraw[pattern=vertical lines] (2,0) rectangle (3,1);
  \fill[pattern=horizontal lines](1.25,0)--(2,1)--(2,0);
  \fill[pattern=north east lines](1.25,0)--(2,1)--(1.25,1);
  \filldraw[pattern=north east lines](2,2)rectangle(3,3);


The grid spacing that I have used is the tikz default. If you need to change this to be more like your picture then have look at TikZ patterns with dimensions parameters.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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