和题主要求的不是特别相关,前几天正好学习了\tikzmath
的有关功能,也实现了九九乘法表...
下面是一个MWE的片段
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{pgffor}
\usetikzlibrary{math} % 感谢鱼香肉丝没有鱼先生
-------------------------------------------------------
\begin{tikzpicture}
\tikzmath{
function paint_rectangle(\x,\y){
int \i,\j,\k;
for \i in {1,...,\x}{
for \j in {1,...,\y}{
\k = \i * \j;
if \i <= \j then{
{
\node [rectangle,fill=green!30,draw=green!60,rounded corners] at (2.5*\i,\j) {\i $\times$ \j $=$ \k};
};
}else{
{
\node [rectangle,fill=violet!40,draw=violet!80,rounded corners] at (2.5*\i,\j) {$\j \times \i=\k$};
};
};
};
};
};
\A = 6;
\B = 15;
paint_rectangle(\A,\B);
}
\end{tikzpicture}
问 九九乘法表如何用宏编程实现不用宏包