Debian Codegraph @

texmf-dist/doc/latex/pascaltriangle/pascaltriangle.tex

raw
1 \documentclass[full]{l3doc}
2 \usepackage[scheme=plain]{ctex}
3 \usepackage{enumitem}
4 \usepackage{indentfirst}
5 \usepackage{titling}
6 \usepackage{geometry}
7 \usepackage{fancyvrb-ex}
8 \usepackage{pascaltriangle}
9
10 \IndexPrologue
11 {
12 \section*{Index}
13 \markboth{Index}{Index}
14 \addcontentsline{toc}{section}{Index}
15 The~italic~numbers~denote~the~pages~where~the~
16 corresponding~entry~is~described,~
17 numbers~underlined~point~to~the~definition,~
18 all~others~indicate~the~places~where~it~is~used.
19 }
20
21 \newcommand\tikzmark[1]{\tikz \coordinate[overlay, remember picture] (#1);}
22
23 \geometry{
24 left=4.5cm,
25 right=2cm,
26 top=2cm,
27 bottom=2cm,
28 }
29 \hypersetup {
30 CJKbookmarks,
31 bookmarksopen,
32 bookmarksopenlevel=3,
33 pdfstartview=FitH,
34 pdfinfo = {
35 Title = The package pascaltriangle ,
36 Subject = A LaTeX3 package ,
37 Author = Geng Nan
38 }
39 }
40
41 \DoNotIndex{\begin, \end}
42 \setlength{\parskip}{\medskipamount}
43 \DeclareDocumentEnvironment { noteen } { +b } {
44 \par\textbf{\textsf{NOTE:~}}#1\par
45 } {}
46 \DeclareDocumentEnvironment { notezh } { +b } {
47 \par\textbf{\textsf{注意:~}}#1\par
48 } {}
49
50 \AtEndDocument{
51 \newgeometry{
52 left=2cm,
53 right=2cm,
54 top=2cm,
55 bottom=2cm
56 }
57 \PrintIndex
58 }
59
60 \ExplSyntaxOn
61 \dim_new:N \l__my_syntax_dim
62 \box_new:N \g__my_syntax_box
63 \NewDocumentEnvironment { Syntax } { s }
64 {
65 \dim_set:Nn \l__my_syntax_dim
66 { \textwidth }
67 \hbox_gset:Nw \g__my_syntax_box
68 \small \ttfamily
69 \begin{minipage}[t]{\l__my_syntax_dim}
70 \raggedright\obeyspaces\obeylines
71 }
72 {
73 \end{minipage}
74 \hbox_gset_end:
75 \IfValueF { #1 } { \smallskip }
76 \box_use_drop:N \g__my_syntax_box
77 \smallskip
78 }
79
80 \DeclareDocumentEnvironment { Description } { o +b } {
81 \hbox_set:Nn \l_tmpa_box { #1 }
82 \dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box }
83 \begin{itemize}[labelwidth=\l_tmpa_dim, align=left]
84 #2
85 \end{itemize}
86 } { }
87
88 \keys_define:nn { pascal/doc } {
89 opt .tl_set:N = \l_opt_tl,
90 desc .tl_set:N = \l_desc_tl,
91 init .tl_set:N = \l_init_tl,
92 init .initial:n = init-none,
93 }
94
95 \box_new:N \l__option_box
96 \NewDocumentEnvironment { option } { m +b } {
97 \keys_set:nn { pascal/doc } { #1 }
98 \hbox_set:Nw \l__option_box
99 \small \ttfamily
100 \begin{minipage}[t]{\textwidth}
101 \obeyspaces\obeylines
102 \textcolor{red}{
103 \l_opt_tl
104 \exp_args:Nx\SpecialOptionIndex{\l_opt_tl}
105 }
106 {~}\l_desc_tl
107 \hfill(
108 \tl_if_eq:NnTF \l_init_tl { init-none } { no~value }
109 { initially~\texttt{\l_init_tl} }
110 )
111 \end{minipage}
112 \hbox_gset_end:
113 \box_use_drop:N \l__option_box
114 #2
115 \medskip
116 } { }
117
118 \DeclareDocumentCommand \opt { O{} m }
119 { \__codedoc_cmd:no {#1} { #2 } }
120 \ExplSyntaxOff
121
122 \def\vers{\texttt{v1.0.1}
123 \thanks{\url{https://github.com/registor/pascaltriangle}}
124 \thanks{\url{https://gitee.com/nwafu_nan/pascaltriangle}}
125 }
126
127 \begin{document}
128 \title{
129 \pkg{pascaltriangle} 宏包
130 \rlap{\makebox[4cm][r]{
131 \normalsize $\Longrightarrow$ \color{red}
132 \protect\hyperlink{en}{English Version}
133 \protect\hypertarget{zh}{}
134 }}
135 }
136 \author{\textit{耿楠} \texttt{<[email protected]>}}
137 \date{\the\year 年\the\month 月\the\day 日\qquad \vers
138 }
139 \maketitle
140
141 {\small
142 \tableofcontents
143 }
144 \newpage
145
146 \begin{documentation}
147
148 \section{引言}
149 \pkg{pascaltriangle}是一个基于\pkg{TikZ}用\pkg{expl3}开发的
150 Pascal三角形(杨辉三角形)生成宏包,它提供了一个唯一的绘图命令
151 \tn{pascal},并可以通过不同命令的命令选项或\tn{pascalset}命令
152 设置生成不同外观的等腰或直角Pascal三角形。
153
154 \section{用户接口}
155
156 \subsection{\cs{pascal}绘图命令}
157
158 \begin{function}{\pascal}
159 \begin{syntax}
160 \cs{pascal} \oarg{外观选项} \marg{层数}
161 \end{syntax}
162
163 \end{function}
164
165 用于绘制一个Pascal三角形。
166
167 该命令仅有一个必选参数\marg{层数},用于指定Pascal三角形的层数。
168
169 在\oarg{外观选项}中可以通过key-value方式设置三角形形状、大小等外观。
170
171 三角形的外观也可以通过\cs{pascalset}命令的逗号分隔key-value列表进行设置
172
173 \subsection{\cs{pascalset}}
174 \begin{function}{\pascalset}
175 \begin{syntax}
176 \cs{pascalset} \marg{外观选项}
177 \end{syntax}
178
179 \end{function}
180
181 用于设置一个Pascal三角形的外观。
182
183 在\marg{外观选项}中可以通过key-value方式设置三角形形状、大小等外观。
184
185 \section{外观选项}
186
187 \begin{option}{ opt = shape, desc = {= \meta{形状}}, init=iso }
188 设置Pascal三角形的形状,目前支持|iso|---等腰三角形和
189 |rt|---直角三角形。
190 \end{option}\\
191 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
192 \centering
193 \pascal{5}\qquad
194 \pascal[shape=rt]{5}
195 \end{SideBySideExample}
196
197 \bigskip
198
199 \begin{option}{ opt = radius, desc = {= \meta{半径}}, init=0.5cm }
200 设置三角形每个单元外接圆半径,注意需要带有单位。
201 \end{option}\\
202 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
203 \centering
204 \pascal[radius=0.8cm]{5}
205 \end{SideBySideExample}
206
207 \bigskip
208
209 \begin{option}{ opt = fontsize, desc = {= \meta{字号命令}}, init=\cs{small} }
210 设置三角形每个单元中数字文本大小。
211 \end{option}\\
212 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
213 \centering
214 \pascal[radius=0.8cm,
215 fontsize=\Huge]{5}
216 \end{SideBySideExample}
217
218 \bigskip
219
220 \begin{option}{opt=withnum, desc={= \meta{布尔值}}, init=false}
221 设置是否显示Pascal三角形的行列编号。
222 \end{option}\\
223 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
224 \centering
225 \pascal[withnum]{4}
226 \pascal[withnum,shape=rt]{4}
227 \end{SideBySideExample}
228
229 \bigskip
230
231 \begin{option}{opt = binom, desc = {= \meta{布尔值}}, init=false}
232 设置是否显示用二项式表达式显示各元素值。
233 \end{option}\\
234 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
235 \centering
236 \pascal[binom]{5}
237 \pascal[binom,shape=rt]{5}
238 \end{SideBySideExample}
239
240 \bigskip
241
242 \begin{option}{ opt = fillr, desc = {= \meta{整数}}, init=1 }
243 设置需要表示前列累加的单元格行号,注意行号是当前列自顶向下从0开始计数。
244 \end{option}
245
246 \begin{option}{ opt = fillc, desc = {= \meta{整数}}, init=1 }
247 设置需要表示前列累加的单元格列号,注意列号是自左向右从0开始计数。
248 \end{option}\\
249 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.64\linewidth,gobble=2]
250 \centering
251 \pascalset{fillr=2,fillc=6,
252 radius=0.4cm}
253 \pascal{10}\\
254 \pascal[shape=rt]{10}
255 \end{SideBySideExample}
256
257 \bigskip
258
259 \title{
260 Package \pkg{pascaltriangle}
261 \rlap{\makebox[4cm][r]{
262 \normalsize $\Longrightarrow$ \color{red}
263 \protect\hyperlink{zh}{中文版本}
264 \protect\hypertarget{en}{}
265 }}
266 }
267 \author{Nan Geng \texttt{<[email protected]>}}
268 \date{\today\qquad \vers}
269 \maketitle
270
271 \section{Introduction}
272
273 \pkg{pascaltriangle} is a Pascal triangle(Yanghui triangle) generation package
274 based on TikZ developed in expl3, which provides a unique drawing command \cs{pascal},
275 and can be set by different options or \cs{pascalset} macro to
276 generates isosceles or right-angle Pascal triangles with different appearances.
277
278 \section{Interfaces}
279
280 \subsection{\cs{pascal} macro}
281
282 \begin{function}{\pascal}
283 \begin{syntax}
284 \cs{pascal} \oarg{options} \marg{order}
285 \end{syntax}
286 \end{function}
287 Used to draw a Pascal triangle.
288
289 This macro has only one mandatory parameter \marg{order},
290 which specifies the number of layers of the Pascal triangle.
291
292 In \oarg{options} you can set the appearance of the triangle shape,
293 size, etc. by key-value method.
294
295 The appearance of the triangle can also be set via the comma-separated
296 key-value list of the \cs{pascalset} macro
297
298 \subsection{\cs{pascalset} macro}
299
300 \begin{function}{\pascalset}
301 \begin{syntax}
302 \cs{pascalset} \marg{options}
303 \end{syntax}
304 \end{function}
305
306 Used to set the appearance of Pascal triangle.
307
308 In \oarg{options} you can set the appearance of the triangle shape,
309 size, etc. by key-value method.
310
311 \section{options}
312
313 \begin{option}{ opt = shape, desc = {= \meta{shape}}, init=iso }
314 Sets the shape of Pascal triangle
315 currently supporting |iso|---isosceles triangles and |rt|---right-angle triangles.
316 \end{option}\\
317 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
318 \centering
319 \pascal{5}\qquad
320 \pascal[shape=rt]{5}
321 \end{SideBySideExample}
322
323 \bigskip
324
325 \begin{option}{ opt = radius, desc = {= \meta{radius}}, init=0.5cm }
326 Set the radius of the outer circle of each cell of the triangle,
327 note that it needs to have units.
328 \end{option}\\
329 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
330 \centering
331 \pascal[radius=0.8cm]{5}
332 \end{SideBySideExample}
333
334 \bigskip
335
336 \begin{option}{ opt = fontsize, desc = {= \meta{fontsize}}, init=\cs{small} }
337 Sets the fontsize of each cell of the triangle.
338 \end{option}\\
339 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.65\linewidth,gobble=2]
340 \centering
341 \pascal[radius=0.8cm,
342 fontsize=\Huge]{5}
343 \end{SideBySideExample}
344
345 \bigskip
346
347 \begin{option}{opt=withnum, desc={= \meta{bool}}, init=false}
348 Sets whether to show the Pascal triangle row/col numbers or not.
349 \end{option}\\
350 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
351 \centering
352 \pascal[withnum]{4}
353 \pascal[withnum,shape=rt]{4}
354 \end{SideBySideExample}
355
356 \bigskip
357
358 \begin{option}{opt = binom, desc = {= \meta{bool}}, init=false}
359 Sets whether to show each element value with binomial expressions or not.
360 \end{option}\\
361 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.63\linewidth,gobble=2]
362 \centering
363 \pascal[binom]{5}
364 \pascal[binom,shape=rt]{5}
365 \end{SideBySideExample}
366
367 \bigskip
368
369 \begin{option}{ opt = fillr, desc = {= \meta{integer}}, init=1 }
370 Set the row number of the cell that needs to indicate the sum of the pre-column,
371 note that the row number is in the current column counted from the top down based 0.
372 \end{option}
373
374 \begin{option}{ opt = fillc, desc = {= \meta{integer}}, init=1 }
375 Set the col number of the cell that needs to indicate the sum of the pre-column,
376 note that the col number is counted from the left to right based 0.
377 \end{option}\\
378 \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.64\linewidth,gobble=2]
379 \centering
380 \pascalset{fillr=2,fillc=6,
381 radius=0.4cm}
382 \pascal{10}\\
383 \pascal[shape=rt]{10}
384 \end{SideBySideExample}
385
386 \end{documentation}
387
388
389 \end{document}