Normally I try to have a skeleton at least before I ask a question, but this time I don't know where to begin, so my apologies for asking a cold question. I am trying to get parts of a rectangle hatched as shown in the figure below, but don't know how to begin. Any help would be much appreciated.
1 Answer
There are many ways to do this. For example draw overlapping rectangles and shade then appropriately:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=white, draw=black] (0,0) rectangle (8,1);
\filldraw[fill=green, draw=black] (0,0) rectangle (2,1);
\filldraw[fill=white, draw=black] (0,-2) rectangle (8,-1);
\filldraw[fill=green, draw=black] (0,-2) rectangle (2,-1);
\filldraw[fill=green, draw=black] (4,-2) rectangle (6,-1);
\end{tikzpicture}
\end{document}
If you are only going to draw simple rectangles then you can also try using tabular
along with cellcolor
command from xcolor
package. For example:
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{tabular}{*4{|p{2em}}|}
\hline
\cellcolor{green} & \multicolumn{3}{p{6em}|}{}\\
\hline
\multicolumn{4}{c}{} \\
\hline
\cellcolor{green} & & \cellcolor{green} & \\
\hline
\end{tabular}
\end{document}