答案1
你可以用 tikz 来做。请参阅\pyrdot
命令定义中的注释。
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\pyrdot}[1]{
% you can tune the size of the pyramid using the scale option
\begin{tikzpicture}[scale=.4]
\pgfmathsetmacro{\n}{#1} % define \n, the number of rows
\edef\m{0} % define \m, the total number of circles
\foreach \i in {1, ..., \n} { % vertical loop
\foreach \k in {1, ..., \i} { % horizontal loop
\fill ($(\k,-\i)+(-.5*\i,0)$) circle (4mm); % draw the circle (size = 4mm, shifted to the left)
\pgfmathparse{int(\m+1)} % increment \m
\xdef\m{\pgfmathresult}
}
}
% put the text below the pyramid
\node[anchor=north] at (current bounding box.south) {$T_{\n}=\m$};
\end{tikzpicture}
}
\begin{document}
\section{pyramidical dots}
\pyrdot{1}
\pyrdot{2}
\pyrdot{3}
\pyrdot{4}
\pyrdot{5}
\pyrdot{6}
\end{document}