summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-07 22:29:40 +0000
committerKarl Berry <karl@freefriends.org>2022-01-07 22:29:40 +0000
commitdb5f35c7db6319d4ca6369052b1a492c8729bfc7 (patch)
tree75c6f8e3f40f7393bfdecbb68e4d15d6ac254d03
parent9977ee10493897ac7eb7e02d347eb83e70cdc4e0 (diff)
pascaltriangle (7jan22)
git-svn-id: svn://tug.org/texlive/trunk@61523 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/pascaltriangle/README.md56
-rwxr-xr-xMaster/texmf-dist/doc/latex/pascaltriangle/build.sh8
-rw-r--r--Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.pdfbin0 -> 165670 bytes
-rw-r--r--Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.tex389
-rw-r--r--Master/texmf-dist/tex/latex/pascaltriangle/pascaltriangle.sty397
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rw-r--r--Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/pascaltriangle.tlpsrc0
8 files changed, 852 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/pascaltriangle/README.md b/Master/texmf-dist/doc/latex/pascaltriangle/README.md
new file mode 100644
index 00000000000..495ca2b9854
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pascaltriangle/README.md
@@ -0,0 +1,56 @@
+Pascal triangles(Yanghui triangles) generator package based on TikZ developed with LaTeX3.
+=======
+
+`pascaltriangle` is a Pascal triangle(Yanghui triangle) generation package based on TikZ developed with LaTeX3, which provides a unique drawing macro `\pascal` and can generate isosceles or right-angle triangles with different macro options or `\pascalset` macro.
+
+You can read the manual (in Chinese/English) for more details and examples.
+
+Contributing
+------------
+
+1. github repository:
+ 1. repository: [pascaltriangle](https://github.com/registor/pascaltriangle)
+ 2. Issues and pull requests are welcome. [issue](https://github.com/registor/pascaltriangle/issues) or [pull request](https://github.com/registor/pascaltriangle/pulls).
+
+2. gitee repository:
+ 1. repository: [pascaltriangle](https://gitee.com/nwafu_nan/pascaltriangle)
+ 2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/pascaltriangle/issues) or [pull request](https://gitee.com/nwafu_nan/pascaltriangle/pulls).
+
+基于TikZ用LaTeX3开发的Pascal三角形(杨辉三角形)生成宏包
+=======
+
+`pascaltriangle`一个基于TikZ用LaTeX3开发的Pascal三角形(杨辉三角形)生成宏包,它提供了一个唯一的绘图命令`\pascal`,并可以通过不同命令的命令选项或`\pascalset`命令的设置生成等腰或直角Pascal三角形(杨辉三角形)。
+
+可以通过阅读宏包手册(中文/英文)以也解该宏包更多的使用细节和使用样例。
+
+### 参与贡献
+---------------------
+
+1. github仓库:
+ (1). 仓库地址: [pascaltriangle](https://github.com/registor/pascaltriangle)
+ (2). Issues和PR: [issue](https://github.com/registor/pascaltriangle/issues) or [pull request](https://github.com/registor/pascaltriangle/pulls).
+
+2. gitee仓库:
+ (1). 仓库地址: [pascaltriangle](https://gitee.com/nwafu_nan/pascaltriangle)
+ (2). Issues and PR: [issue](https://gitee.com/nwafu_nan/pascaltriangle/issues) or [pull request](https://gitee.com/nwafu_nan/pascaltriangle/pulls).
+
+Copyright and Licence
+---------------------
+
+ Copyright (C) 2020-2022 by Nan Geng <nangeng@nwafu.edu.cn>
+ ----------------------------------------------------------------------
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c of this license or (at your option) any later
+ version. This version of this license is in
+ http://www.latex-project.org/lppl/lppl-1-3c.txt
+ and the latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of
+ LaTeX version 2005/12/01 or later.
+
+ This work has the LPPL maintenance status "maintained".
+
+ The Current Maintainer of this work is Nan Geng.
+
diff --git a/Master/texmf-dist/doc/latex/pascaltriangle/build.sh b/Master/texmf-dist/doc/latex/pascaltriangle/build.sh
new file mode 100755
index 00000000000..bd7c2c5aa36
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pascaltriangle/build.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+xelatex pascaltriangle.tex &&\
+makeindex -s gind.ist -o pascaltriangle.ind pascaltriangle.idx &&\
+makeindex -s gglo.ist -o pascaltriangle.gls pascaltriangle.glo &&\
+xelatex pascaltriangle.tex &&\
+xelatex pascaltriangle.tex &&\
+xelatex pascaltriangle.tex
diff --git a/Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.pdf b/Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.pdf
new file mode 100644
index 00000000000..961e826e40c
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.tex b/Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.tex
new file mode 100644
index 00000000000..ff9536f62fa
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pascaltriangle/pascaltriangle.tex
@@ -0,0 +1,389 @@
+\documentclass[full]{l3doc}
+\usepackage[scheme=plain]{ctex}
+\usepackage{enumitem}
+\usepackage{indentfirst}
+\usepackage{titling}
+\usepackage{geometry}
+\usepackage{fancyvrb-ex}
+\usepackage{pascaltriangle}
+
+\IndexPrologue
+ {
+ \section*{Index}
+ \markboth{Index}{Index}
+ \addcontentsline{toc}{section}{Index}
+ The~italic~numbers~denote~the~pages~where~the~
+ corresponding~entry~is~described,~
+ numbers~underlined~point~to~the~definition,~
+ all~others~indicate~the~places~where~it~is~used.
+ }
+
+\newcommand\tikzmark[1]{\tikz \coordinate[overlay, remember picture] (#1);}
+
+\geometry{
+ left=4.5cm,
+ right=2cm,
+ top=2cm,
+ bottom=2cm,
+}
+\hypersetup {
+ CJKbookmarks,
+ bookmarksopen,
+ bookmarksopenlevel=3,
+ pdfstartview=FitH,
+ pdfinfo = {
+ Title = The package pascaltriangle ,
+ Subject = A LaTeX3 package ,
+ Author = Geng Nan
+ }
+}
+
+\DoNotIndex{\begin, \end}
+\setlength{\parskip}{\medskipamount}
+\DeclareDocumentEnvironment { noteen } { +b } {
+ \par\textbf{\textsf{NOTE:~}}#1\par
+} {}
+\DeclareDocumentEnvironment { notezh } { +b } {
+ \par\textbf{\textsf{注意:~}}#1\par
+} {}
+
+\AtEndDocument{
+ \newgeometry{
+ left=2cm,
+ right=2cm,
+ top=2cm,
+ bottom=2cm
+ }
+ \PrintIndex
+}
+
+\ExplSyntaxOn
+\dim_new:N \l__my_syntax_dim
+\box_new:N \g__my_syntax_box
+\NewDocumentEnvironment { Syntax } { s }
+ {
+ \dim_set:Nn \l__my_syntax_dim
+ { \textwidth }
+ \hbox_gset:Nw \g__my_syntax_box
+ \small \ttfamily
+ \begin{minipage}[t]{\l__my_syntax_dim}
+ \raggedright\obeyspaces\obeylines
+ }
+ {
+ \end{minipage}
+ \hbox_gset_end:
+ \IfValueF { #1 } { \smallskip }
+ \box_use_drop:N \g__my_syntax_box
+ \smallskip
+ }
+
+\DeclareDocumentEnvironment { Description } { o +b } {
+ \hbox_set:Nn \l_tmpa_box { #1 }
+ \dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box }
+ \begin{itemize}[labelwidth=\l_tmpa_dim, align=left]
+ #2
+ \end{itemize}
+} { }
+
+\keys_define:nn { pascal/doc } {
+ opt .tl_set:N = \l_opt_tl,
+ desc .tl_set:N = \l_desc_tl,
+ init .tl_set:N = \l_init_tl,
+ init .initial:n = init-none,
+}
+
+\box_new:N \l__option_box
+\NewDocumentEnvironment { option } { m +b } {
+ \keys_set:nn { pascal/doc } { #1 }
+ \hbox_set:Nw \l__option_box
+ \small \ttfamily
+ \begin{minipage}[t]{\textwidth}
+ \obeyspaces\obeylines
+ \textcolor{red}{
+ \l_opt_tl
+ \exp_args:Nx\SpecialOptionIndex{\l_opt_tl}
+ }
+ {~}\l_desc_tl
+ \hfill(
+ \tl_if_eq:NnTF \l_init_tl { init-none } { no~value }
+ { initially~\texttt{\l_init_tl} }
+ )
+ \end{minipage}
+ \hbox_gset_end:
+ \box_use_drop:N \l__option_box
+ #2
+ \medskip
+} { }
+
+\DeclareDocumentCommand \opt { O{} m }
+ { \__codedoc_cmd:no {#1} { #2 } }
+\ExplSyntaxOff
+
+\def\vers{\texttt{v1.0.0}
+\thanks{\url{https://github.com/registor/pascaltriangle}}
+\thanks{\url{https://gitee.com/nwafu_nan/pascaltriangle}}
+}
+
+\begin{document}
+\title{
+ \pkg{pascaltriangle} 宏包
+ \rlap{\makebox[4cm][r]{
+ \normalsize $\Longrightarrow$ \color{red}
+ \protect\hyperlink{en}{English Version}
+ \protect\hypertarget{zh}{}
+ }}
+}
+\author{\textit{耿楠} \texttt{<nangeng@nwafu.edu.cn>}}
+\date{\the\year 年\the\month 月\the\day 日\qquad \vers
+}
+\maketitle
+
+{\small
+\tableofcontents
+}
+\newpage
+
+\begin{documentation}
+
+\section{引言}
+\pkg{pascaltriangle}是一个基于\pkg{TikZ}用\pkg{expl3}开发的
+Pascal三角形(杨辉三角形)生成宏包,它提供了一个唯一的绘图命令
+\tn{pascal},并可以通过不同命令的命令选项或\tn{pascalset}命令
+设置生成不同外观的等腰或直角Pascal三角形。
+
+\section{用户接口}
+
+\subsection{\cs{pascal}绘图命令}
+
+\begin{function}{\pascal}
+ \begin{syntax}
+ \cs{pascal} \oarg{外观选项} \marg{层数}
+ \end{syntax}
+
+\end{function}
+
+ 用于绘制一个Pascal三角形。
+
+ 该命令仅有一个必选参数\marg{层数},用于指定Pascal三角形的层数。
+
+ 在\oarg{外观选项}中可以通过key-value方式设置三角形形状、大小等外观。
+
+ 三角形的外观也可以通过\cs{pascalset}命令的逗号分隔key-value列表进行设置
+
+\subsection{\cs{pascalset}}
+\begin{function}{\pascalset}
+ \begin{syntax}
+ \cs{pascalset} \marg{外观选项}
+ \end{syntax}
+
+\end{function}
+
+ 用于设置一个Pascal三角形的外观。
+
+ 在\marg{外观选项}中可以通过key-value方式设置三角形形状、大小等外观。
+
+\section{外观选项}
+
+\begin{option}{ opt = shape, desc = {= \meta{形状}}, init=iso }
+ 设置Pascal三角形的形状,目前支持|iso|---等腰三角形和
+ |rt|---直角三角形。
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
+ \centering
+ \pascal{5}\qquad
+ \pascal[shape=rt]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{ opt = radius, desc = {= \meta{半径}}, init=0.5cm }
+ 设置三角形每个单元外接圆半径,注意需要带有单位。
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
+ \centering
+ \pascal[radius=0.8cm]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{ opt = fontsize, desc = {= \meta{字号命令}}, init=\cs{small} }
+ 设置三角形每个单元中数字文本大小。
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
+ \centering
+ \pascal[radius=0.8cm,
+ fontsize=\Huge]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{opt=withnum, desc={= \meta{布尔值}}, init=false}
+ 设置是否显示Pascal三角形的行列编号。
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
+ \centering
+ \pascal[withnum]{4}
+ \pascal[withnum,shape=rt]{4}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{opt = binom, desc = {= \meta{布尔值}}, init=false}
+ 设置是否显示用二项式表达式显示各元素值。
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
+ \centering
+ \pascal[binom]{5}
+ \pascal[binom,shape=rt]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{ opt = fillr, desc = {= \meta{整数}}, init=1 }
+ 设置需要表示前列累加的单元格行号,注意行号是当前列自顶向下从0开始计数。
+\end{option}
+
+\begin{option}{ opt = fillc, desc = {= \meta{整数}}, init=1 }
+ 设置需要表示前列累加的单元格列号,注意列号是自左向右从0开始计数。
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.64\linewidth,gobble=2]
+ \centering
+ \pascalset{fillr=2,fillc=6,
+ radius=0.4cm}
+ \pascal{10}\\
+ \pascal[shape=rt]{10}
+\end{SideBySideExample}
+
+\bigskip
+
+\title{
+ Package \pkg{pascaltriangle}
+ \rlap{\makebox[4cm][r]{
+ \normalsize $\Longrightarrow$ \color{red}
+ \protect\hyperlink{zh}{中文版本}
+ \protect\hypertarget{en}{}
+ }}
+}
+\author{Nan Geng \texttt{<nangeng@nwafu.edu.cn>}}
+\date{\today\qquad \vers}
+\maketitle
+
+\section{Introduction}
+
+\pkg{pascaltriangle} is a Pascal triangle(Yanghui triangle) generation package
+based on TikZ developed in expl3, which provides a unique drawing command \cs{pascal},
+and can be set by different options or \cs{pascalset} macro to
+generates isosceles or right-angle Pascal triangles with different appearances.
+
+\section{Interfaces}
+
+\subsection{\cs{pascal} macro}
+
+\begin{function}{\pascal}
+ \begin{syntax}
+ \cs{pascal} \oarg{options} \marg{order}
+ \end{syntax}
+\end{function}
+Used to draw a Pascal triangle.
+
+This macro has only one mandatory parameter \marg{order},
+which specifies the number of layers of the Pascal triangle.
+
+In \oarg{options} you can set the appearance of the triangle shape,
+size, etc. by key-value method.
+
+The appearance of the triangle can also be set via the comma-separated
+key-value list of the \cs{pascalset} macro
+
+\subsection{\cs{pascalset} macro}
+
+\begin{function}{\pascalset}
+ \begin{syntax}
+ \cs{pascalset} \marg{options}
+ \end{syntax}
+\end{function}
+
+Used to set the appearance of Pascal triangle.
+
+In \oarg{options} you can set the appearance of the triangle shape,
+size, etc. by key-value method.
+
+\section{options}
+
+\begin{option}{ opt = shape, desc = {= \meta{shape}}, init=iso }
+ Sets the shape of Pascal triangle
+ currently supporting |iso|---isosceles triangles and |rt|---right-angle triangles.
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
+ \centering
+ \pascal{5}\qquad
+ \pascal[shape=rt]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{ opt = radius, desc = {= \meta{radius}}, init=0.5cm }
+ Set the radius of the outer circle of each cell of the triangle,
+ note that it needs to have units.
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
+ \centering
+ \pascal[radius=0.8cm]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{ opt = fontsize, desc = {= \meta{fontsize}}, init=\cs{small} }
+ Sets the fontsize of each cell of the triangle.
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
+ \centering
+ \pascal[radius=0.8cm,
+ fontsize=\Huge]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{opt=withnum, desc={= \meta{bool}}, init=false}
+ Sets whether to show the Pascal triangle row/col numbers or not.
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
+ \centering
+ \pascal[withnum]{4}
+ \pascal[withnum,shape=rt]{4}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{opt = binom, desc = {= \meta{bool}}, init=false}
+ Sets whether to show each element value with binomial expressions or not.
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
+ \centering
+ \pascal[binom]{5}
+ \pascal[binom,shape=rt]{5}
+\end{SideBySideExample}
+
+\bigskip
+
+\begin{option}{ opt = fillr, desc = {= \meta{integer}}, init=1 }
+ Set the row number of the cell that needs to indicate the sum of the pre-column,
+ note that the row number is in the current column counted from the top down based 0.
+\end{option}
+
+\begin{option}{ opt = fillc, desc = {= \meta{integer}}, init=1 }
+ Set the col number of the cell that needs to indicate the sum of the pre-column,
+ note that the col number is counted from the left to right based 0.
+\end{option}\\
+\begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.64\linewidth,gobble=2]
+ \centering
+ \pascalset{fillr=2,fillc=6,
+ radius=0.4cm}
+ \pascal{10}\\
+ \pascal[shape=rt]{10}
+\end{SideBySideExample}
+
+\end{documentation}
+
+
+\end{document}
diff --git a/Master/texmf-dist/tex/latex/pascaltriangle/pascaltriangle.sty b/Master/texmf-dist/tex/latex/pascaltriangle/pascaltriangle.sty
new file mode 100644
index 00000000000..6c4be46ac37
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/pascaltriangle/pascaltriangle.sty
@@ -0,0 +1,397 @@
+%%% ----------------------------------------------------------------------------
+%%% pascaltriangle: Typeset Pascal triangle figure with LaTeX3
+%%% Author : Nan Geng <nangeng@nwafu.edu.cn>
+%%% Repository: https://github.com/registor/pascaltriangle or https://gitee.com/nwafu_nan/pascaltriangle
+%%% License : The LaTeX Project Public License 1.3c
+%%% ----------------------------------------------------------------------------
+
+\NeedsTeXFormat{LaTeX2e}
+\RequirePackage{expl3}
+\ProvidesExplPackage{pascaltriangle}{2022-01-07}{v1.0.0}
+ {Typeset Pascal triangle figure with LaTeX3}
+
+\RequirePackage{xparse}
+
+%% \tl_if_eq:NnTF 与texlive 2020的兼容性设置
+\cs_if_exist:NF \tl_if_eq:NnTF
+ {
+ \tl_new:N \l__tblr_backport_b_tl
+ \prg_new_protected_conditional:Npnn \tl_if_eq:Nn #1 #2 { T, F, TF }
+ {
+ \group_begin:
+ \tl_set:Nn \l__tblr_backport_b_tl {#2}
+ \exp_after:wN
+ \group_end:
+ \if_meaning:w #1 \l__tblr_backport_b_tl
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+ \prg_generate_conditional_variant:Nnn \tl_if_eq:Nn { c } { TF, T, F }
+ }
+
+\cs_if_exist:NF \seq_map_indexed_function:NN
+ {
+ \cs_set_eq:NN \seq_map_indexed_function:NN \seq_indexed_map_function:NN
+ }
+
+%% 解决TikZ库无法在Expl3中载入问题
+\RequirePackage {amsmath, tikz, etoolbox}
+\ExplSyntaxOff
+\patchcmd
+{\tcb@input@library@in}
+ {%
+ \input\tcbpkgprefix#1\relax%
+ }
+ {%
+ \@pushfilename
+ \input\tcbpkgprefix#1\relax%
+ \@popfilename
+ }
+ {}{}
+
+\patchcmd
+{\pgfutil@InputIfFileExists}
+ {\input #1}
+ {%
+ \@pushfilename
+ \xdef\@currname{#1}%
+ \input #1 %
+ \@popfilename
+ }
+ {}{}
+\ExplSyntaxOn
+\usetikzlibrary{shapes.geometric}
+
+%% 定义变量
+\bool_new:N \l__pascal_num_cell_bool % 是否绘制行列号
+\bool_new:N \l__pascal_binom_cell_bool % 是否仅绘制二项式表达式
+
+\tl_new:N \l__pascal_cell_color_tl % 单元格填充颜色
+\tl_new:N \l__pascal_shift_col_pt_tl % 列变换坐标
+\tl_new:N \l__pascal_shift_row_pt_tl % 行变换坐标
+\tl_new:N \l__pascal_font_size_tl % 文件大小
+
+\int_new:N \l__pascal_shape_type_int % 形状(1---等腰,2---直角)
+\int_new:N \l__pascal_row_idx_int % 行索引(从0计数)
+\int_new:N \l__pascal_col_idx_int % 列索引(从0计数)
+\int_new:N \l__pascal_row_top_int % 各列最大行数
+\int_new:N \l__pascal_total_idx_int % 索引总数
+\int_new:N \l__pascal_fill_row_int % 填充行号(最大值与当前列数有关,从顶向下从0计数)
+\int_new:N \l__pascal_fill_col_int % 填充列号(从0计数)
+
+\dim_new:N \l__pascal_cell_radius_dim % 单元格大小(中心到顶点的半径)
+
+%% 选项设计
+\keys_define:nn { pascal }
+ {
+ % 是否需要行列编号
+ withnum .bool_set:N = \l__pascal_num_cell_bool,
+ withnum .default:n = true,
+ withnum .initial:n = false,
+
+ % 是否仅绘制二项式表达式
+ binom .bool_set:N = \l__pascal_binom_cell_bool,
+ binom .default:n = true,
+ binom .initial:n = false,
+
+ % 形状选择(iso---等腰三角形, rt---直角三角形)
+ shape .choice:,
+ shape .value_required:n = true,
+ shape .choices:nn =
+ { iso, rt }
+ { \int_set_eq:NN \l__pascal_shape_type_int \l_keys_choice_int },
+ shape .initial:n = iso,
+
+ % 单元格半径(中心到顶点)
+ radius .dim_set:N = \l__pascal_cell_radius_dim,
+ radius .initial:n = 0.5cm,
+
+ % 文字大小
+ fontsize .tl_set:N = \l__pascal_font_size_tl,
+ fontsize .initial:n = \small,
+
+ % 要填充单元格行数(按列从顶向下,从0开始计数)
+ fillr .int_set:N = \l__pascal_fill_row_int,
+ fillr .initial:n = 1 ,
+ % 要填充单元格列数(从左向右,从0开始计数)
+ fillc .int_set:N = \l__pascal_fill_col_int,
+ fillc .initial:n = 1 ,
+ fillrc .meta:n = { fillr = #1 , fillc = #1 },
+
+ unknown .code:n = { \__pascal_error:n { unknown-option } }
+ }
+
+\msg_new:nnn { pascal } { unknown-option }
+ { package~ option~ "\l_keys_key_tl"~ is~ unknown. }
+
+%% 参数设置用户接口
+\NewDocumentCommand \pascalset { m }
+ { \keys_set:nn { pascal } {#1} }
+
+%% 利用LaTeX3的fact阶乘计算函数计算组合数
+\cs_set:Npn \__pascal_binomcoeff:nn #1#2
+ {
+ \fp_eval:n { fact(#1) / (fact(#2) * fact(#1 - #2)) }
+ }
+
+%% 组合数计算用户接口
+\NewDocumentCommand{\binomc}{m m}
+ {
+ \__pascal_binomcoeff:nn{#1}{#2}
+ }
+
+%% 绘制Pascal三角形
+%% 注意":"无法使用造成极坐标不能用的问题,以下网站给出了解决方案
+%% https://tex.stackexchange.com/questions/501333/how-to-use-colon-as-part-of-tikz-syntax-while-in-explsyntaxon-environment
+%% 将":"用\c_colon_str代替
+
+%% 根据形状类型计算列变换坐标(极坐标)
+\cs_set:Npn \__pascal_shift_col_pt:n #1
+ {
+ \int_case:nn { \l__pascal_shape_type_int }
+ {
+ {1}{
+ \tl_set:Nn \l__pascal_shift_col_pt_tl { -60 \c_colon_str
+ \fp_eval:n {sqrt(3) * \l__pascal_cell_radius_dim * #1}pt
+ }
+ }
+ {2}{
+ \tl_set:Nn \l__pascal_shift_col_pt_tl { -45 \c_colon_str
+ \fp_eval:n {2 * \l__pascal_cell_radius_dim * #1}pt
+ }
+ }
+ }
+ }
+
+%% 根据形状类型计算行变换坐标(极坐标)
+\cs_set:Npn \__pascal_shift_row_pt:n #1
+ {
+ \int_case:nn { \l__pascal_shape_type_int }
+ {
+ {1}{
+ \tl_set:Nn \l__pascal_shift_row_pt_tl { -120 \c_colon_str
+ \fp_eval:n {sqrt(3) * \l__pascal_cell_radius_dim * #1}pt
+ }
+ }
+ {2}{
+ \tl_set:Nn \l__pascal_shift_row_pt_tl { -90 \c_colon_str
+ \fp_eval:n {sqrt(2) * \l__pascal_cell_radius_dim * #1}pt
+ }
+ }
+ }
+ }
+
+%% 正六边形闭合路径代码
+\cs_set:Npn \__pascal_hex_cell:
+ {
+ (30 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (90 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (150 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (210 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (270 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (330 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ cycle (90 \c_colon_str 0)
+ }
+
+%% 正方形闭合路径代码
+\cs_set:Npn \__pascal_square_cell:
+ {
+ (45 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (134 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (225 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ (-45 \c_colon_str \fp_eval:n{\l__pascal_cell_radius_dim}pt) --
+ cycle (90 \c_colon_str 0)
+ }
+
+%% 绘制行列编号标记单元格
+\cs_set:Npn \__pascal_num_draw:nnn #1#2#3
+ {
+ \int_case:nn { \l__pascal_shape_type_int }
+ {
+ {1}{% 正六边形
+ \int_compare:nNnT { #1 } = {0}% 最左列
+ {
+ \int_compare:nNnT { #2 } = { #3 - 1 }% 最底行
+ {
+ \begin{scope}[shift={(-150\c_colon_str {\fp_eval:n{3*\l__pascal_cell_radius_dim}pt})}]
+ \draw[dashed, top~color=gray!10,bottom~color=gray!20]
+ \__pascal_hex_cell:
+ node[rotate=-45] {$m,n$};
+ \end{scope}
+ }
+ }
+ \int_compare:nNnT { #1 } = { 0 }% 最左列
+ {
+ \begin{scope}[shift={(-180\c_colon_str {\fp_eval:n{sqrt(3)*\l__pascal_cell_radius_dim}pt})}]
+ \draw[dashed, top~color=gray!10,bottom~color=gray!20]
+ \__pascal_hex_cell:
+ node{$(\int_eval:n {#2})$};
+ \end{scope}
+ }
+ \int_compare:nNnT { #2 } = { #3 - 1 }% 最底行
+ {
+ \begin{scope}[shift={(-120\c_colon_str {\fp_eval:n{sqrt(3)*\l__pascal_cell_radius_dim}pt})}]
+ \draw[dashed, top~color=gray!10,bottom~color=gray!20]
+ \__pascal_hex_cell:
+ node {$(\int_eval:n {#1})$};
+ \end{scope}
+ }
+ }
+ {2}{% 正方形
+ \int_compare:nNnT { #1 } = {0}% 最左列
+ {
+ \int_compare:nNnT { #2 } = { #3 - 1 }% 最底行
+ {
+ \begin{scope}[shift={(-135\c_colon_str {\fp_eval:n{2*\l__pascal_cell_radius_dim}pt})}]
+ \draw[dashed, top~color=gray!10,bottom~color=gray!20]
+ \__pascal_square_cell:
+ node[scale=0.8,rotate=-45] {$m,n$};
+ \end{scope}
+ }
+ }
+ \int_compare:nNnT { #1 } = { 0 }% 最左列
+ {
+ \begin{scope}[shift={(-180\c_colon_str {\fp_eval:n{sqrt(2)*\l__pascal_cell_radius_dim}pt})}]
+ \draw[dashed, top~color=gray!10,bottom~color=gray!20]
+ \__pascal_square_cell:
+ node{$(\int_eval:n {#2})$};
+ \end{scope}
+ }
+ \int_compare:nNnT { #2 } = { #3 - 1 }% 最底行
+ {
+ \begin{scope}[shift={(-90\c_colon_str {\fp_eval:n{sqrt(2)*\l__pascal_cell_radius_dim}pt})}]
+ \draw[dashed, top~color=gray!10,bottom~color=gray!20]
+ \__pascal_square_cell:
+ node {$(\int_eval:n {#1})$};
+ \end{scope}
+ }
+ }
+ }
+ }
+
+%% 绘制三角形单元格
+\cs_set:Npn \__pascal_cell_draw:nn #1#2
+ {
+ \int_case:nn { \l__pascal_shape_type_int }
+ {
+ {1}{% 正六边形
+ \draw[top~color=\l__pascal_cell_color_tl!20,bottom~color=\l__pascal_cell_color_tl!60]
+ \__pascal_hex_cell:
+ \bool_if:NTF \l__pascal_binom_cell_bool
+ {
+ node {$\binom{\int_eval:n {#1}}{\int_eval:n {#2}}$};
+ }
+ {
+ node {$\__pascal_binomcoeff:nn {#1}{#2}$};
+ }
+ }
+ {2}{% 正方形
+ \draw[top~color=\l__pascal_cell_color_tl!20,bottom~color=\l__pascal_cell_color_tl!60]
+ \__pascal_square_cell:
+ \bool_if:NTF \l__pascal_binom_cell_bool
+ {
+ node {$\binom{\int_eval:n {#1}}{\int_eval:n {#2}}$};
+ }
+ {
+ node {$\__pascal_binomcoeff:nn {#1}{#2}$};
+ }
+ }
+ }
+ }
+
+%% 绘制Pascal三角形
+% 等腰三角形的绘制原理参考了 https://texample.net/tikz/examples/pascal-triangle/
+% Author: M.H. Ahmadi
+\cs_set:Npn \__pascal_triangle_draw:n #1
+ {
+ % 设置正常单元格为灰色
+ \tl_set:Nn \l__pascal_cell_color_tl {gray}
+ % 记录绘制列数
+ \int_set:Nn \l_tmpa_int {#1}
+
+ % 使用TikZ绘制
+ \begin{tikzpicture}[font=\l__pascal_font_size_tl]
+ % 列循环
+ \int_step_inline:nn {\l_tmpa_int}
+ {
+ % 调整为从0计数,以便于后续计算
+ \int_set:Nn \l__pascal_col_idx_int { ##1 - 1 }
+
+ % 计算列变换坐标(极坐标)
+ \__pascal_shift_col_pt:n {\l__pascal_col_idx_int}
+
+ % 用scope环境变换各列到指定位置
+ \begin{scope}[shift={(\l__pascal_shift_col_pt_tl)}]
+ % 计算每列最多行数
+ \int_set:Nn \l__pascal_row_top_int {\l_tmpa_int - ##1 + 1}
+
+ % 行循环
+ \int_step_inline:nn { \l__pascal_row_top_int }
+ {
+ % 调整为从0计数,以便于后续计算
+ \int_set:Nn \l__pascal_row_idx_int { ####1 - 1 }
+
+ % 计算组合数计算中的行数
+ \int_zero:N \l__pascal_total_idx_int
+ \int_add:Nn \l__pascal_total_idx_int { \l__pascal_row_idx_int }
+ \int_add:Nn \l__pascal_total_idx_int { \l__pascal_col_idx_int }
+
+ % 为指定行设置绘制颜色
+ \int_case:nn { \l__pascal_col_idx_int }
+ {
+ {0}{
+ \tl_set:Nn \l__pascal_cell_color_tl { pink }
+ }
+ {1}{
+ \tl_set:Nn \l__pascal_cell_color_tl { yellow }
+ }
+ {2}{
+ \tl_set:Nn \l__pascal_cell_color_tl { blue }
+ }
+ {3}{
+ \tl_set:Nn \l__pascal_cell_color_tl { green }
+ }
+ {\l__pascal_fill_col_int - 1}{
+ \int_compare:nNnTF{\l__pascal_row_idx_int} < { \l__pascal_fill_row_int + 1 }
+ {\tl_set:Nn \l__pascal_cell_color_tl { purple }}
+ {\tl_set:Nn \l__pascal_cell_color_tl { gray }}
+ }
+ {\l__pascal_fill_col_int}{
+ \int_compare:nNnTF{\l__pascal_row_idx_int} = { \l__pascal_fill_row_int }
+ {\tl_set:Nn \l__pascal_cell_color_tl { purple }}
+ {\tl_set:Nn \l__pascal_cell_color_tl { gray }}
+ }
+ }
+
+ % 计算行变换坐标(极坐标)
+ \__pascal_shift_row_pt:n {\l__pascal_row_idx_int}
+ % 用scope环境变换各行到指定位置
+ \begin{scope}[shift={(\l__pascal_shift_row_pt_tl)}]
+ % 是否绘制行列编号
+ \bool_if:NT \l__pascal_num_cell_bool
+ {
+ \__pascal_num_draw:nnn { \l__pascal_col_idx_int }
+ { \l__pascal_row_idx_int }
+ { \l__pascal_row_top_int }
+ }
+ % 绘制一个单元格
+ \__pascal_cell_draw:nn{\l__pascal_total_idx_int}{\l__pascal_col_idx_int}
+ \end{scope}
+ }
+ \end{scope}
+ }
+ \end{tikzpicture}
+ }
+
+%% 绘制Pascal三角形用户接口
+\NewDocumentCommand{\pascal}{O{} m}
+ {
+ \IfNoValueF{#1}{ \keys_set:nn { pascal } {#1} }
+ \group_begin:
+ \__pascal_triangle_draw:n{#2}
+ \group_end:
+ }
+
+\endinput
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index e836ac1aeb2..e91963346fb 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -590,7 +590,7 @@ my @TLP_working = qw(
palatino palette paper papercdcase papermas papertex
paracol parades paralist parallel paratype
paresse parnotes parrun parsa parselines parskip
- pas-cours pas-crosswords pas-cv pas-tableur passivetex
+ pas-cours pas-crosswords pas-cv pas-tableur pascaltriangle passivetex
patch patchcmd patgen2-tutorial path pauldoc pawpict pax
pbalance pbibtex-base pbox pb-diagram pbsheet
pdf14
diff --git a/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc b/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
index 383df134588..ee3faf11388 100644
--- a/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
@@ -156,6 +156,7 @@ depend objectz
depend oplotsymbl
depend ot-tableau
depend oubraces
+depend pascaltriangle
depend perfectcut
depend pfdicons
depend physconst
diff --git a/Master/tlpkg/tlpsrc/pascaltriangle.tlpsrc b/Master/tlpkg/tlpsrc/pascaltriangle.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/pascaltriangle.tlpsrc