答案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}