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.



  • 1
    What do you mean by scan?
    – Bernard
    Jul 24, 2014 at 11:26
  • Maybe “fill” rather than ”scan”?
    – egreg
    Jul 24, 2014 at 12:47

2 Answers 2


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]{}; 
   &                                                             \\


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.

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.