1

I have made a 5 x 5 square checker pattern using the code below. How can I change it to 4 x 10 rectangular checker pattern?

\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture} \edef\size{4} \foreach \x in {0,...,\size} \foreach \y in {0,...,\size} { \pgfmathsetmacro{\colour}{(\x==\y || \x+\y==\size) ? "none" : "none"} \draw[fill=\colour] (\x,\y) rectangle ++ (1,1); } \end{tikzpicture}

\end{document}

Pankaj Singh
  • 107
  • 3
  • have a look here https://tex.stackexchange.com/questions/540338/increasing-thickness-of-borders-in-a-square-grid/540355? – Black Mild Dec 22 '20 at 08:54

2 Answers2

2

Here is one way.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\pagecolor{gray}
\begin{document}
\begin{tikzpicture}
\def\n{10} % number of columns 
\def\m{4}  % number of rows
\foreach \i in {1,...,\n}
\foreach \j in {1,...,\m}
{
\pgfmathparse{mod(\i+\n-\j,2) ? "red" : "white"}
\fill[\pgfmathresult] (\i,\j) rectangle +(1,1);
}
\end{tikzpicture}
\end{document}

And yet another way

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\pagecolor{lightgray}
\begin{document}
\begin{tikzpicture}
\fill[white] (0,0) rectangle (10,4);    
\foreach \i in {0,2,...,8} \foreach \j in {0,2}
\fill[orange] (\i,\j) rectangle +(1,1) (\i+1,1+\j) rectangle +(1,1);
\end{tikzpicture}
\end{document}
Black Mild
  • 17,569
1

So just change the values or am I missing something?

\foreach \x in {0,...,9} \foreach \y in {0,...,3}.

enter image description here

Roland
  • 6,655