答案1
它可能做得更容易,但这也可能有效:
\documentclass[border=1mm, tikz]{standalone}
% helper macro to split a string in to a comma separated list
\makeatletter
\newcommand{\makenumlist}[2]{%
\def\splitnums##1##2\relax{%
\edef#1{##1}%
\@tfor\next:=##2\do{\edef#1{#1,\next}}%
}%
\splitnums#2\relax%
}
\makeatother
\newcounter{umbrellatip}
\newcommand{\umbrellamultiply}[2]{%
\makenumlist{\firstfactornum}{#1}%
\makenumlist{\secondfactornum}{#2}%
\begin{tikzpicture}[font=\large]
\setcounter{umbrellatip}{0}
\foreach \n [count=\i] in \firstfactornum {
\node (t\i) at (\i,0) {\n};
\setcounter{umbrellatip}{\i}
}
\stepcounter{umbrellatip}
\node (t\theumbrellatip) at (\theumbrellatip,0) {$\times$};
\stepcounter{umbrellatip}
\foreach \n [count=\i start from \theumbrellatip] in \secondfactornum {
\node (t\i) at (\i,0) {\n};
\setcounter{umbrellatip}{\i}
}
\foreach \t [count=\u start from 1] in {2,...,\theumbrellatip} {
\draw (t\u.north) to[out=60, in=120] (t\t.north);
}
\draw (t1.north) to[out=60, in=120] coordinate (m) (t\theumbrellatip.north);
\draw (m) -- (m |- 0,-20pt) arc (360:150:5pt);
\end{tikzpicture}%
}
\begin{document}
\umbrellamultiply{96}{47}
\umbrellamultiply{464}{123}
\end{document}
更新:加排骨
\documentclass[border=1mm, tikz]{standalone}
% helper macro to split a string in to a comma separated list
\makeatletter
\newcommand{\makenumlist}[2]{%
\def\splitnums##1##2\relax{%
\edef#1{##1}%
\@tfor\next:=##2\do{\edef#1{#1,\next}}%
}%
\splitnums#2\relax%
}
\makeatother
\newcounter{umbrellatip}
\newcommand{\umbrellamultiply}[2]{%
\makenumlist{\firstfactornum}{#1}%
\makenumlist{\secondfactornum}{#2}%
\begin{tikzpicture}[font=\large]
\setcounter{umbrellatip}{0}
\foreach \n [count=\i] in \firstfactornum {
\node (t\i) at (\i,0) {\n};
\setcounter{umbrellatip}{\i}
}
\stepcounter{umbrellatip}
\node (t\theumbrellatip) at (\theumbrellatip,0) {$\times$};
\stepcounter{umbrellatip}
\foreach \n [count=\i start from \theumbrellatip] in \secondfactornum {
\node (t\i) at (\i,0) {\n};
\setcounter{umbrellatip}{\i}
}
\foreach \t [count=\u start from 1] in {2,...,\theumbrellatip} {
\draw (t\u.north) to[out=60, in=120] (t\t.north);
}
\draw (t1.north) to[out=60, in=120] coordinate (m) (t\theumbrellatip.north);
\foreach \t [count=\v start from 2] in {3,...,\theumbrellatip} {
\pgfmathtruncatemacro{\currenttip}{\v<(\theumbrellatip+1)/2 ? -1 : (\v>(\theumbrellatip+1)/2 ? 1 : 0)}
\ifnum\currenttip>0\relax
\draw (t\v.north) to[bend right] (m);
\else
\ifnum\currenttip<0\relax
\draw (t\v.north) to[bend left] (m);
\fi
\fi
}
\draw (m) -- (m |- 0,-20pt) arc (360:150:5pt);
\end{tikzpicture}%
}
\begin{document}
\umbrellamultiply{96}{47}
\umbrellamultiply{464}{13}
\end{document}