Debian Codegraph @

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

raw
1 \documentclass[full]{l3doc}
2 \usepackage[scheme=chinese]{ctex}
3 \usepackage{enumitem}
4 \usepackage{indentfirst}
5 \usepackage{titling}
6 \usepackage{geometry}
7 \usepackage{graphicx}
8 \usepackage{fontawesome5}
9 \usepackage{fancyvrb-ex}
10 \usepackage[piecechar={C}{炮}]{chinesechess}
11 % \usepackage[draft,piecechar={C}{炮}]{chinesechess}
12
13 \IndexPrologue
14 {
15 \section*{Index}
16 \markboth{Index}{Index}
17 \addcontentsline{toc}{section}{Index}
18 The~italic~numbers~denote~the~pages~where~the~
19 corresponding~entry~is~described,~
20 numbers~underlined~point~to~the~definition,~
21 all~others~indicate~the~places~where~it~is~used.
22 }
23
24 \newcommand\tikzmark[1]{\tikz \coordinate[overlay, remember picture] (#1);}
25
26 \geometry{
27 left=4.5cm,
28 right=2cm,
29 top=2cm,
30 bottom=2cm,
31 }
32 \hypersetup {
33 CJKbookmarks,
34 bookmarksopen,
35 bookmarksopenlevel=3,
36 pdfstartview=FitH,
37 pdfinfo = {
38 Title = 中国象棋排版宏包 ,
39 Subject = A LaTeX3 package ,
40 Author = 耿楠
41 }
42 }
43
44 \DoNotIndex{\begin, \end}
45 \setlength{\parskip}{\medskipamount}
46 \DeclareDocumentEnvironment { noteen } { +b } {
47 \par\textbf{\textsf{NOTE:~}}#1\par
48 } {}
49 \DeclareDocumentEnvironment { notezh } { +b } {
50 \par\textbf{\textsf{注意:~}}#1\par
51 } {}
52
53 \AtEndDocument{
54 \newgeometry{
55 left=2cm,
56 right=2cm,
57 top=2cm,
58 bottom=2cm
59 }
60 \PrintIndex
61 }
62
63 \ExplSyntaxOn
64 \dim_new:N \l__my_syntax_dim
65 \box_new:N \g__my_syntax_box
66 \NewDocumentEnvironment { Syntax } { s }
67 {
68 \dim_set:Nn \l__my_syntax_dim
69 { \textwidth }
70 \hbox_gset:Nw \g__my_syntax_box
71 \small \ttfamily
72 \begin{minipage}[t]{\l__my_syntax_dim}
73 \raggedright\obeyspaces\obeylines
74 }
75 {
76 \end{minipage}
77 \hbox_gset_end:
78 \IfValueF { #1 } { \smallskip }
79 \box_use_drop:N \g__my_syntax_box
80 \smallskip
81 }
82
83 \DeclareDocumentEnvironment { Description } { o +b } {
84 \hbox_set:Nn \l_tmpa_box { #1 }
85 \dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box }
86 \begin{itemize}[labelwidth=\l_tmpa_dim, align=left]
87 #2
88 \end{itemize}
89 } { }
90
91 \keys_define:nn { cchess/doc } {
92 opt .tl_set:N = \l_opt_tl,
93 desc .tl_set:N = \l_desc_tl,
94 init .tl_set:N = \l_init_tl,
95 init .initial:n = init-none,
96 }
97
98 \box_new:N \l__option_box
99 \NewDocumentEnvironment { option } { m +b } {
100 \keys_set:nn { cchess/doc } { #1 }
101 \hbox_set:Nw \l__option_box
102 \small \ttfamily
103 \begin{minipage}[t]{\textwidth}
104 \obeyspaces\obeylines
105 \textcolor{red}{
106 \l_opt_tl
107 \exp_args:Nx\SpecialOptionIndex{\l_opt_tl}
108 }
109 {~}\l_desc_tl
110 \hfill(
111 \tl_if_eq:NnTF \l_init_tl { init-none } { no~value }
112 { 初始值:~\texttt{\l_init_tl} }
113 )
114 \end{minipage}
115 \hbox_gset_end:
116 \box_use_drop:N \l__option_box
117 #2
118 % \vspace*{-4ex}
119 \medskip
120 } { }
121
122 \DeclareDocumentCommand \opt { O{} m }
123 { \__codedoc_cmd:no {#1} { #2 } }
124 \ExplSyntaxOff
125
126 \def\vers{\texttt{v1.2.0} }
127
128 \begin{document}
129 \title{
130 中国象棋棋谱排版\\\pkg{chinesechess} 宏包
131 % \rlap{\makebox[4cm][r]{
132 % \normalsize $\Longrightarrow$ \color{red}
133 % \protect\hyperlink{en}{English Version}
134 % \protect\hypertarget{zh}{}
135 % }}
136 }
137 \author{\textit{耿楠} \texttt{<[email protected]>}}
138 \date{\the\year 年\the\month 月\the\day 日\qquad \vers
139 % \thanks{\url{https://github.com/registor/chinesechess}}
140 \thanks{\url{https://gitee.com/nwafu_nan/chinesechess}}
141 }
142
143 \maketitle
144
145 \begin{abstract}
146 \pkg{chinesechess}是一个基于\pkg{l3draw}绘图宏包,用\pkg{Expl3}%
147 开发的中国象棋排版宏包。它提供了\tn{cchessboard}(全棋盘)、%
148 \tn{cchessbord*}(空棋盘)和\tn{cchessman}(棋谱)排版命令。同时,
149 该宏包还提供了用于打谱的排版环境\env{setcchessman},在该环境
150 中,可以通过环境专用命令\tn{init}(初始化棋谱状态),\tn{set}(在
151 指定位置布置棋子),\tn{del}(删除指定位置的棋子),\tn{mov}(实现
152 棋子的移动)实现打谱操作,并在环境结束后排版最终状态棋谱。
153 通过其星号环境\env{setcchessman*}可以记录打谱过程,并通过%
154 \tn{printman}利用交叉引用标签\oarg{label}选项对指定%
155 \env{setcchessman*}打谱环境记录的打谱文本在指定位置排版输出。
156 棋子、棋盘、背景等外观可以通过命令、环境选项或\tn{cchessset}%
157 命令进行设置。
158 \end{abstract}
159
160 {\small
161 \tableofcontents
162 }
163 \newpage
164
165 \begin{documentation}
166
167 \section{引言}
168
169 \pkg{chinesechess}是一个基于\pkg{l3draw}绘图宏包,用\pkg{Expl3}%
170 开发的中国象棋排版宏包。它利用\pkg{l3draw}的绘图功能,通过为红黑
171 各7个棋子文字添加背景实现了棋子绘制,利用简单线条实现了棋盘绘制,
172 并可以通过\pkg{graphicx}宏包可以为棋盘添加图片背景。
173
174 该宏包的目的是实现\textsf{不依赖于字体文件}或\textsf{字体宏包}的
175 中国象棋棋谱排版,由于需要大量绘制操作,因此,其编译速度较低。
176
177 \section{用户接口}
178
179 \subsection{\tn{cchessboard}棋盘排版命令}
180
181 \begin{function}{\cchessboard}
182 \begin{syntax}
183 \cs{cchessboard} \oarg{外观选项}
184 \cs{cchessboard*} \oarg{外观选项}
185 \end{syntax}
186 \end{function}
187
188 按设置的\oarg{外观选项}输出带有32个红黑棋子,并布置于初始位置
189 的棋盘。
190
191 在\oarg{外观选项}中可以通过key-value的方式设置棋子、棋盘的颜色、
192 字体、字号、线宽等外观。
193
194 通过\oarg{外观选项}设置的外观参数仅对当前命令局部有效,
195
196 其星号版本命令用于无棋子棋盘排版。
197
198 \begin{SideBySideExample}[frame=single,numbers=left,
199 xrightmargin=.60\linewidth,gobble=2]
200 \centering
201 % 为便排版,进行缩放
202 \cchessset{resize/type=real,
203 resize/height=4.0cm}
204 \cchessboard\quad
205 \cchessboard*
206 \end{SideBySideExample}
207
208 \subsection{\tn{cchessman}棋谱排版命令}\label{subsec-cchessman}
209
210 \begin{function}{\cchessman}
211 \begin{syntax}
212 \cs{cchessman} \oarg{外观选项} \marg{棋子列表}
213 \end{syntax}
214 \end{function}
215
216 按设置的\oarg{外观选项},将在\marg{棋子列表}中指定棋子布置于棋盘的
217 指定位置并排版输出。
218
219 \marg{棋子列表}中各个棋子用大括号分组后再用英文逗号进行分隔,每个棋子
220 是由大括号括起来的\textsf{棋子位置}与\textsf{棋子编码}组成的。
221
222 棋子位置由英文逗号分隔的纵横坐标确定,其中,纵向坐标用英文小写字母
223 a--j或阿拉伯数字0--9分别表示棋盘纵向10个交点;横向坐标用英文小写字母
224 a--i或阿拉伯数字0--8分别表示棋盘横向的9个交点。
225
226 \textbf{\textsf{注意: }}可以混合使用字母和数字棋子坐标表示方法,但强烈
227 建议使用单一字母法或数字法表示棋子坐标。
228
229 棋子编码采用大写字母表示红棋,小写字母表示黑棋,具体如表%
230 \ref{tab-piececode}所示。
231
232 \begin{table}[!htbp]
233 \centering
234 \caption{棋子编码规则}\label{tab-piececode}
235 \begin{tabular}{cc||cc}
236 \hline
237 编码 & 红棋 & 编码 & 黑棋\\\hline
238 K & 帥 & k & 將 \\
239 A & 仕 & a & 士 \\
240 B(E) & 相 & b(e) & 象 \\
241 N(H) & 马 & n(h) & 馬 \\
242 R & 车 & r & 車 \\
243 C & 炮 & c & 炮 \\
244 P & 兵 & p & 卒 \\\hline
245 \end{tabular}
246 \end{table}
247
248 例如,一个完整的\marg{棋子列表}为:
249
250 |{{4,0}{K}}, {{2,2}{p}}, {{1,7}{C}}, {{4,9}{k}}|
251
252 在\oarg{外观选项}中可以通过key-value的方式设置棋子、棋盘的颜色、
253 字体、字号、线宽等外观。
254
255 通过\oarg{外观选项}设置的外观参数仅对当前命令局部有效,
256
257 \begin{SideBySideExample}[frame=single,numbers=left,
258 xrightmargin=.50\linewidth,gobble=2]
259 \centering
260 % 为便排版,进行缩放
261 \cchessset{resize/type=real,
262 resize/width=.90\linewidth}
263 \cchessman{ {{4,0}{K}}, {{2,2}{p}},
264 {{1,7}{C}}, {{4,9}{k}}
265 }
266 \end{SideBySideExample}
267
268 \subsection{\env{setcchessman}打谱排版环境}
269
270 \begin{function}{setcchessman}
271 \begin{syntax}
272 \tn{begin}|{setcchessman}|\oarg{外观选项}
273 .....
274 \tn{end}|{setcchessman}|
275 \tn{begin}|{setcchessman*}|\oarg{外观选项}
276 .....
277 \tn{end}|{setcchessman*}|
278 \end{syntax}
279 \end{function}
280
281 按设置的\oarg{外观选项}排版打谱结果。
282
283 在\env{setcchessman}环境中,可以通过专用命令\tn{init}%
284 (初始化棋谱状态)(残局),\tn{set}(在指定位置布置棋子),\tn{del}(删除
285 指定位置的棋子),\tn{mov}(棋子移动)实现打谱操作。
286 在环境结束后以最终打谱状态排版棋谱。
287
288 星号环境\env{setcchessman*}用于同时记录打谱过程的文本描述(如:车一进二等)。
289 在\env{setcchessman*}环境中可以用\oarg{label}选项设置引用标签,
290 再用\tn{printman}命令通过引用标签输出对应打谱过程文本描述。
291
292 在\oarg{外观选项}中可以通过key-value的方式设置棋子、棋盘的颜色、
293 字体、字号、线宽等外观。对于\env{setcchessman*}星号环境,%
294 \oarg{外观选项}中的棋子与棋盘相关外观选项设置无效。
295
296 通过\oarg{外观选项}设置的外观参数仅对当前命令局部有效,
297
298 \begin{SideBySideExample}[frame=single,numbers=left,
299 xrightmargin=.48\linewidth,gobble=2]
300 \centering
301 % 为便排版,进行缩放
302 \cchessset{resize/type=real,
303 resize/width=.90\linewidth}
304 \begin{setcchessman}
305 % 残局初始化
306 \init{ {{4,0}{K}}, {{2,2}{p}},
307 {{1,7}{C}}, {{4,9}{k}} }
308 % 添加棋子
309 \set{e,d}{P} \set{8,g}{h}
310 % 删除棋子
311 \del{4,3}
312 % 移动棋子
313 \mov{C}{b,h}{b,b} \mov{p}{2,2}{3,2}
314 \mov{K}{4,0}{4,1} \mov{h}{8,6}{6,7}
315 \mov{K}{4,1}{3,1} \mov{h}{6,7}{5,5}
316 \end{setcchessman}
317 \end{SideBySideExample}
318
319 \subsection{打谱专用命令}
320
321 \subsubsection{\tn{init}棋谱初始化命令}
322
323 \begin{function}{\init}
324 \begin{syntax}
325 \cs{init} \marg{棋子列表}
326 \end{syntax}
327 \end{function}
328
329 用于将\marg{棋子列表}中指定的所有棋子布置于棋盘的指定位置。
330
331 \marg{棋子列表}中的棋子表示方法与第\ref{subsec-cchessman}小节
332 中的说明相同。
333
334 \textbf{\textsf{注意: }}该命令只能用于\env{setcchessman}环境中。
335
336 \subsubsection{\tn{set}棋子布置命令}
337
338 \begin{function}{\set}
339 \begin{syntax}
340 \cs{set} \marg{棋子}
341 \end{syntax}
342 \end{function}
343
344 用于将指定\marg{棋子}布置于棋盘的指定位置。
345
346 \marg{棋子}中的棋子表示方法与第\ref{subsec-cchessman}小节
347 中的说明相同。
348
349 \textbf{\textsf{注意: }}该命令只能用于\env{setcchessman}环境中。
350
351 \subsubsection{\tn{del}棋子删除命令}
352
353 \begin{function}{\del}
354 \begin{syntax}
355 \cs{del} \marg{棋盘坐标}
356 \end{syntax}
357 \end{function}
358
359 用于删除\marg{棋盘坐标}中指定坐标处的棋子。
360
361 \marg{棋盘坐标}中的表示方法与第\ref{subsec-cchessman}小节
362 中的说明相同。
363
364 \textbf{\textsf{注意: }}该命令只能用于\env{setcchessman}环境中。
365
366 \subsubsection{\tn{mov}棋子移动命令}
367
368 \begin{function}{\mov}
369 \begin{syntax}
370 \cs{mov} \marg{棋子编码}\marg{原棋盘坐标}\marg{新棋盘坐标}
371 \end{syntax}
372 \end{function}
373
374 用于将\marg{棋子编码}中指定的棋子从\marg{原棋盘坐标}移动到%
375 \marg{新棋盘坐标}。若\marg{新棋盘坐标}处有棋子,则会被无条件
376 ``吃''掉(替换)。
377
378 \marg{棋子编码}、\marg{原棋盘坐标}和\marg{新棋盘坐标}中采用
379 棋子与棋盘坐标表示方法与第\ref{subsec-cchessman}小节中的说明相同。
380
381 \textbf{\textsf{注意: }}该命令只能用于\env{setcchessman}环境中。
382
383 \subsection{\tn{printman}输出打谱结果命令}
384
385 \begin{function}{\printman}
386 \begin{syntax}
387 \cs{printman} \oarg{每行步数} \marg{label标签}
388 \end{syntax}
389 \end{function}
390
391 输出由label标签指定的\env{setcchessman*}打谱环境生成的棋谱文本描述。
392 \footnote{棋谱文本描述文件以\tn{jobname}+label+索引编号命名,
393 并以``.man''为后缀名,是一个纯文本文件。}
394
395 \oarg{每行步数}选项用于指定每行中输出的棋谱步数。
396
397 \subsection{\tn{getpiece}输出棋子命令}
398
399 \begin{function}{\getpiece}
400 \begin{syntax}
401 \cs{getpiece} \oarg{棋子字号} \marg{棋子编码}
402 \end{syntax}
403 \end{function}
404
405 按\oarg{棋子字号}指定的字号将用\marg{棋子编码}指定的棋子在当前位置输出。
406
407 \marg{棋子编码}中的编码详见表\ref{tab-piececode}。
408
409 \begin{SideBySideExample}[frame=single,numbers=left,
410 xrightmargin=.28\linewidth,gobble=2]
411 \centering
412 \getpiece{K}\getpiece{A}\getpiece{B}\getpiece{R}%
413 \getpiece{N}\getpiece{C}\getpiece{P}
414
415 \getpiece{k}\getpiece{a}\getpiece{b}\getpiece{r}%
416 \getpiece{n}\getpiece{c}\getpiece{p}
417 \end{SideBySideExample}
418
419 \subsection{\tn{piecechar}棋子字符设置命令}
420
421 \begin{function}{\piecechar}
422 \begin{syntax}
423 \cs{piecechar} \marg{棋子编码} \marg{棋子字符}
424 \end{syntax}
425 \end{function}
426
427 用于将\marg{棋子编码}指定的棋子字符设置为指定的\marg{棋子字符}。
428
429 \marg{棋子编码}中的编码详见表\ref{tab-piececode}。
430
431 \textbf{\textsf{说明: }}该功能也可以通过|piecechar|外观选项实现。
432
433 \subsection{\tn{resetpiece}棋子字符复位命令}
434
435 \begin{function}{\resetpiece}
436 \begin{syntax}
437 \cs{resetpiece}
438 \end{syntax}
439 \end{function}
440
441 将棋子字符复位到默认字符。
442
443 \subsection{\tn{cchessset}选项设置命令}
444
445 \begin{function}{\cchessset}
446 \begin{syntax}
447 \cs{cchessset} \marg{外观选项}
448 \end{syntax}
449 \end{function}
450
451 通过\marg{外观选项}中的key-value方式设置棋子、棋盘的文字、
452 字体、颜色、线宽等外观参数。
453
454 % \textbf{\textsf{说明: }}执行该命令时,仅有\textbf{\textsf{除}}%
455 % 棋子与棋盘外观的\textbf{\textsf{其它参数}}有效,棋子与棋盘外观
456 % 参数的设置会在执行下一次命令或环境参数时起效。
457
458 通过\cs{cchessset}\marg{外观选项}设置的外观参数对后续所有
459 棋谱排版命令有效。
460
461 \textbf{\textsf{注意: }}由于\pkg{chinesechess}宏包涉及大量
462 绘图操作,因此建议尽量减少在命令或环境中使用\oarg{外观选项}设置%
463 以节约编译时间。如需要更改棋子或棋盘外观,可以在引用宏包时,
464 通过为宏包添加选项实现,也可以执行\tn{cchessset}命令进行必要的
465 全局设置或在一定范围内进行统一设置。
466
467 % \oarg{外观选项}中的棋子与棋盘相关外观选项设置无效。
468
469 % \section{宏包选项}
470
471 \section{宏包选项}
472
473 在\pkg{chinesechess}宏包中,棋子与棋盘的文本、字体、颜色、背景等
474 外观可以可以在引入宏包时通过\oarg{宏包选项}进行设置,也可以在
475 命令或环境的\oarg{外观选项}中进行局部设置,还可以通过\cs{cchessset}命令
476 进行全局设置。
477
478 强烈建议在引用宏包时通过\oarg{宏包选项}为一个文档统一全局设置棋子与
479 棋盘外观,以节约编译时间。应避免频繁在命令和环境中使用\oarg{宏包选项}或
480 使用\cs{cchessset}命令设置棋子与棋盘外面。
481
482 \pkg{chinesechess}宏包的选项是一组由(英文)逗号分隔的选项列表,列表中的
483 选项通常是\marg{key}|=|\marg{value}形式。部分选项的\marg{value}可以省略。
484 对于同一选项,后续设置会覆盖以前的设置。
485
486 \pkg{chinesechess}采用\LaTeX3风格的键值设置,支持不同类型以及多种层次的
487 选项设定。键值列表中,``|=|''左右的空格不影响设置。但需注意,参数列表中%
488 \textsf{不可以出现空行}。
489
490 布尔型的参数\marg{选项}|=true|中的``|=true|''可以省略。
491
492 对于``|resize|''缩放和``|man|''子选项,只能用于命令与环境选项中,或通过
493 \tn{cchessset}命令进行设置。
494
495 \textbf{\textsf{注意: }}为提高编译速度,\pkg{chinesechess}宏包会分别根据%
496 \tn{cchessset}命令或棋谱排版命令与环境的可选项中的棋盘与棋子相关参数决定
497 是否对棋盘或棋子进行重新绘制,因此,前一次的棋盘与棋子外观选项会影响至下
498 一次新的外观选项出现。如果需要改变前一次外观选项的影响,可以使用一次棋盘
499 或棋子外观相关选项。
500
501 \subsection{草稿选项}
502
503 \begin{option}{ opt = draft, desc = {= \meta{草稿选项}}, init=false }
504 设置草稿选项。
505 \end{option}
506
507 \oarg{draft}选项将删除所有效果设置,所有棋子仅显示文本,
508 棋盘仅带有九宫格对角线。从而加快编译速度。
509
510 \textbf{\textsf{注意: }}在草稿模式下,命令与环境中与棋子与棋盘外观
511 相关的选项都将失效,因此,可能与最终排版结果会有出入。
512
513 \begin{SideBySideExample}[frame=single,numbers=left,
514 xrightmargin=.53\linewidth,gobble=2]
515 % \usepackage[draft]{chinesechess}
516 \centering
517 % 为便排版,进行缩放
518 \cchessset{resize/type=real,
519 resize/width=.90\linewidth}
520 \cchessboard[draft]
521 \end{SideBySideExample}
522 \subsection{棋盘}
523
524 \subsubsection{单元格尺寸}
525
526 \begin{option}{ opt = gridsize, desc = {= \meta{棋盘格尺寸}}, init=10mm }
527 设置棋盘单元格尺寸。
528 \end{option}
529
530 \textbf{\textsf{说明: }}由于在前一个示例中使用了|[draft]|%
531 参数,为恢复棋子外观,需要执行一次棋子相关设置参数。
532
533 \begin{SideBySideExample}[frame=single,numbers=left,
534 xrightmargin=.60\linewidth,gobble=2]
535 \centering
536 % 为便排版,进行缩放
537 \cchessset{resize/type=real,
538 resize/width=.90\linewidth}
539 \cchessboard[gridsize=15mm,
540 piecetype=ooo]
541 \end{SideBySideExample}
542
543 \bigskip
544
545 \subsubsection{棋盘类型}
546
547 \begin{option}{ opt = boardtype, desc = {= \meta{棋盘类型}}, init=x+tn }
548 设置棋盘类型,目前支持:
549 \end{option}
550
551 \begin{Description}[a]
552 \item |x|---有九宫对角线,无兵炮位置标志。
553 \item |x+|---有九宫对角线和兵炮位置标志。
554 \item |x+t|---有九宫对角线、兵炮位置标志和楚河汉界。
555 \item |x+tn|---有九宫对角线、兵炮位置标志、楚河汉界和纵线标位数字。
556 \item |x+Xtn|---有九宫对角线、兵炮位置标志、楚河汉界、纵线标位数字和象位虚线。
557 \end{Description}
558
559 \begin{SideBySideExample}[frame=single,numbers=left,
560 xrightmargin=.54\linewidth,gobble=2]
561 \centering
562 % 为便排版,进行缩放
563 \cchessset{resize/type=real,
564 resize/width=.35\linewidth}
565 \cchessboard*[boardtype=x]\quad
566 \cchessboard*[boardtype=x+]\\
567 \cchessboard*[boardtype=x+t]\quad
568 \cchessboard*[boardtype=x+tn]\\
569 \cchessboard*[boardtype=x+Xtn]
570 \end{SideBySideExample}
571
572 \bigskip
573
574 \subsubsection{棋盘线线宽}
575
576 \begin{option}{ opt = boardlinewd, desc = {= \meta{棋盘线宽}}, init=0.4pt }
577 设置棋盘线线宽。
578 \end{option}
579
580 \begin{SideBySideExample}[frame=single,numbers=left,
581 xrightmargin=.56\linewidth,gobble=2]
582 \centering
583 % 为便排版,进行缩放
584 \cchessset{resize/type=real,
585 resize/width=.90\linewidth}
586 \cchessboard*[boardlinewd=1.0pt]
587 \end{SideBySideExample}
588
589 \bigskip
590
591 \subsubsection{棋盘线颜色}
592
593 \begin{option}{ opt = boardlinecolor, desc = {= \meta{棋盘线颜色}}, init=black }
594 设置棋盘线颜色。
595 \end{option}
596
597 \begin{SideBySideExample}[frame=single,numbers=left,
598 xrightmargin=.55\linewidth,gobble=2]
599 \centering
600 % 为便排版,进行缩放
601 \cchessset{resize/type=real,
602 resize/width=.90\linewidth}
603 \cchessboard*[boardlinecolor=red]
604 \end{SideBySideExample}
605
606 \bigskip
607
608 \subsubsection{棋盘背景}
609
610 \begin{option}{ opt = boardbg, desc = {= \meta{棋盘背景}}, init=init-none }
611 设置棋盘背景图的插图文件路径及文件名。
612 \end{option}
613
614 \textbf{\textsf{注意: }}使用该选项时,需要在导言区添加|\usepackage{grpahicx}|命令。
615
616 \begin{SideBySideExample}[frame=single,numbers=left,
617 xrightmargin=.55\linewidth,gobble=2]
618 \centering
619 % 为便排版,进行缩放
620 \cchessset{resize/type=real,
621 resize/width=.35\linewidth}
622 \cchessboard*[boardbg=bg01]\quad
623 \cchessboard*[boardbg=bg02]
624 \end{SideBySideExample}
625
626 \bigskip
627
628 \subsection{棋子}
629
630 \subsubsection{字符}
631
632 \begin{option}{ opt = piecechar, desc = {= \meta{棋子字符}},
633 init=\{K\}\{帥\} }
634 设置棋子字符,用两组大括号分别指定棋子编码和棋子字符。
635 其中,棋子编码见表\ref{tab-piececode}。
636 \end{option}
637
638 \textbf{\textsf{注意: }}使用该选项时,在能需要在导言区添加字体,
639 如|\usepackage{fontawesome5}|命令。
640
641 \begin{SideBySideExample}[frame=single,numbers=left,
642 xrightmargin=.55\linewidth,gobble=2]
643 %\usepackage{fontawesome5}
644 \centering
645 % 为便排版,进行缩放
646 \cchessset{resize/type=real,
647 resize/width=.90\linewidth}
648 \cchessboard[%
649 piecechar={K}{\faChessKing},
650 piecechar={A}{\faShield*},
651 piecechar={E}{\faChessBishop},
652 piecechar={H}{\faChessKnight},
653 piecechar={R}{\faChessRook},
654 piecechar={C}{\faMeteor},
655 piecechar={P}{\faChessPawn},
656 piecechar={k}{\faChessQueen},
657 piecechar={a}{\faShield*},
658 piecechar={e}{\faChessBishop},
659 piecechar={h}{\faChessKnight},
660 piecechar={r}{\faChessRook},
661 piecechar={c}{\faMeteor},
662 piecechar={p}{\faChessPawn},
663 boardlinecolor=red]
664 \end{SideBySideExample}
665
666 \bigskip
667
668 \resetpiece
669 \cchessset{piecechar={C}{炮}}
670
671 \subsubsection{字体}
672
673 \begin{option}{ opt = piecefont, desc = {= \meta{棋子字符字体}}, init=\cs{kaishu} }
674 设置棋子字符字体。
675 \end{option}
676
677 \begin{SideBySideExample}[frame=single,numbers=left,
678 xrightmargin=.54\linewidth,gobble=2]
679 \centering
680 % 为便排版,进行缩放
681 \cchessset{resize/type=real,
682 resize/width=.90\linewidth}
683 \cchessboard[piecefont=\sffamily]
684 \end{SideBySideExample}
685
686 \bigskip
687
688 \subsubsection{边框类型}
689
690 \begin{option}{ opt = piecetype, desc = {= \meta{棋子边框类型}}, init=|ooo| }
691 设置棋子外框类型,目前支持:
692 \end{option}
693
694 \begin{Description}[a]
695 \item |o|---实心填充圆(小写英文字母``|o|'')。
696 \item |oo|---双同心实心圆。
697 \item |ooo|---双同心实心圆叠加阴影错位圆。
698 \end{Description}
699
700 \begin{SideBySideExample}[frame=single,numbers=left,
701 xrightmargin=.55\linewidth,gobble=2]
702 \centering
703 % 为便排版,进行缩放
704 \cchessset{resize/type=real,
705 resize/width=.40\linewidth}
706 \cchessboard[piecetype=o]\quad
707 \cchessboard[piecetype=oo]\\
708 \cchessboard[piecetype=ooo]
709 \end{SideBySideExample}
710
711 \bigskip
712
713 \subsubsection{边框线宽}
714
715 \begin{option}{ opt = boxlinewd, desc = {= \meta{棋子外框线宽度}}, init=0.4pt }
716 设置棋子外框线线宽。
717 \end{option}
718
719 \begin{SideBySideExample}[frame=single,numbers=left,
720 xrightmargin=.60\linewidth,gobble=2]
721 \centering
722 % 为便排版,进行缩放
723 \cchessset{resize/type=real,
724 resize/width=.95\linewidth}
725 \cchessboard[boxlinewd=0.8pt]
726 \end{SideBySideExample}
727
728 \bigskip
729
730 \subsubsection{边框颜色}
731
732 \begin{option}{ opt = boxcolor, desc = {= \meta{棋子外框线颜色}}, init=black }
733 设置棋子外框线颜色。
734 \end{option}
735
736 \begin{SideBySideExample}[frame=single,numbers=left,
737 xrightmargin=.60\linewidth,gobble=2]
738 \centering
739 % 为便排版,进行缩放
740 \cchessset{resize/type=real,
741 resize/width=.95\linewidth}
742 \cchessboard[boxcolor=white]
743 \end{SideBySideExample}
744
745 \bigskip
746
747 \subsubsection{红棋字符颜色}
748
749 \begin{option}{ opt = redpiece, desc = {= \meta{红棋棋子字符颜色}}, init=red }
750 设置红棋棋子字符颜色。
751 \end{option}
752
753 \begin{SideBySideExample}[frame=single,numbers=left,
754 xrightmargin=.60\linewidth,gobble=2]
755 \centering
756 % 为便排版,进行缩放
757 \cchessset{resize/type=real,
758 resize/width=.95\linewidth}
759 \cchessboard[redpiece=white]
760 \end{SideBySideExample}
761
762 \bigskip
763
764 \subsubsection{黑棋字符颜色}
765
766 \begin{option}{ opt = blkpiece, desc = {= \meta{黑棋棋子字符颜色}}, init=black }
767 设置黑棋棋子字符颜色。
768 \end{option}
769
770 \begin{SideBySideExample}[frame=single,numbers=left,
771 xrightmargin=.60\linewidth,gobble=2]
772 \centering
773 % 为便排版,进行缩放
774 \cchessset{resize/type=real,
775 resize/width=.95\linewidth}
776 \cchessboard[blkpiece=white]
777 \end{SideBySideExample}
778
779 \bigskip
780
781 \subsubsection{背景圆填充色}
782
783 \begin{option}{ opt = lower, desc = {= \meta{棋子背景圆填充色}}, init=init-none }
784 设置棋子背景圆填充色。
785 \end{option}
786
787 \begin{SideBySideExample}[frame=single,numbers=left,
788 xrightmargin=.60\linewidth,gobble=2]
789 \centering
790 % 为便排版,进行缩放
791 \cchessset{resize/type=real,
792 resize/width=.95\linewidth}
793 \cchessboard[lower=black]
794 \end{SideBySideExample}
795
796 \bigskip
797
798 \subsubsection{表面圆环填充色}
799
800 \begin{option}{ opt = donut, desc = {= \meta{棋子表面圆环填充色}}, init=init-none }
801 设置棋子表面圆环填充色。
802 \end{option}
803
804 \begin{SideBySideExample}[frame=single,numbers=left,
805 xrightmargin=.60\linewidth,gobble=2]
806 \centering
807 % 为便排版,进行缩放
808 \cchessset{resize/type=real,
809 resize/width=.95\linewidth}
810 \cchessboard[donut=red]
811 \end{SideBySideExample}
812
813 \bigskip
814
815 \subsubsection{红棋表面圆填充色}
816
817 \begin{option}{ opt = redupper, desc = {= \meta{红棋棋子表面圆填充色}}, init=init-none }
818 设置红棋棋子表面圆填充色。
819 \end{option}
820
821 \begin{SideBySideExample}[frame=single,numbers=left,
822 xrightmargin=.60\linewidth,gobble=2]
823 \centering
824 % 为便排版,进行缩放
825 \cchessset{resize/type=real,
826 resize/width=.95\linewidth}
827 \cchessboard[redupper=red,
828 redpiece=white]
829 \end{SideBySideExample}
830
831 \bigskip
832
833 \subsubsection{黑棋表面圆填充色}
834
835 \begin{option}{ opt = blkupper, desc = {= \meta{黑棋棋子表面圆填充色}}, init=init-none }
836 设置黑棋棋子表面圆填充色。
837 \end{option}
838
839 \begin{SideBySideExample}[frame=single,numbers=left,
840 xrightmargin=.60\linewidth,gobble=2]
841 \centering
842 % 为便排版,进行缩放
843 \cchessset{resize/type=real,
844 resize/width=.95\linewidth}
845 \cchessboard[blkupper=black,
846 blkpiece=white]
847 \end{SideBySideExample}
848
849 \bigskip
850
851 \subsubsection{阴影错位圆填充色}
852
853 \begin{option}{ opt = shadow, desc = {= \meta{棋子阴影错位圆填充色}}, init=init-none }
854 设置棋子阴影错位圆填充色。
855 \end{option}
856
857 \begin{SideBySideExample}[frame=single,numbers=left,
858 xrightmargin=.60\linewidth,gobble=2]
859 \centering
860 % 为便排版,进行缩放
861 \cchessset{resize/type=real,
862 resize/width=.95\linewidth}
863 \cchessboard[shadow=red!80]
864 \end{SideBySideExample}
865
866 \bigskip
867
868 \subsubsection{笔划}
869
870 \begin{option}{ opt = scharstroke, desc = {= \meta{棋子字符笔划类型}}, init=bold }
871 设置棋子字符笔划类型。
872 \end{option}
873
874 \begin{Description}[a]
875 \item |none|---默认笔划。
876 \item |solid|---实线笔划轮廓,笔划内部透明,颜色使用字符颜色。
877 \item |white|---实线白色笔划轮廓,笔划内部用白色填充。
878 \item |bold|---加粗笔划,颜色使用字符颜色。
879 \item |invisible|---隐藏笔划。
880 \end{Description}
881
882 \begin{SideBySideExample}[frame=single,numbers=left,
883 xrightmargin=.58\linewidth,gobble=2]
884 \centering
885 % 为便排版,进行缩放
886 \cchessset{resize/type=real,
887 resize/width=.95\linewidth}
888 \cchessboard[charstroke=white,
889 redupper=red,blkupper=black]
890 \end{SideBySideExample}
891
892 \bigskip
893
894 \subsection{打谱}
895
896 打谱参数位于|man|子选项中,可以使用|man={label=test}|或
897 |man/label=test|两种形式进行设置。
898
899 \subsubsection{label标签}
900
901 \begin{option}{ opt = label, desc = {= \meta{棋谱标签}}, init=init-none }
902 设置\env{setcchessman*}打谱环境交叉引用标签。
903 \end{option}
904
905 该选项目前仅支持\env{setcchessman*}打谱环境。
906
907 \subsubsection{每行棋谱步数}
908
909 \begin{option}{ opt = nums, desc = {= \meta{每行棋谱步数}}, init=2 }
910 设置\tn{printman}输出棋谱时,每行输出棋谱的步数。
911 \end{option}
912
913 该选项只在\tn{printman}命令中起作用。
914
915 \textbf{\textsf{说明: }}由于在前一个示例中使用了|[charstroke=white]|%
916 参数,为恢复棋子外观,需要执行一次棋子相关设置参数。
917
918 但要注意的是|setcchessman*|星号环境并不执行棋子棋盘重构,因此,此处
919 需要在\tn{cchessset}命令中重新设置棋子笔划类型。
920
921 \begin{SideBySideExample}[frame=single,numbers=left,
922 xrightmargin=.45\linewidth,gobble=2]
923 \centering
924 \printman{test}
925 % 为便排版,进行缩放
926 \cchessset{charstroke=bold,
927 resize/type=real,
928 resize/width=0.90\linewidth}
929 \begin{setcchessman*}[man/label=test]
930 % 残局初始化
931 \init{ {{4,0}{K}}, {{2,2}{p}},
932 {{1,7}{C}}, {{4,9}{k}} }
933 % 添加棋子
934 \set{e,d}{P} \set{8,g}{h}
935 % 删除棋子
936 \del{4,3}
937 % 移动棋子
938 \mov{C}{b,h}{b,b} \mov{p}{2,2}{3,2}
939 \mov{K}{4,0}{4,1} \mov{h}{8,6}{6,7}
940 \mov{K}{4,1}{3,1} \mov{h}{6,7}{5,5}
941 \end{setcchessman*}
942 \begin{flushleft}
943 \small
944 \printman[man/nums=4]{test}
945 \end{flushleft}
946 \end{SideBySideExample}
947
948 \subsection{棋谱缩放}
949
950 缩放方式位于|resize|子选项中,可以使用|resize={type=real}|或
951 |resize/xscale=0.5|两种形式进行设置。
952
953 \subsubsection{缩放方式}
954
955 \begin{option}{ opt = type, desc = {= \meta{棋谱缩放方式}}, init=none }
956 设置最终棋谱输出时的整体缩放方式,目前支持:
957 \end{option}
958
959 \begin{Description}[a]
960 \item |none|---无缩放。
961 \item |real|---按指定的width、height、xscale或yscale进行缩放。
962 \end{Description}
963
964 \bigskip
965
966 \subsubsection{横向缩放因子}
967
968 \begin{option}{ opt = xscale, desc = {= \meta{x方向缩放系数}}, init=1 }
969 设置x方向缩放系数,需要配合|resize|缩放方式参数一起使用。
970 \end{option}
971
972 \begin{SideBySideExample}[frame=single,numbers=left,
973 xrightmargin=.48\linewidth,gobble=2]
974 \centering
975 \cchessboard[resize/type=real,
976 resize/xscale=0.5]
977 \end{SideBySideExample}
978
979
980 \bigskip
981
982 \subsubsection{纵向缩放因子}
983
984 \begin{option}{ opt = yscale, desc = {= \meta{y方向缩放系数}}, init=1 }
985 设置y方向缩放系数,需要配合|resize|缩放方式参数一起使用。
986 \end{option}
987
988 \begin{SideBySideExample}[frame=single,numbers=left,
989 xrightmargin=.70\linewidth,gobble=2]
990 \centering
991 \cchessboard[%
992 resize/type=real,
993 resize/yscale=0.5]
994 \end{SideBySideExample}
995
996 \bigskip
997
998 \subsubsection{横向尺寸}
999
1000 \begin{option}{ opt = width, desc = {= \meta{宽度}}, init=init-none }
1001 设置输出宽度,需要配合|resize|缩放方式参数一起使用。
1002 \end{option}
1003
1004 \begin{SideBySideExample}[frame=single,numbers=left,
1005 xrightmargin=.65\linewidth,gobble=2]
1006 \centering
1007 \cchessboard[%
1008 resize/type=real,
1009 resize/width=7cm]
1010 \end{SideBySideExample}
1011
1012 \bigskip
1013
1014 \subsubsection{纵向尺寸}
1015
1016 \begin{option}{ opt = height, desc = {= \meta{高度}}, init=init-none }
1017 设置输出高度,需要配合|resize|缩放方式参数一起使用。
1018 \end{option}
1019
1020 \begin{SideBySideExample}[frame=single,numbers=left,
1021 xrightmargin=.65\linewidth,gobble=2]
1022 \centering
1023 \cchessboard[%
1024 resize/type=real,
1025 resize/height=6cm]
1026 \end{SideBySideExample}
1027
1028 \textbf{\textsf{说明: }}缩放纵/横参数可以混合使用。
1029
1030 \bigskip
1031
1032 % \bigskip
1033
1034 % \title{
1035 % \pkg{chinesechess} package for writing Chinese chess
1036 % \rlap{\makebox[4cm][r]{
1037 % \normalsize $\Longrightarrow$ \color{red}
1038 % \protect\hyperlink{zh}{中文版本}
1039 % \protect\hypertarget{en}{}
1040 % }}
1041 % }
1042 % \author{Nan Geng \texttt{<[email protected]>}}
1043 % \date{\today\qquad \vers}
1044 % \maketitle
1045 %
1046 % \section{Introduction}
1047 %
1048 % \section{Interface}
1049 %
1050 % \section{options}
1051
1052 \end{documentation}
1053
1054 \end{document}