答案1
以下是使用以下代码的提案这个很好的答案.可以设定蓝色人数。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{People}
\begin{tikzpicture}[pics/person/.style={code={%https://tex.stackexchange.com/a/84566/121799
\node[circle,fill,minimum size=5mm] (head) {};
\node[rounded corners=2pt,minimum height=1.3cm,minimum width=0.4cm,fill,below = 1pt of head] (body) {};
\draw[line width=1mm,Round Cap-Round Cap] ([shift={(2pt,-1pt)}]body.north east) --++(-90:6mm);
\draw[line width=1mm,Round Cap-Round Cap] ([shift={(-2pt,-1pt)}]body.north west)--++(-90:6mm);
\draw[thick,white,-Round Cap] (body.south) --++(90:5.5mm);}}]
\pgfmathsetmacro{\Zblue}{25}
\path foreach \X in {0,...,9}
{foreach \Y [evaluate=\Y as \Z using {int(\X-10*\Y)}] in {0,-1,-2,-3}
{\ifnum\Z<\Zblue
(\X,2*\Y) pic[blue]{person}
\else
(\X,2*\Y) pic[red]{person}
\fi}};
\end{tikzpicture}
\end{frame}
\end{document}
当然你也可以指定每行蓝色人物的数量。这些数字在 中指定\LstBlue
。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{People}
\begin{tikzpicture}[pics/person/.style={code={%https://tex.stackexchange.com/a/84566/121799
\node[circle,fill,minimum size=5mm] (head) {};
\node[rounded corners=2pt,minimum height=1.3cm,minimum width=0.4cm,fill,below = 1pt of head] (body) {};
\draw[line width=1mm,Round Cap-Round Cap] ([shift={(2pt,-1pt)}]body.north east) --++(-90:6mm);
\draw[line width=1mm,Round Cap-Round Cap] ([shift={(-2pt,-1pt)}]body.north west)--++(-90:6mm);
\draw[thick,white,-Round Cap] (body.south) --++(90:5.5mm);}}]
\def\LstBlue{8,7,5,1}
\path foreach \Y [evaluate=\Y as \Z using {{\LstBlue}[\Y]}] in {0,...,3}
{foreach \X in {0,...,9}
{\ifnum\X<\Z
(\X,-2*\Y) pic[blue]{person}
\else
(\X,-2*\Y) pic[red]{person}
\fi
}};
\end{tikzpicture}
\end{frame}
\end{document}
这是一个有 100 人的版本。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{People}
\hfill\begin{tikzpicture}[pics/person/.style={code={%https://tex.stackexchange.com/a/84566/121799
\node[circle,fill,minimum size=5mm] (head) {};
\node[rounded corners=2pt,minimum height=1.3cm,minimum width=0.4cm,fill,below = 1pt of head] (body) {};
\draw[line width=1mm,Round Cap-Round Cap] ([shift={(2pt,-1pt)}]body.north east) --++(-90:6mm);
\draw[line width=1mm,Round Cap-Round Cap] ([shift={(-2pt,-1pt)}]body.north west)--++(-90:6mm);
\draw[thick,white,-Round Cap] (body.south) --++(90:5.5mm);}},
xscale=0.7,yscale=0.4,transform shape] %<- scale down
\pgfmathsetmacro{\Zblue}{55}
\path foreach \X in {0,...,9}
{foreach \Y [evaluate=\Y as \Z using {int(\X+10*\Y)}] in {0,...,9}
{\ifnum\Z<\Zblue
(1.6*\X,-2*\Y) pic[blue]{person}
\else
(1.6*\X,-2*\Y) pic[red]{person}
\fi}};
\end{tikzpicture}\hfill\null
\end{frame}
\end{document}