The white/black board can be drawn by testing the parity of node positions as follows:
\documentclass[tikz]{standalone}
\usepackage{xifthen}
\begin{document}
\begin{tikzpicture}[every node/.style = {draw, circle, minimum size = 10pt}]
\foreach \r in {1, ..., 4} {
\foreach \c in {1, ..., 5} {
\pgfmathparse{mod(\r + \c, 2)}
\let\parity\pgfmathresult
\ifthenelse{\equal{\parity}{0.0}}
{\node (\r\c) [fill = lightgray] at (\c, \r){}}
{\node (\r\c) at (\c, \r){}};
}
}
\end{tikzpicture}
\end{document}
However, using isodd of xifthen does not produce the same result. What is wrong here? Or are there any alternative similar solutions?
\documentclass[tikz]{standalone}
\usepackage{xifthen}
\begin{document}
\begin{tikzpicture}[every node/.style = {draw, circle, minimum size = 10pt}]
\foreach \r in {1, ..., 4} {
\foreach \c in {1, ..., 5} {
\ifthenelse{\NOT \isodd{\r + \c}}
{\node (\r\c) [fill = lightgray] at (\c, \r){}}
{\node (\r\c) at (\c, \r){}};
}
}
\end{tikzpicture}
\end{document}





\ifoddinstead of\ifthenelsefromxifthen? See Why is theifthenpackage obsolete? – Werner Dec 27 '18 at 06:31