How do I do an inline if-else statement?
\draw[draw = #1, fill = \if black#1 white \else black \fi, line width = 0.1mm]
(#2, #3) circle [radius = 0.25cm];
I've tried to do it based on this answer, for example, but with no success:
\begingroup
\def\color{#1}
\def\black{black}
\draw[draw = #1, fill = \ifx\color\black white \else black \fi, line width = 0.1mm]
(#2, #3) circle [radius = 0.25cm]; % chktex 1
\endgroup
I did try many other methods but none seem to work.
Here is a minimal complete example:
\documentclass{article}
\usepackage{tikz}
% Parameters
%
% 1: dimension (in cm)
% 2: board size (square)
%
% Example: A 19x19 board with size 10cm x 10cm: `\gogrid{10}{19}'
\newcommand{\goGrid}[2]{
\pgfmathsetmacro{\step}{#1 / (#2 - 1)} % chktex 1
\draw[step=\step] (0, 0) grid (#1, #1);
}
\newcommand{\drawStone}[3]{
\draw[draw = #1, fill = \if black#1 white \else black \fi, line width = 0.1mm]
(#2, #3) circle [radius = 0.25cm];
}
\begin{document}
\begin{tikzpicture}
\goGrid{10}{19}
\drawStone{white}{2 * 10cm / 18}{3 * 10cm / 18}
\end{tikzpicture}
\end{document}
(Why are there dozens of ways of doing if statements in TeX but all of them seem super finicky? T.T)

\if blis comparingbandlso is always false – David Carlisle Feb 06 '24 at 14:29\def\color{#1}... would have worked but don't use\coloror you will disable latex color support. also don't use\beingrouparound the\draw– David Carlisle Feb 06 '24 at 14:33