我有一个网格。我想用一些线条填充一个单元格,如图所示。我有:
这是我迄今为止的代码:
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (0,0) grid (4,4);
\draw[step=2cm,very thick] (0,0) grid (4,4);
\draw[red, very thick] (0,2.3) rectangle (1.5,4);
\end{tikzpicture}
\end{document}
答案1
像这样?
该patterns
库提供了许多这样的模式。
\documentclass[border=5pt,multi,tikz]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (0,0) grid (4,4);
\draw[step=2cm,very thick] (0,0) grid (4,4);
\draw[red, very thick, pattern=north east lines] (0,2.3) rectangle (1.5,4);
\end{tikzpicture}
\end{document}