[Tex/LaTex] Scan a cell of a table with lines

tables

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.

Thanks.

table

Best Answer

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

Code

\documentclass[border=10pt]{standalone}%{article}
\usepackage{tikz,siunitx}
\usetikzlibrary{matrix,positioning,calc}
\usetikzlibrary{patterns}
\tikzset{ 
table/.style={
  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
}
}

\newcommand{\mixed}[2]{
\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);
}

\begin{document}

\begin{tikzpicture}
% 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]{}; 
   &                                                             \\
};
\mixed{4}{1}
\mixed{3}{5}
\end{tikzpicture}

\end{document}
Related Question