From f13b318e9141d8f73521ec9e249647ebb38c6510 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 11 May 2022 03:00:53 +0000 Subject: CTAN sync 202205110300 --- macros/latex/contrib/chinesechess/README.md | 27 +- macros/latex/contrib/chinesechess/chinesechess.pdf | Bin 4096186 -> 4155609 bytes macros/latex/contrib/chinesechess/chinesechess.sty | 707 ++++++++++++++------- macros/latex/contrib/chinesechess/chinesechess.tex | 450 ++++++++----- macros/latex/contrib/fancyhdr/README | 2 +- macros/latex/contrib/fancyhdr/fancyhdr.dtx | 208 ++++-- macros/latex/contrib/fancyhdr/fancyhdr.pdf | Bin 787804 -> 851692 bytes 7 files changed, 914 insertions(+), 480 deletions(-) (limited to 'macros/latex/contrib') diff --git a/macros/latex/contrib/chinesechess/README.md b/macros/latex/contrib/chinesechess/README.md index 6e3077d2aa..f1733f8909 100644 --- a/macros/latex/contrib/chinesechess/README.md +++ b/macros/latex/contrib/chinesechess/README.md @@ -8,11 +8,11 @@ You can read the manual (in Chinese) for more details and examples. Contributing ------------ - - - - -1. gitee repository: +1. github repository: + 1. repository: [chinesechess](https://github.com/registor/chinesechess) + 2. Issues and pull requests are welcome. [issue](https://github.com/registor/chinesechess/issues) or [pull request](https://github.com/registor/chinesechess/pulls). + +2. gitee repository: 1. repository: [chinesechess](https://gitee.com/nwafu_nan/chinesechess) 2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/chinesechess/issues) or [pull request](https://gitee.com/nwafu_nan/chinesechess/pulls). @@ -55,9 +55,10 @@ Contributing \mov{p}{2,2}{3,2} \end{setcchessman} -% 可以使用带星号的打谱环境,同时将行棋过程按棋谱描述同时输出 -% 但此时需要注意排版版面限制问题。 -\begin{setcchessman*}[boardtype=x+tn] +% 可以使用带星号的打谱环境, +% 此时可以用label标签标记该打谱环境。 +% 然后在需要的位置用`\printman{label}`输出打谱结果 +\begin{setcchessman*}[boardtype=x+tn, label=test] % 残局初始化 \init{ {{4,0}{K}}, {{2,2}{p}}, {{1,7}{C}}, {{4,9}{k}} } @@ -73,6 +74,8 @@ Contributing \mov{K}{4,1}{3,1} \mov{h}{6,7}{5,5} \end{setcchessman*} + +\printman{test} ``` ## 使用方法 @@ -110,11 +113,11 @@ Contributing ## 参与贡献 --------------------- - - - +1. github仓库: + (1). 仓库地址: [chinesechess](https://github.com/registor/chinesechess) + (2). Issues和PR: [issue](https://github.com/registor/chinesechess/issues) or [pull request](https://github.com/registor/chinesechess/pulls). -1. gitee仓库: +2. gitee仓库: (1). 仓库地址: [chinesechess](https://gitee.com/nwafu_nan/chinesechess) (2). Issues and PR: [issue](https://gitee.com/nwafu_nan/chinesechess/issues) or [pull request](https://gitee.com/nwafu_nan/chinesechess/pulls). diff --git a/macros/latex/contrib/chinesechess/chinesechess.pdf b/macros/latex/contrib/chinesechess/chinesechess.pdf index a965c4fe30..5238290f51 100644 Binary files a/macros/latex/contrib/chinesechess/chinesechess.pdf and b/macros/latex/contrib/chinesechess/chinesechess.pdf differ diff --git a/macros/latex/contrib/chinesechess/chinesechess.sty b/macros/latex/contrib/chinesechess/chinesechess.sty index 2a2db971ed..b988871013 100644 --- a/macros/latex/contrib/chinesechess/chinesechess.sty +++ b/macros/latex/contrib/chinesechess/chinesechess.sty @@ -19,7 +19,7 @@ %% \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{expl3} -\ProvidesExplPackage{chinesechess}{2022-05-06}{v1.1.0} +\ProvidesExplPackage{chinesechess}{2022-05-09}{v1.2.0} {Typeset Chinese chess with l3draw} \RequirePackage { l3keys2e, l3draw, xparse } @@ -34,7 +34,7 @@ % 棋盘排版命令用户接口 % #1 星号命令,是否输出棋子 % #2 棋盘类型、棋子类型等外观选项 -\NewDocumentCommand{\cchessboard}{ s O{} } +\NewDocumentCommand{\cchessboard}{ s o } { \group_begin: % 星号命令是否带棋子 @@ -44,8 +44,35 @@ }{ \bool_set_true:N \l__cchess_board_pieces_bool } - % 选项设置 - \keys_set:nn { cchess } { #2 } + + \IfNoValueF { #2 } + { + % 设置选项 + \keys_set:nn { cchess } { #2 } + + % 有draft参数,需要重构棋子和棋盘 + \tl_if_in:nnT { #2 } { draft } + { + % 构建棋盘 + \__cchess_board_construct: + % 构建红黑各9个棋子 + \__cchess_pieces_construct: + } + + \bool_if:NF \g__cchess_draft_bool + { + % 构建棋盘 + \__cchess_board_option_if_in:nT { #2 } + { + \__cchess_board_construct: + } + % 构建红黑各9个棋子 + \__cchess_piece_option_if_in:nT { #2 } + { + \__cchess_pieces_construct: + } + } + } \__cchess_board_output: \group_end: } @@ -57,11 +84,37 @@ % 黑棋:k=将,a=士,e/b=象,r=車,c=炮,n/h=馬,p=卒 % 横向定位: a(0),b(1),c(2),d(3),e(4),f(5),g(6),h(7),i(8) % 纵向定位: a(0),b(1),c(2),d(3),e(4),f(5),g(6),h(7),i(8),j(9) -\NewDocumentCommand{\cchessman}{ O{} m } +\NewDocumentCommand{\cchessman}{ o m } { \group_begin: - % 选项设置 - \keys_set:nn { cchess } { #1 } + % 设置选项 + \IfNoValueF { #1} + { + \keys_set:nn { cchess } { #1 } + + % 有draft参数,需要重构棋子和棋盘 + \tl_if_in:nnT { #1 } { draft } + { + % 构建棋盘 + \__cchess_board_construct: + % 构建红黑各9个棋子 + \__cchess_pieces_construct: + } + + \bool_if:NF \g__cchess_draft_bool + { + % 构建棋盘 + \__cchess_board_option_if_in:nT { #1 } + { + \__cchess_board_construct: + } + % 构建红黑各9个棋子 + \__cchess_piece_option_if_in:nT { #1 } + { + \__cchess_pieces_construct: + } + } + } \__cchess_manual_output:n { #2 } \group_end: } @@ -69,29 +122,35 @@ % 棋子字符复位 \NewDocumentCommand{\resetpiece}{} { - % 定义棋子字符常量 - \clist_map_inline:nn - { - { K } { 帥 }, % 帥\__cchess_symbol:n {"5E25} - { A } { 仕 }, % 仕\__cchess_symbol:n {"4ED5} - { E } { 相 }, % 相\__cchess_symbol:n {"76F8} - { B } { 相 }, % 相\__cchess_symbol:n {"76F8} - { H } { 马 }, % 马\__cchess_symbol:n {"9A6C} - { N } { 马 }, % 马\__cchess_symbol:n {"9A6C} - { R } { 车 }, % 车\__cchess_symbol:n {"8F66} - { C } { 砲 }, % 砲\__cchess_symbol:n {"7832} - { P } { 兵 }, % 兵\__cchess_symbol:n {"5175} - { k } { 將 }, % 將\__cchess_symbol:n {"5C07} - { a } { 士 }, % 士\__cchess_symbol:n {"58EB} - { e } { 象 }, % 象\__cchess_symbol:n {"8C61} - { b } { 象 }, % 象\__cchess_symbol:n {"8C61} - { h } { 馬 }, % 馬\__cchess_symbol:n {"99AC} - { n } { 馬 }, % 馬\__cchess_symbol:n {"99AC} - { r } { 車 }, % 車\__cchess_symbol:n {"8ECA} - { c } { 炮 }, % 炮\__cchess_symbol:n {"70AE} - { p } { 卒 }, % 卒\__cchess_symbol:n {"5352} - } - { \__cchess_piece_char_setup:nn ##1 } + % 定义棋子字符常量 + \clist_map_inline:nn + { + { K } { 帥 }, % 帥\__cchess_symbol:n {"5E25} + { A } { 仕 }, % 仕\__cchess_symbol:n {"4ED5} + { E } { 相 }, % 相\__cchess_symbol:n {"76F8} + { B } { 相 }, % 相\__cchess_symbol:n {"76F8} + { H } { 马 }, % 马\__cchess_symbol:n {"9A6C} + { N } { 马 }, % 马\__cchess_symbol:n {"9A6C} + { R } { 车 }, % 车\__cchess_symbol:n {"8F66} + { C } { 砲 }, % 砲\__cchess_symbol:n {"7832} + { P } { 兵 }, % 兵\__cchess_symbol:n {"5175} + { k } { 將 }, % 將\__cchess_symbol:n {"5C07} + { a } { 士 }, % 士\__cchess_symbol:n {"58EB} + { e } { 象 }, % 象\__cchess_symbol:n {"8C61} + { b } { 象 }, % 象\__cchess_symbol:n {"8C61} + { h } { 馬 }, % 馬\__cchess_symbol:n {"99AC} + { n } { 馬 }, % 馬\__cchess_symbol:n {"99AC} + { r } { 車 }, % 車\__cchess_symbol:n {"8ECA} + { c } { 炮 }, % 炮\__cchess_symbol:n {"70AE} + { p } { 卒 }, % 卒\__cchess_symbol:n {"5352} + } + { \__cchess_piece_char_setup:nn ##1 } + + \bool_if:NF \g__cchess_draft_bool + { + % 构建红黑各9个棋子 + \__cchess_pieces_construct: + } } % 棋子字符设置命令 @@ -101,6 +160,12 @@ \NewDocumentCommand{\piecechar}{ m m } { \__cchess_piece_char_setup:nn { #1 } { #2 } + + \bool_if:NF \g__cchess_draft_bool + { + % 构建红黑各9个棋子 + \__cchess_pieces_construct: + } } % 打谱环境初始化(仅用于setcchessman环境中) @@ -155,11 +220,39 @@ % 打谱排版环境用户接口 % #1 棋盘类型、棋子类型等外观选项 -\NewDocumentEnvironment{ setcchessman }{ O{} +b } +\NewDocumentEnvironment{ setcchessman }{ o +b } { \group_begin: \bool_set_false:N \l__cchess_with_setman_bool - \keys_set:nn { cchess } { #1 } + + % 设置选项 + \IfNoValueF { #1} + { + \keys_set:nn { cchess } { #1 } + + % 有draft参数,需要重构棋子和棋盘 + \tl_if_in:nnT { #1 } { draft } + { + % 构建棋盘 + \__cchess_board_construct: + % 构建红黑各9个棋子 + \__cchess_pieces_construct: + } + + \bool_if:NF \g__cchess_draft_bool + { + % 构建棋盘 + \__cchess_board_option_if_in:nT { #1 } + { + \__cchess_board_construct: + } + % 构建红黑各9个棋子 + \__cchess_piece_option_if_in:nT { #1 } + { + \__cchess_pieces_construct: + } + } + } \__cchess_setcchessman_pre_setup:n { #2 } }{ \__cchess_setcchessman_post_setup: @@ -168,10 +261,11 @@ % 打谱排版星号环境用户接口,用于同时输出棋谱描述 % #1 棋盘类型、棋子类型等外观选项 -\NewDocumentEnvironment{ setcchessman* }{ O{} +b } +\NewDocumentEnvironment{ setcchessman* }{ o +b } { \group_begin: \bool_set_true:N \l__cchess_with_setman_bool + % 设置选项 \keys_set:nn { cchess } { #1 } \__cchess_setcchessman_pre_setup:n { #2 } }{ @@ -186,6 +280,7 @@ \NewDocumentCommand{\printman}{ O{} >{\TrimSpaces} m } % 去掉两侧空格 { \group_begin: + % 设置选项 \keys_set:nn { cchess } { #1 } \__cchess_setman_print:n { #2 } \group_end: @@ -222,44 +317,7 @@ % 绘制棋盘时是否带有棋子标志 \bool_new:N \l__cchess_board_pieces_bool \bool_new:N \l__cchess_with_setman_bool - -% 棋子类型 -\tl_new:N \l__cchess_piece_box_type_tl -% 棋子类型列表 -\clist_new:N \g__cchess_piece_box_list_clist -% 棋盘类型 -\tl_new:N \l__cchess_board_type_tl -% 棋盘类型列表 -\clist_new:N \g__cchess_board_list_clist - -% 缩放方式 -\tl_new:N \l__cchess_resize_method_tl -% 缩放方式列表 -\clist_new:N \g__cchess_resize_method_clist - -% 棋谱输出宽度 -\dim_new:N \l__cchess_manual_width_dim -% 棋谱输出高度 -\dim_new:N \l__cchess_manual_height_dim -% 棋盘宽度 -\dim_new:N \l__cchess_board_width_dim -% 棋盘高度 -\dim_new:N \l__cchess_board_height_dim -% 棋盘线线宽 -\dim_new:N \l__cchess_board_linewidth_dim -% 辅线线宽 -\dim_new:N \l__cchess_cross_linewidth_dim -% 辅线间距 -\dim_new:N \l__cchess_cross_sep_dim -% 棋子字符正方形外接圆半径 -\dim_new:N \l__cchess_piece_box_radius_dim -% 棋子外框线线宽 -\dim_new:N \l__cchess_box_linewidth_dim -% 临时尺寸变量 -\dim_new:N \l__cchess_tmpa_dim -\dim_new:N \l__cchess_tmpb_dim -\dim_new:N \l__cchess_tmpc_dim -\dim_new:N \l__cchess_tmpd_dim +\bool_new:N \g__cchess_draft_bool % 棋子容器 % 当前中国象棋主流软件的棋子代码,多沿用: @@ -427,18 +485,56 @@ \coffin_new:c { l_char_tmp #1 _coffin } } +% 棋子类型 +\tl_new:N \l__cchess_piece_box_type_tl +% 棋子类型列表 +\clist_new:N \g__cchess_piece_box_list_clist +% 棋盘类型 +\tl_new:N \l__cchess_board_type_tl +% 棋盘类型列表 +\clist_new:N \g__cchess_board_list_clist + +% 缩放方式 +\tl_new:N \l__cchess_resize_method_tl +% 缩放方式列表 +\clist_new:N \g__cchess_resize_method_clist + +% 棋谱输出宽度 +\dim_new:N \l__cchess_manual_width_dim +% 棋谱输出高度 +\dim_new:N \l__cchess_manual_height_dim + +% 棋盘宽度 +\dim_new:N \l__cchess_board_width_dim +% 棋盘高度 +\dim_new:N \l__cchess_board_height_dim + +% 棋盘线线宽 +\dim_new:N \l__cchess_board_linewidth_dim +% 辅线线宽 +\dim_new:N \l__cchess_cross_linewidth_dim +% 辅线间距 +\dim_new:N \l__cchess_cross_sep_dim +% 棋子字符正方形外接圆半径 +\dim_new:N \l__cchess_piece_box_radius_dim +% 棋子外框线线宽 +\dim_new:N \l__cchess_box_linewidth_dim + +% 棋盘格子尺寸 +\dim_new:N \gridsize +% 棋子整体尺寸 +\dim_new:N \piecesize % 棋子字符包围盒尺寸 \dim_new:N \charboxsize % 棋子字符包围盒尺寸半长 \dim_new:N \semicharboxsize -% 棋子整体尺寸 -\dim_new:N \piecesize -% 棋盘格子尺寸 -\dim_new:N \gridsize -% 棋子缩放比例 -\tl_new:N \l__cchess_piece_scale_tl -% 待处理棋子字符 -\tl_new:N \l__cchess_pieces_tl + +% 临时尺寸变量 +\dim_new:N \l__cchess_tmpa_dim +\dim_new:N \l__cchess_tmpb_dim +\dim_new:N \l__cchess_tmpc_dim +\dim_new:N \l__cchess_tmpd_dim + % 棋子字符格式 \tl_new:N \l__cchess_piece_char_format_tl % 棋盘背景图片名称 @@ -463,6 +559,20 @@ \tl_new:N \l_tmpd_tl \tl_new:N \l_tmpe_tl +% ============宏包选项================= +\keys_define:nn { cchess } + { + draft .choice:, + draft / true .code:n = { \bool_set_true:N \g__cchess_draft_bool }, + draft / false .code:n = { \bool_set_false:N \g__cchess_draft_bool }, + draft .default:n = true, + draft .initial:n = false, + + unknown .code:n = { \msg_error:nn { cchess } { unknown-option } } + } + +% 将文档类选项传给cchess +% \ProcessKeysOptions { cchess } % 棋子盒子由l3draw实现, % 棋子外围盒子及缩放设计思路来自zitie宏包 @@ -531,12 +641,14 @@ \dim_gset:Nn \semicharboxsize { \fp_to_dim:n { \fp_eval:n { \charboxsize / 2 } } + % \charboxsize / 2 } % 外接圆半径 \dim_gset:Nn \l__cchess_piece_box_radius_dim { \fp_to_dim:n { \fp_eval:n { \charboxsize * sqrt(2)/ 2 } } + % \fp_to_dim:n { \fp_eval:n { \charboxsize * 0.707106781 } } } } @@ -580,17 +692,6 @@ % 无边框 \__cchess_new_piece_box_construct:nn { none } { } -% 填充外接圆 -\__cchess_new_piece_box_private_construct:nn { __outerfilledcircle } - { - \draw_scope_begin: - \color_fill:n { lowerbgboxfill } - \draw_path_circle:nn { \semicharboxsize, \semicharboxsize } - { \l__cchess_piece_box_radius_dim*#1 } - \draw_path_use_clear:n { fill } - \draw_scope_end: - } - % 底层填充外接圆 \__cchess_new_piece_box_private_construct:nn { __outerlowerfilledcircle } { @@ -650,8 +751,8 @@ % 填充外接圆叠加外接圆边框 \__cchess_new_piece_box_construct:nn { o } { - \__cchess_piece_box_type_c:n { __outerupperfilledcircle } {#1} - \__cchess_piece_box_type_c:n { __outercirclebox } {#1} + \__cchess_piece_box_type_c:n { __outerupperfilledcircle } {0.82} + \__cchess_piece_box_type_c:n { __outercirclebox } {0.82} } % 填充外接圆叠加同心82%外接圆边框 @@ -1066,6 +1167,24 @@ \draw_scope_end: } +% 无兵、炮标志全棋盘 +\__cchess_new_board_private_construct:nn { __none } + { + \hcoffin_set:Nn \l_tmpa_coffin + { + \__cchess_board_type_c:n { __semiboard } {#1} {#2} + } + % 下半部 + \draw_coffin_use:Nnn \l_tmpa_coffin { l } { b } + + % 上半部 + \draw_path_scope_begin: + \draw_transform_shift:n { \gridsize * 8, \gridsize * 9 } + \draw_transform_rotate:n { 180 } + \draw_coffin_use:Nnn \l_tmpa_coffin { l } { b } + \draw_path_scope_end: + } + % 无兵、炮标志全棋盘 \__cchess_new_board_construct:nn { x } { @@ -1326,30 +1445,29 @@ } , gridsize .initial:n = 10mm , % 棋盘类型 - boardtype .code:n = { \exp_args:NNx \clist_if_in:NnTF - \g__cchess_board_list_clist {#1} + boardtype .code:n = { \exp_args:NNx \clist_if_in:NnTF \g__cchess_board_list_clist {#1} { \tl_set:Nx \l__cchess_board_type_tl {#1} } { \msg_error:nnx { cchess } { board-exists } {#1} } }, % 棋盘线线宽 boardlinewd .code:n = { \dim_set:Nn \l__cchess_board_linewidth_dim {#1} - % 九宫线与象位线线宽 - \dim_gset:Nn \l__cchess_cross_linewidth_dim - { - \fp_to_dim:n - { - \fp_eval:n { \l__cchess_board_linewidth_dim * 0.50 } - } - } - % 炮兵位置线与棋盘线间距 - \dim_gset:Nn \l__cchess_cross_sep_dim - { - \fp_to_dim:n - { - \fp_eval:n { \l__cchess_board_linewidth_dim * 1.80 } - } - } - }, + % 九宫线与象位线线宽 + \dim_gset:Nn \l__cchess_cross_linewidth_dim + { + \fp_to_dim:n + { + \fp_eval:n { \l__cchess_board_linewidth_dim * 0.50 } + } + } + % 炮兵位置线与棋盘线间距 + \dim_gset:Nn \l__cchess_cross_sep_dim + { + \fp_to_dim:n + { + \fp_eval:n { \l__cchess_board_linewidth_dim * 1.80 } + } + } + }, boardlinewd .initial:n = 0.4pt , % 棋盘线颜色 @@ -1361,29 +1479,14 @@ boardbg .tl_set:N = \l__cchess_board_background_tl , boardbg .initial:n = {} , - % 缩放方式 - resize .code:n = { \exp_args:NNx \clist_if_in:NnTF - \g__cchess_resize_method_clist {#1} - { \tl_set:Nx \l__cchess_resize_method_tl {#1} } - { \msg_error:nnx { cchess } { resize-method } {#1} } - }, - % 缩放参数 - xscale .tl_set:N = \l__cchess_x_scale_tl , - xscale .initial:n = 1 , - yscale .tl_set:N = \l__cchess_y_scale_tl , - yscale .initial:n = 1 , - scale .meta:n = { xscale = #1 , yscale = #1 } , - width .dim_set:N = \l__cchess_manual_width_dim , - height .dim_set:N = \l__cchess_manual_height_dim , - % 设置棋子字符 piecechar .code:n = { \__cchess_piece_char_setup:nn #1 }, piecechar .initial:n = {K}{\c__cchess_K_tl} , % 字符格式 piecefont .code:n = { \tl_set:Nn \l__cchess_piece_char_format_tl {#1} - \__cchess_calc_piece_box_size: - }, + \__cchess_calc_piece_box_size: + }, % 边框类型 piecetype .code:n = { \exp_args:NNx \clist_if_in:NnTF @@ -1397,85 +1500,85 @@ boxlinewd .initial:n = 0.4pt , % 边框线颜色 - boxcolor .code:n = { \__cchess_color_select:nn { cchesspieceboxcolor } {#1} } , + boxcolor .code:n = { \__cchess_color_select:nn { cchesspieceboxcolor } {#1} } , boxcolor .initial:n = black , - boxcolor* .code:n = { \__cchess_color_select:nnn { cchesspieceboxcolor } #1 } , + boxcolor* .code:n = { \__cchess_color_select:nnn { cchesspieceboxcolor } #1 } , % 字符颜色 - redpiece .code:n = { \__cchess_color_select:nn { cchessredpiececolor } {#1} } , + redpiece .code:n = { \__cchess_color_select:nn { cchessredpiececolor } {#1} } , redpiece .initial:n = red , - redpiece* .code:n = { \__cchess_color_select:nnn { cchessredpiececolor } #1 } , - blkpiece .code:n = { \__cchess_color_select:nn { cchessblkpiececolor } {#1} } , + redpiece* .code:n = { \__cchess_color_select:nnn { cchessredpiececolor } #1 } , + blkpiece .code:n = { \__cchess_color_select:nn { cchessblkpiececolor } {#1} } , blkpiece .initial:n = black , - blkpiece* .code:n = { \__cchess_color_select:nnn { cchessblkpiececolor } #1 } , + blkpiece* .code:n = { \__cchess_color_select:nnn { cchessblkpiececolor } #1 } , % 棋子背景底层填充颜色 lower .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1} - { - \__cchess_color_select:nn { lowerbgboxfill } - { yellow!70!red } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { yellow!70!red } } - }{ \__cchess_color_select:nn { lowerbgboxfill } { #1 } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { #1 } } - } - } , + { + \__cchess_color_select:nn { lowerbgboxfill } + { yellow!70!red } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { yellow!70!red } } + }{ \__cchess_color_select:nn { lowerbgboxfill } { #1 } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { #1 } } + } + } , lower .initial:n = {} , % 无反色时上层盒子背景填充颜色 donut .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1} - { - \__cchess_color_select:nn { donutboxfill } - { yellow!80!black } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { yellow!80!black } } - }{ \__cchess_color_select:nn { donutboxfill } { #1 } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { #1 } } - } - } , + { + \__cchess_color_select:nn { donutboxfill } + { yellow!80!black } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { yellow!80!black } } + }{ \__cchess_color_select:nn { donutboxfill } { #1 } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { #1 } } + } + } , donut .initial:n = {} , % 棋子背景底层填充颜色 redupper .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1} - { - \__cchess_color_select:nn { redupperbgboxfill } - { yellow!70!red } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { yellow!70!red } } - }{ \__cchess_color_select:nn { redupperbgboxfill } { #1 } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { #1 } } - } - } , + { + \__cchess_color_select:nn { redupperbgboxfill } + { yellow!70!red } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { yellow!70!red } } + }{ \__cchess_color_select:nn { redupperbgboxfill } { #1 } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { #1 } } + } + } , redupper .initial:n = {} , % 棋子背景底层填充颜色 blkupper .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1} - { - \__cchess_color_select:nn { blkupperbgboxfill } - { yellow!70!red } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { yellow!70!red } } - }{ \__cchess_color_select:nn { blkupperbgboxfill } { #1 } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { #1 } } - } - } , + { + \__cchess_color_select:nn { blkupperbgboxfill } + { yellow!70!red } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { yellow!70!red } } + }{ \__cchess_color_select:nn { blkupperbgboxfill } { #1 } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { #1 } } + } + } , blkupper .initial:n = {} , % 盒子阴影填充颜色 shadow .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1} - { - \__cchess_color_select:nn { shadowboxfill } - { black!35!white } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { black!35!white } } - }{ \__cchess_color_select:nn { shadowboxfill } { #1 } - \cs_set_nopar:Npn \__cchess_aux_color_boxfill: - { \color_fill:n { #1 } } - } - } , + { + \__cchess_color_select:nn { shadowboxfill } + { black!35!white } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { black!35!white } } + }{ \__cchess_color_select:nn { shadowboxfill } { #1 } + \cs_set_nopar:Npn \__cchess_aux_color_boxfill: + { \color_fill:n { #1 } } + } + } , shadow .initial:n = {} , % 笔画参数 @@ -1486,14 +1589,6 @@ { \int_set_eq:NN \l__cchess_charstroke_type_int \l_keys_choice_int }, charstroke .initial:n = bold, - % 打谱环境交叉引用标签 - label .tl_gset:N = \l__cchess_setman_label_tl , - label .initial:n = {} , - - % 每行棋谱步数 - mansperline .tl_gset:N = \l__cchess_mans_per_line_int , - mansperline .initial:n = 2 , - unknown .code:n = { \msg_error:nn { cchess } { unknown-option } } } \msg_new:nnn { cchess } { unknown-option } @@ -1504,13 +1599,143 @@ piecefont = \kaishu, piecetype = ooo, boardtype = x+tn, - resize = none, + } + +\ProcessKeysOptions { cchess } + +% key_value选项设计(打谱man) +\keys_define:nn { cchess / man } + { + % 打谱环境交叉引用标签 + label .tl_gset:N = \l__cchess_setman_label_tl , + label .initial:n = {} , + + % 每行棋谱步数 + nums .tl_gset:N = \l__cchess_mans_per_line_int , + nums .initial:n = 2 , + + unknown .code:n = { \msg_error:nn { cchess } { unknown-man-option } } + } +\msg_new:nnn { cchess } { unknown-man-option } + { package~ manual~ option~ "\l_keys_key_tl"~ is~ unknown. } + +% key_value选项设计(缩放resize) +\keys_define:nn { cchess / resize } + { + % 缩放方式 + type .code:n = { \exp_args:NNx \clist_if_in:NnTF \g__cchess_resize_method_clist {#1} + { \tl_set:Nx \l__cchess_resize_method_tl {#1} } + { \msg_error:nnx { cchess } { resize-method } {#1} } + }, + % 缩放参数 + xscale .tl_set:N = \l__cchess_x_scale_tl , + xscale .initial:n = 1 , + yscale .tl_set:N = \l__cchess_y_scale_tl , + yscale .initial:n = 1 , + scale .meta:n = { xscale = #1 , yscale = #1 } , + width .dim_set:N = \l__cchess_manual_width_dim , + height .dim_set:N = \l__cchess_manual_height_dim , + + unknown .code:n = { \msg_error:nn { cchess } { unknown-resize-option } } + } +\msg_new:nnn { cchess } { unknown-resize-option } + { package~ resize~ option~ "\l_keys_key_tl"~ is~ unknown. } + +\keys_set:nn { cchess / resize } + { + type = none, + } + +% =============判断选项是否存在============= + +% 状态记录bool变量 +\bool_new:N \g__cchess_is_board_option_bool +\bool_new:N \g__cchess_is_piece_option_bool + +% 判断是否有棋盘外观参数 +\cs_new:Npn \__cchess_board_option_if_in:n #1 + { + \bool_set_false:N \g__cchess_is_board_option_bool + \clist_map_inline:nn { board,gridsize } + { + \tl_if_in:nnT { #1 } { ##1 } + { + \bool_set_true:N \g__cchess_is_board_option_bool + \clist_map_break: + } + } + } + +% 判断是否有棋子外观参数 +\cs_new:Npn \__cchess_piece_option_if_in:n #1 + { + \bool_set_false:N \g__cchess_is_piece_option_bool + \clist_map_inline:nn { piece,lower,donut,upper,shadow,box,charstroke } + { + \tl_if_in:nnT { #1 } { ##1 } + { + \bool_set_true:N \g__cchess_is_piece_option_bool + \clist_map_break: + } + } + } + +% 棋盘参数判断 +\prg_set_conditional:Npnn \__cchess_board_option_if_in:n #1 { p, T, F, TF } + { + \__cchess_board_option_if_in:n { #1 } + + \bool_if:NTF \g__cchess_is_board_option_bool + { + \prg_return_true: + }{ + \prg_return_false: + } + } + +% 棋子参数判断 +\prg_set_conditional:Npnn \__cchess_piece_option_if_in:n #1 { p, T, F, TF } + { + \__cchess_piece_option_if_in:n { #1 } + + \bool_if:NTF \g__cchess_is_piece_option_bool + { + \prg_return_true: + }{ + \prg_return_false: + } } % 选项设置用户接口 \NewDocumentCommand \cchessset { m } { - \keys_set:nn { cchess } {#1} + \IfNoValueF { #1} + { + \keys_set:nn { cchess } { #1 } + + % 有draft参数,需要重构棋子和棋盘 + \tl_if_in:nnT { #1 } { draft } + { + % 构建棋盘 + \__cchess_board_construct: + % 构建红黑各9个棋子 + \__cchess_pieces_construct: + } + + \bool_if:NF \g__cchess_draft_bool + { + % 构建棋盘 + \__cchess_board_option_if_in:nT { #1 } + { + \__cchess_board_construct: + } + % 构建红黑各9个棋子 + \__cchess_piece_option_if_in:nT { #1 } + { + \__cchess_pieces_construct: + } + } + } } % =============创建棋子coffins============= @@ -1561,29 +1786,44 @@ % 按指定颜色和格式构造棋子字符盒子容器 \hcoffin_gset:Nn \l__cchess_box_coffin { - \color_select:n { cchesspiececolor } - \tl_use:N \l__cchess_piece_char_format_tl - % 笔划处理 - \__cchess_pieces_stroke_construct:n { #1 } + \bool_if:NTF \g__cchess_draft_bool + { + \color_select:n { cchesspiececolor } + #1 + }{ + \color_select:n { cchesspiececolor } + \tl_use:N \l__cchess_piece_char_format_tl + % 笔划处理 + \__cchess_pieces_stroke_construct:n { #1 } + } } % 构造构造棋子字符盒子容器边框 \__cchess_single_box_construct: } +% gridsize,boardtype,boardlinewd,boardlinecolor,boardbg, +% piecechar,piecefont,piecetype,boxlinewd,boxcolor,redpiece,blkpiece, +% lower,donut,redupper,blkupper,shadow,charstroke % 字符盒子及边框组合盒子容器构造函数 \cs_new:Npn \__cchess_single_box_construct: { - % 绘制字符外框并拼装结果 - \draw_begin: - \draw_linewidth:n { \l__cchess_box_linewidth_dim } + \bool_if:NTF \g__cchess_draft_bool + { + \coffin_typeset:cnnnn { l__cchess_box_coffin } + { l } { b } { 0pt } { 0pt } + }{ + % 绘制字符外框并拼装结果 + \draw_begin: + \draw_linewidth:n { \l__cchess_box_linewidth_dim } - \draw_path_scope_begin: - \__cchess_piece_box_type_c:n { \l__cchess_piece_box_type_tl } { 1.0 } - \draw_transform_shift:n {\charboxsize / 2.0, \charboxsize / 2.0 } - \draw_coffin_use:Nnn \l__cchess_box_coffin { hc } { vc } - \draw_path_scope_end: - \draw_end: + \draw_path_scope_begin: + \__cchess_piece_box_type_c:n { \l__cchess_piece_box_type_tl } { 1.0 } + \draw_transform_shift:n {\charboxsize / 2.0, \charboxsize / 2.0 } + \draw_coffin_use:Nnn \l__cchess_box_coffin { hc } { vc } + \draw_path_scope_end: + \draw_end: + } } % =============创建棋子占位coffins============= @@ -1655,12 +1895,15 @@ \dim_add:Nn \l_tmpa_dim { \piecesize / 2 } \dim_add:Nn \l_tmpb_dim { \piecesize / 2 } - % 构建背景图片coffin - \__cchess_board_backgroud_construct: + \bool_if:NF \g__cchess_draft_bool + { + % 构建背景图片coffin + \__cchess_board_backgroud_construct: - % 缩放背景图片coffin - \coffin_resize:Nnn \l__cchess_board_background_coffin - { \l_tmpa_dim } { \l_tmpb_dim } + % 缩放背景图片coffin + \coffin_resize:Nnn \l__cchess_board_background_coffin + { \l_tmpa_dim } { \l_tmpb_dim } + } % 绘制总边框外线 \hcoffin_set:Nn \l__cchess_tmpa_coffin @@ -1690,7 +1933,10 @@ \draw_begin: \draw_path_scope_begin: \draw_transform_shift:n { \l_tmpa_dim / 2, \l_tmpa_dim / 2 } - \draw_coffin_use:Nnn \l__cchess_board_background_coffin { hc } { vc } + \bool_if:NF \g__cchess_draft_bool + { + \draw_coffin_use:Nnn \l__cchess_board_background_coffin { hc } { vc } + } \draw_coffin_use:Nnn \l__cchess_tmpa_coffin { hc } { vc } \draw_coffin_use:Nnn \l__cchess_tmpb_coffin { hc } { vc } \draw_coffin_use:Nnn \l__cchess_manual_coffin { hc } { vc } @@ -1710,7 +1956,12 @@ \draw_linewidth:n { \l__cchess_board_linewidth_dim } \draw_path_scope_begin: - \__cchess_board_type_c:n { \l__cchess_board_type_tl } { 1.0 } { 1.0 } + \bool_if:NTF \g__cchess_draft_bool + { + \__cchess_board_type_c:n { x } { 1.0 } { 1.0 } + }{ + \__cchess_board_type_c:n { \l__cchess_board_type_tl } { 1.0 } { 1.0 } + } \draw_path_scope_end: \draw_end: } @@ -1729,8 +1980,8 @@ % 在正文中排版棋子 \cs_new:Npn \__cchess_getpiece_handle:nn #1#2 { - % 构建红黑各7个棋子 - \__cchess_pieces_construct: + % 构建红黑各9个棋子 + % \__cchess_pieces_construct: % 设置指定格式的基字符盒子 \hbox_set:Nn \l_tmpa_box { #1 将 } @@ -1763,15 +2014,21 @@ { l } { b } { 0pt } { -\l_tmpb_dim } } +% 构建棋盘 +\__cchess_board_construct: + +% 构建红黑各9个棋子 +\__cchess_pieces_construct: + % =============排版棋谱============= % 棋谱排版 \cs_new:Npn \__cchess_manual_output:n #1 { % 构建棋盘 - \__cchess_board_construct: + % \__cchess_board_construct: - % 构建红黑各7个棋子 - \__cchess_pieces_construct: + % 构建红黑各9个棋子 + % \__cchess_pieces_construct: % 构建棋子画布盒子容器 \__cchess_board_piece_pos_construct:n { #1 } @@ -1807,13 +2064,13 @@ \cs_new:Nn \__cchess_board_output: { % 创建棋盘 - \__cchess_board_construct: + % \__cchess_board_construct: % 是否需要棋子 \bool_if:NT \l__cchess_board_pieces_bool { - % 构建红黑各7个棋子 - \__cchess_pieces_construct: + % 构建红黑各9个棋子 + % \__cchess_pieces_construct: % 创建32个棋子画布盒子容器 \__cchess_board_piece_pos_construct:n @@ -2310,9 +2567,9 @@ \cs_new:Npn \__cchess_setcchessman_pre_setup:n #1 { % 构建棋盘 - \__cchess_board_construct: - % 构建红黑各7个棋子 - \__cchess_pieces_construct: + % \__cchess_board_construct: + % 构建红黑各9个棋子 + % \__cchess_pieces_construct: % 删除环境中的代码中的空白 \tl_set:Nn \l_tmpa_tl { #1 } diff --git a/macros/latex/contrib/chinesechess/chinesechess.tex b/macros/latex/contrib/chinesechess/chinesechess.tex index 60404db623..b77b6011e2 100644 --- a/macros/latex/contrib/chinesechess/chinesechess.tex +++ b/macros/latex/contrib/chinesechess/chinesechess.tex @@ -7,8 +7,8 @@ \usepackage{graphicx} \usepackage{fontawesome5} \usepackage{fancyvrb-ex} -\usepackage{chinesechess} -\cchessset{piecechar={C}{炮}} +\usepackage[piecechar={C}{炮}]{chinesechess} +% \usepackage[draft,piecechar={C}{炮}]{chinesechess} \IndexPrologue { @@ -123,7 +123,7 @@ { \__codedoc_cmd:no {#1} { #2 } } \ExplSyntaxOff -\def\vers{\texttt{v1.1.0} } +\def\vers{\texttt{v1.2.0} } \begin{document} \title{ @@ -139,8 +139,24 @@ % \thanks{\url{https://github.com/registor/chinesechess}} \thanks{\url{https://gitee.com/nwafu_nan/chinesechess}} } + \maketitle +\begin{abstract} + \pkg{chinesechess}是一个基于\pkg{l3draw}绘图宏包,用\pkg{Expl3}% + 开发的中国象棋排版宏包。它提供了\tn{cchessboard}(全棋盘)、% + \tn{cchessbord*}(空棋盘)和\tn{cchessman}(棋谱)排版命令。同时, + 该宏包还提供了用于打谱的排版环境\env{setcchessman},在该环境 + 中,可以通过环境专用命令\tn{init}(初始化棋谱状态),\tn{set}(在 + 指定位置布置棋子),\tn{del}(删除指定位置的棋子),\tn{mov}(实现 + 棋子的移动)实现打谱操作,并在环境结束后排版最终状态棋谱。 + 通过其星号环境\env{setcchessman*}可以记录打谱过程,并通过% + \tn{printman}利用交叉引用标签\oarg{label}选项对指定% + \env{setcchessman*}打谱环境记录的打谱文本在指定位置排版输出。 + 棋子、棋盘、背景等外观可以通过命令、环境选项或\tn{cchessset}% + 命令进行设置。 +\end{abstract} + {\small \tableofcontents } @@ -151,16 +167,12 @@ \section{引言} \pkg{chinesechess}是一个基于\pkg{l3draw}绘图宏包,用\pkg{Expl3}% -开发的中国象棋排版宏包。它提供了\tn{cchessboard}(全棋盘)、% -\tn{cchessbord*}(空棋盘)和\tn{cchessman}(棋谱)排版命令。同时, -该宏包还提供了用于打谱的排版环境\env{setcchessman},在该环境 -中,可以通过环境专用命令\tn{init}(初始化棋谱状态),\tn{set}(在 -指定位置布置棋子),\tn{del}(删除指定位置的棋子),\tn{mov}(实现 -棋子的移动),从而实现打谱操作,并在环境结束后以最终状态排版棋谱。 -另外,也可以通过星号环境\env{setcchessman*}实现棋谱文本输出。 +开发的中国象棋排版宏包。它利用\pkg{l3draw}的绘图功能,通过为红黑 +各7个棋子文字添加背景实现了棋子绘制,利用简单线条实现了棋盘绘制, +并可以通过\pkg{graphicx}宏包可以为棋盘添加图片背景。 -棋子、棋盘、背景等外观可以通过命令、环境选项或\tn{cchessset}% -命令进行设置。 +该宏包的目的是实现\textsf{不依赖于字体文件}或\textsf{字体宏包}的 +中国象棋棋谱排版,由于需要大量绘制操作,因此,其编译速度较低。 \section{用户接口} @@ -181,14 +193,14 @@ 通过\oarg{外观选项}设置的外观参数仅对当前命令局部有效, - 其星号版本命令用于无棋子棋盘。 + 其星号版本命令用于无棋子棋盘排版。 \begin{SideBySideExample}[frame=single,numbers=left, - xrightmargin=.68\linewidth,gobble=2] + xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - height=4.8cm} + \cchessset{resize/type=real, + resize/height=4.0cm} \cchessboard\quad \cchessboard* \end{SideBySideExample} @@ -201,18 +213,18 @@ \end{syntax} \end{function} - 按设置的\oarg{外观选项},将在\marg{棋子列表}中指定棋子排版于棋盘的 - 指定位置。 + 按设置的\oarg{外观选项},将在\marg{棋子列表}中指定棋子布置于棋盘的 + 指定位置并排版输出。 - \marg{棋子列表}中各个棋子用大括号分组后用英文逗号进行分隔,每个棋子 - 由用大括号括起来的棋子位置与棋子编码组成。 + \marg{棋子列表}中各个棋子用大括号分组后再用英文逗号进行分隔,每个棋子 + 是由大括号括起来的\textsf{棋子位置}与\textsf{棋子编码}组成的。 棋子位置由英文逗号分隔的纵横坐标确定,其中,纵向坐标用英文小写字母 a--j或阿拉伯数字0--9分别表示棋盘纵向10个交点;横向坐标用英文小写字母 a--i或阿拉伯数字0--8分别表示棋盘横向的9个交点。 - \textbf{\textsf{注意: }}可以混合使用棋子坐标表示方法,但强烈建议使用 - 单一字母法或数字表示棋子坐标。 + \textbf{\textsf{注意: }}可以混合使用字母和数字棋子坐标表示方法,但强烈 + 建议使用单一字母法或数字法表示棋子坐标。 棋子编码采用大写字母表示红棋,小写字母表示黑棋,具体如表% \ref{tab-piececode}所示。 @@ -246,8 +258,8 @@ xrightmargin=.50\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.90\linewidth} + \cchessset{resize/type=real, + resize/width=.90\linewidth} \cchessman{ {{4,0}{K}}, {{2,2}{p}}, {{1,7}{C}}, {{4,9}{k}} } @@ -266,19 +278,20 @@ \end{syntax} \end{function} - 按设置的\oarg{外观选项}对打谱结果进行排版。 + 按设置的\oarg{外观选项}排版打谱结果。 - 在打谱排版环境\env{setcchessman}中,可以通过专用命令\tn{init}% - 初始化棋谱状态(残局),\tn{set}在指定位置布置棋子,\tn{del}删除 - 指定位置的棋子,\tn{mov}实现棋子的移动,从而实现打谱操作。 + 在\env{setcchessman}环境中,可以通过专用命令\tn{init}% + (初始化棋谱状态)(残局),\tn{set}(在指定位置布置棋子),\tn{del}(删除 + 指定位置的棋子),\tn{mov}(棋子移动)实现打谱操作。 在环境结束后以最终打谱状态排版棋谱。 - 星号环境\env{setcchessman*}用于记录排版棋谱的文本描述(如:车一进二等)。 - 可在在\env{setcchessman*}环境中用label选项进行标记,然后用\tn{printman}% - 输出该棋谱。 + 星号环境\env{setcchessman*}用于同时记录打谱过程的文本描述(如:车一进二等)。 + 在\env{setcchessman*}环境中可以用\oarg{label}选项设置引用标签, + 再用\tn{printman}命令通过引用标签输出对应打谱过程文本描述。 在\oarg{外观选项}中可以通过key-value的方式设置棋子、棋盘的颜色、 - 字体、字号、线宽等外观。 + 字体、字号、线宽等外观。对于\env{setcchessman*}星号环境,% + \oarg{外观选项}中的棋子与棋盘相关外观选项设置无效。 通过\oarg{外观选项}设置的外观参数仅对当前命令局部有效, @@ -286,8 +299,8 @@ xrightmargin=.48\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.90\linewidth} + \cchessset{resize/type=real, + resize/width=.90\linewidth} \begin{setcchessman} % 残局初始化 \init{ {{4,0}{K}}, {{2,2}{p}}, @@ -313,7 +326,7 @@ \end{syntax} \end{function} - 用于将在\marg{棋子列表}中指定的所有棋子布置于棋盘的指定位置。 + 用于将\marg{棋子列表}中指定的所有棋子布置于棋盘的指定位置。 \marg{棋子列表}中的棋子表示方法与第\ref{subsec-cchessman}小节 中的说明相同。 @@ -328,7 +341,7 @@ \end{syntax} \end{function} - 用于将在\marg{棋子}中指定的棋子布置于棋盘的指定位置。 + 用于将指定\marg{棋子}布置于棋盘的指定位置。 \marg{棋子}中的棋子表示方法与第\ref{subsec-cchessman}小节 中的说明相同。 @@ -359,7 +372,8 @@ \end{function} 用于将\marg{棋子编码}中指定的棋子从\marg{原棋盘坐标}移动到% - \marg{新棋盘坐标}。 + \marg{新棋盘坐标}。若\marg{新棋盘坐标}处有棋子,则会被无条件 + ``吃''掉(替换)。 \marg{棋子编码}、\marg{原棋盘坐标}和\marg{新棋盘坐标}中采用 棋子与棋盘坐标表示方法与第\ref{subsec-cchessman}小节中的说明相同。 @@ -370,11 +384,15 @@ \begin{function}{\printman} \begin{syntax} - \cs{printman} \marg{\env{setcchessman*}环境的label标签} + \cs{printman} \oarg{每行步数} \marg{label标签} \end{syntax} \end{function} - 输出由label标签指定的\env{setcchessman*}打谱环境生成的棋谱。 + 输出由label标签指定的\env{setcchessman*}打谱环境生成的棋谱文本描述。 + \footnote{棋谱文本描述文件以\tn{jobname}+label+索引编号命名, + 并以``.man''为后缀名,是一个纯文本文件。} + + \oarg{每行步数}选项用于指定每行中输出的棋谱步数。 \subsection{\tn{getpiece}输出棋子命令} @@ -386,7 +404,7 @@ 按\oarg{棋子字号}指定的字号将用\marg{棋子编码}指定的棋子在当前位置输出。 - \marg{棋子编码}中的编码详见表表\ref{tab-piececode}。 + \marg{棋子编码}中的编码详见表\ref{tab-piececode}。 \begin{SideBySideExample}[frame=single,numbers=left, xrightmargin=.28\linewidth,gobble=2] @@ -408,7 +426,7 @@ 用于将\marg{棋子编码}指定的棋子字符设置为指定的\marg{棋子字符}。 - \marg{棋子编码}中的编码详见表表\ref{tab-piececode}。 + \marg{棋子编码}中的编码详见表\ref{tab-piececode}。 \textbf{\textsf{说明: }}该功能也可以通过|piecechar|外观选项实现。 @@ -422,7 +440,7 @@ 将棋子字符复位到默认字符。 -\subsection{\tn{cchessset}外观设置命令} +\subsection{\tn{cchessset}选项设置命令} \begin{function}{\cchessset} \begin{syntax} @@ -431,18 +449,76 @@ \end{function} 通过\marg{外观选项}中的key-value方式设置棋子、棋盘的文字、 - 字体、颜色、线宽、背景等排版外观。 + 字体、颜色、线宽等外观参数。 + + % \textbf{\textsf{说明: }}执行该命令时,仅有\textbf{\textsf{除}}% + % 棋子与棋盘外观的\textbf{\textsf{其它参数}}有效,棋子与棋盘外观 + % 参数的设置会在执行下一次命令或环境参数时起效。 通过\cs{cchessset}\marg{外观选项}设置的外观参数对后续所有 - 棋谱排版命令有效, + 棋谱排版命令有效。 + + \textbf{\textsf{注意: }}由于\pkg{chinesechess}宏包涉及大量 + 绘图操作,因此建议尽量减少在命令或环境中使用\oarg{外观选项}设置% + 以节约编译时间。如需要更改棋子或棋盘外观,可以在引用宏包时, + 通过为宏包添加选项实现,也可以执行\tn{cchessset}命令进行必要的 + 全局设置或在一定范围内进行统一设置。 + + % \oarg{外观选项}中的棋子与棋盘相关外观选项设置无效。 -\section{外观选项} +% \section{宏包选项} + +\section{宏包选项} 在\pkg{chinesechess}宏包中,棋子与棋盘的文本、字体、颜色、背景等 -外观可以通过不同\oarg{外观选项}进行设置。\oarg{外观选项}可以在 -命令或环境的可选项中进行局部设置,也可以通过\cs{cchessset}命令 +外观可以可以在引入宏包时通过\oarg{宏包选项}进行设置,也可以在 +命令或环境的\oarg{外观选项}中进行局部设置,还可以通过\cs{cchessset}命令 进行全局设置。 +强烈建议在引用宏包时通过\oarg{宏包选项}为一个文档统一全局设置棋子与 +棋盘外观,以节约编译时间。应避免频繁在命令和环境中使用\oarg{宏包选项}或 +使用\cs{cchessset}命令设置棋子与棋盘外面。 + +\pkg{chinesechess}宏包的选项是一组由(英文)逗号分隔的选项列表,列表中的 +选项通常是\marg{key}|=|\marg{value}形式。部分选项的\marg{value}可以省略。 +对于同一选项,后续设置会覆盖以前的设置。 + +\pkg{chinesechess}采用\LaTeX3风格的键值设置,支持不同类型以及多种层次的 +选项设定。键值列表中,``|=|''左右的空格不影响设置。但需注意,参数列表中% +\textsf{不可以出现空行}。 + +布尔型的参数\marg{选项}|=true|中的``|=true|''可以省略。 + +对于``|resize|''缩放和``|man|''子选项,只能用于命令与环境选项中,或通过 +\tn{cchessset}命令进行设置。 + +\textbf{\textsf{注意: }}为提高编译速度,\pkg{chinesechess}宏包会分别根据% +\tn{cchessset}命令或棋谱排版命令与环境的可选项中的棋盘与棋子相关参数决定 +是否对棋盘或棋子进行重新绘制,因此,前一次的棋盘与棋子外观选项会影响至下 +一次新的外观选项出现。如果需要改变前一次外观选项的影响,可以使用一次棋盘 +或棋子外观相关选项。 + +\subsection{草稿选项} + +\begin{option}{ opt = draft, desc = {= \meta{草稿选项}}, init=false } + 设置草稿选项。 +\end{option} + + \oarg{draft}选项将删除所有效果设置,所有棋子仅显示文本, + 棋盘仅带有九宫格对角线。从而加快编译速度。 + + \textbf{\textsf{注意: }}在草稿模式下,命令与环境中与棋子与棋盘外观 + 相关的选项都将失效,因此,可能与最终排版结果会有出入。 + +\begin{SideBySideExample}[frame=single,numbers=left, + xrightmargin=.53\linewidth,gobble=2] + % \usepackage[draft]{chinesechess} + \centering + % 为便排版,进行缩放 + \cchessset{resize/type=real, + resize/width=.90\linewidth} + \cchessboard[draft] +\end{SideBySideExample} \subsection{棋盘} \subsubsection{单元格尺寸} @@ -451,13 +527,17 @@ 设置棋盘单元格尺寸。 \end{option} + \textbf{\textsf{说明: }}由于在前一个示例中使用了|[draft]|% + 参数,为恢复棋子外观,需要执行一次棋子相关设置参数。 + \begin{SideBySideExample}[frame=single,numbers=left, xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.90\linewidth} - \cchessboard[gridsize=15mm] + \cchessset{resize/type=real, + resize/width=.90\linewidth} + \cchessboard[gridsize=15mm, + piecetype=ooo] \end{SideBySideExample} \bigskip @@ -480,8 +560,8 @@ xrightmargin=.54\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.35\linewidth} + \cchessset{resize/type=real, + resize/width=.35\linewidth} \cchessboard*[boardtype=x]\quad \cchessboard*[boardtype=x+]\\ \cchessboard*[boardtype=x+t]\quad @@ -501,8 +581,8 @@ xrightmargin=.56\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.90\linewidth} + \cchessset{resize/type=real, + resize/width=.90\linewidth} \cchessboard*[boardlinewd=1.0pt] \end{SideBySideExample} @@ -518,8 +598,8 @@ xrightmargin=.55\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.90\linewidth} + \cchessset{resize/type=real, + resize/width=.90\linewidth} \cchessboard*[boardlinecolor=red] \end{SideBySideExample} @@ -537,92 +617,14 @@ xrightmargin=.55\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.35\linewidth} + \cchessset{resize/type=real, + resize/width=.35\linewidth} \cchessboard*[boardbg=bg01]\quad \cchessboard*[boardbg=bg02] \end{SideBySideExample} \bigskip -\subsection{棋谱缩放} - -\subsubsection{缩放方式} - -\begin{option}{ opt = resize, desc = {= \meta{棋谱缩放方式}}, init=none } - 设置最终棋谱输出时的整体缩放方式,目前支持: -\end{option} - - \begin{Description}[a] - \item |none|---无缩放。 - \item |real|---按指定的width、height、xscale或yscale进行缩放。 - \end{Description} - -\bigskip - -\subsubsection{横向缩放因子} - -\begin{option}{ opt = xscale, desc = {= \meta{x方向缩放系数}}, init=1 } - 设置x方向缩放系数,需要配合|resize|缩放方式参数一起使用。 -\end{option} - -\begin{SideBySideExample}[frame=single,numbers=left, - xrightmargin=.48\linewidth,gobble=2] - \centering - \cchessboard[resize=real, xscale=0.5] -\end{SideBySideExample} - - -\bigskip - -\subsubsection{纵向缩放因子} - -\begin{option}{ opt = yscale, desc = {= \meta{y方向缩放系数}}, init=1 } - 设置y方向缩放系数,需要配合|resize|缩放方式参数一起使用。 -\end{option} - -\begin{SideBySideExample}[frame=single,numbers=left, - xrightmargin=.70\linewidth,gobble=2] - \centering - \cchessboard[% - resize=real, - yscale=0.5] -\end{SideBySideExample} - -\bigskip - -\subsubsection{横向尺寸} - -\begin{option}{ opt = width, desc = {= \meta{宽度}}, init=init-none } - 设置输出宽度,需要配合|resize|缩放方式参数一起使用。 -\end{option} - -\begin{SideBySideExample}[frame=single,numbers=left, - xrightmargin=.65\linewidth,gobble=2] - \centering - \cchessboard[resize=real, - width=7cm] -\end{SideBySideExample} - -\bigskip - -\subsubsection{纵向尺寸} - -\begin{option}{ opt = height, desc = {= \meta{高度}}, init=init-none } - 设置输出高度,需要配合|resize|缩放方式参数一起使用。 -\end{option} - -\begin{SideBySideExample}[frame=single,numbers=left, - xrightmargin=.65\linewidth,gobble=2] - \centering - \cchessboard[resize=real, - height=6cm] -\end{SideBySideExample} - - \textbf{\textsf{说明: }}缩放纵/横参数可以混合使用。 - -\bigskip - \subsection{棋子} \subsubsection{字符} @@ -641,9 +643,8 @@ %\usepackage{fontawesome5} \centering % 为便排版,进行缩放 - \cchessset{resize=real, - % gridsize=10mm, - width=.90\linewidth} + \cchessset{resize/type=real, + resize/width=.90\linewidth} \cchessboard[% piecechar={K}{\faChessKing}, piecechar={A}{\faShield*}, @@ -667,18 +668,18 @@ \resetpiece \cchessset{piecechar={C}{炮}} -\subsubsection{颜色} +\subsubsection{字体} \begin{option}{ opt = piecefont, desc = {= \meta{棋子字符字体}}, init=\cs{kaishu} } 设置棋子字符字体。 \end{option} \begin{SideBySideExample}[frame=single,numbers=left, - xrightmargin=.55\linewidth,gobble=2] + xrightmargin=.54\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.90\linewidth} + \cchessset{resize/type=real, + resize/width=.90\linewidth} \cchessboard[piecefont=\sffamily] \end{SideBySideExample} @@ -700,8 +701,8 @@ xrightmargin=.55\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.40\linewidth} + \cchessset{resize/type=real, + resize/width=.40\linewidth} \cchessboard[piecetype=o]\quad \cchessboard[piecetype=oo]\\ \cchessboard[piecetype=ooo] @@ -719,8 +720,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[boxlinewd=0.8pt] \end{SideBySideExample} @@ -736,14 +737,14 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[boxcolor=white] \end{SideBySideExample} \bigskip -\subsubsection{红棋颜色} +\subsubsection{红棋字符颜色} \begin{option}{ opt = redpiece, desc = {= \meta{红棋棋子字符颜色}}, init=red } 设置红棋棋子字符颜色。 @@ -753,14 +754,14 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[redpiece=white] \end{SideBySideExample} \bigskip -\subsubsection{黑棋颜色} +\subsubsection{黑棋字符颜色} \begin{option}{ opt = blkpiece, desc = {= \meta{黑棋棋子字符颜色}}, init=black } 设置黑棋棋子字符颜色。 @@ -770,8 +771,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[blkpiece=white] \end{SideBySideExample} @@ -787,8 +788,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[lower=black] \end{SideBySideExample} @@ -804,8 +805,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[donut=red] \end{SideBySideExample} @@ -821,8 +822,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[redupper=red, redpiece=white] \end{SideBySideExample} @@ -839,8 +840,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[blkupper=black, blkpiece=white] \end{SideBySideExample} @@ -857,8 +858,8 @@ xrightmargin=.60\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[shadow=red!80] \end{SideBySideExample} @@ -871,7 +872,7 @@ \end{option} \begin{Description}[a] - \item |none|---原字体默认笔划。 + \item |none|---默认笔划。 \item |solid|---实线笔划轮廓,笔划内部透明,颜色使用字符颜色。 \item |white|---实线白色笔划轮廓,笔划内部用白色填充。 \item |bold|---加粗笔划,颜色使用字符颜色。 @@ -882,8 +883,8 @@ xrightmargin=.58\linewidth,gobble=2] \centering % 为便排版,进行缩放 - \cchessset{resize=real, - width=.95\linewidth} + \cchessset{resize/type=real, + resize/width=.95\linewidth} \cchessboard[charstroke=white, redupper=red,blkupper=black] \end{SideBySideExample} @@ -892,29 +893,40 @@ \subsection{打谱} +打谱参数位于|man|子选项中,可以使用|man={label=test}|或 +|man/label=test|两种形式进行设置。 + \subsubsection{label标签} \begin{option}{ opt = label, desc = {= \meta{棋谱标签}}, init=init-none } 设置\env{setcchessman*}打谱环境交叉引用标签。 \end{option} + 该选项目前仅支持\env{setcchessman*}打谱环境。 + \subsubsection{每行棋谱步数} -\begin{option}{ opt = mansperline, desc = {= \meta{每行棋谱步数}}, init=2 } +\begin{option}{ opt = nums, desc = {= \meta{每行棋谱步数}}, init=2 } 设置\tn{printman}输出棋谱时,每行输出棋谱的步数。 \end{option} + 该选项只在\tn{printman}命令中起作用。 + + \textbf{\textsf{说明: }}由于在前一个示例中使用了|[charstroke=white]|% + 参数,为恢复棋子外观,需要执行一次棋子相关设置参数。 + + 但要注意的是|setcchessman*|星号环境并不执行棋子棋盘重构,因此,此处 + 需要在\tn{cchessset}命令中重新设置棋子笔划类型。 + \begin{SideBySideExample}[frame=single,numbers=left, xrightmargin=.45\linewidth,gobble=2] \centering \printman{test} - - \bigskip - % 为便排版,进行缩放 - \cchessset{resize=real, - width=0.90\linewidth} - \begin{setcchessman*}[label=test] + \cchessset{charstroke=bold, + resize/type=real, + resize/width=0.90\linewidth} + \begin{setcchessman*}[man/label=test] % 残局初始化 \init{ {{4,0}{K}}, {{2,2}{p}}, {{1,7}{C}}, {{4,9}{k}} } @@ -927,8 +939,96 @@ \mov{K}{4,0}{4,1} \mov{h}{8,6}{6,7} \mov{K}{4,1}{3,1} \mov{h}{6,7}{5,5} \end{setcchessman*} + \begin{flushleft} + \small + \printman[man/nums=4]{test} + \end{flushleft} \end{SideBySideExample} +\subsection{棋谱缩放} + +缩放方式位于|resize|子选项中,可以使用|resize={type=real}|或 +|resize/xscale=0.5|两种形式进行设置。 + +\subsubsection{缩放方式} + +\begin{option}{ opt = type, desc = {= \meta{棋谱缩放方式}}, init=none } + 设置最终棋谱输出时的整体缩放方式,目前支持: +\end{option} + + \begin{Description}[a] + \item |none|---无缩放。 + \item |real|---按指定的width、height、xscale或yscale进行缩放。 + \end{Description} + +\bigskip + +\subsubsection{横向缩放因子} + +\begin{option}{ opt = xscale, desc = {= \meta{x方向缩放系数}}, init=1 } + 设置x方向缩放系数,需要配合|resize|缩放方式参数一起使用。 +\end{option} + +\begin{SideBySideExample}[frame=single,numbers=left, + xrightmargin=.48\linewidth,gobble=2] + \centering + \cchessboard[resize/type=real, + resize/xscale=0.5] +\end{SideBySideExample} + + +\bigskip + +\subsubsection{纵向缩放因子} + +\begin{option}{ opt = yscale, desc = {= \meta{y方向缩放系数}}, init=1 } + 设置y方向缩放系数,需要配合|resize|缩放方式参数一起使用。 +\end{option} + +\begin{SideBySideExample}[frame=single,numbers=left, + xrightmargin=.70\linewidth,gobble=2] + \centering + \cchessboard[% + resize/type=real, + resize/yscale=0.5] +\end{SideBySideExample} + +\bigskip + +\subsubsection{横向尺寸} + +\begin{option}{ opt = width, desc = {= \meta{宽度}}, init=init-none } + 设置输出宽度,需要配合|resize|缩放方式参数一起使用。 +\end{option} + +\begin{SideBySideExample}[frame=single,numbers=left, + xrightmargin=.65\linewidth,gobble=2] + \centering + \cchessboard[% + resize/type=real, + resize/width=7cm] +\end{SideBySideExample} + +\bigskip + +\subsubsection{纵向尺寸} + +\begin{option}{ opt = height, desc = {= \meta{高度}}, init=init-none } + 设置输出高度,需要配合|resize|缩放方式参数一起使用。 +\end{option} + +\begin{SideBySideExample}[frame=single,numbers=left, + xrightmargin=.65\linewidth,gobble=2] + \centering + \cchessboard[% + resize/type=real, + resize/height=6cm] +\end{SideBySideExample} + + \textbf{\textsf{说明: }}缩放纵/横参数可以混合使用。 + +\bigskip + % \bigskip % \title{ diff --git a/macros/latex/contrib/fancyhdr/README b/macros/latex/contrib/fancyhdr/README index cd07feba89..e44d05f032 100644 --- a/macros/latex/contrib/fancyhdr/README +++ b/macros/latex/contrib/fancyhdr/README @@ -25,7 +25,7 @@ In order to latex the documentation you need to have a copy of boxedminipage.sty (CTAN:/macros/latex/contrib/boxedminipage) and refcount.sty (CTAN:/macros/latex/contrib/oberdiek/) installed. -This is version 4.0.1 of fancyhdr.sty and extramarks.sty. They are +This is version 4.0.2 of fancyhdr.sty and extramarks.sty. They are described in the forthcoming third edition of The LaTeX Companion. Extramarks.sty has not been changed, except for the version and copyright information. diff --git a/macros/latex/contrib/fancyhdr/fancyhdr.dtx b/macros/latex/contrib/fancyhdr/fancyhdr.dtx index d2a6dc9611..41e7ebb598 100644 --- a/macros/latex/contrib/fancyhdr/fancyhdr.dtx +++ b/macros/latex/contrib/fancyhdr/fancyhdr.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 1994-2021 by Pieter van Oostrum +% Copyright (C) 1994-2022 by Pieter van Oostrum % ------------------------------------------------------- % % This file may be distributed and/or modified under the @@ -26,11 +26,11 @@ %\ProvidesPackage{fancyhdr}% %\ProvidesPackage{fancyheadings} %\ProvidesPackage{extramarks} -% [2021/01/28 v4.0.1 +% [2022/05/10 v4.0.2 % Extensive control of page headers and footers]% % Legacy package to call fancyhdr] % Extra marks for LaTeX] -%% Copyright (C) 1994-2021 by Pieter van Oostrum +%% Copyright (C) 1994-2022 by Pieter van Oostrum %% Public domain %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \end{macrocode} @@ -46,8 +46,8 @@ \usepackage{boxedminipage} \usepackage{fourier-orns} \usepackage[T1]{fontenc} -\usepackage{url} \usepackage[fit]{truncate} +\usepackage[hyphens]{url} \usepackage[colorlinks,linktocpage]{hyperref} \usepackage{ifthen} \usepackage{fancyhdr} @@ -674,57 +674,68 @@ % and later\footnote{This comes from the \Package{nccfancyhdr} % package by Alexander I. Rozhenko.}. % -% The marks in a fancy header and footer are prepared using \cs{parbox} -% command. So, you can use multiline marks. In the header, they are +% The fields in a fancy header and footer are prepared using \cs{parbox} +% command. So, you can use multiline fields. In the header, they are % aligned to the bottom line, but, in the footer, they are aligned to -% the top line. The maximum width of every mark is equal to the -% \cs{headwidth}. This can lead to overlapping of neighbouring marks. +% the top line. The maximum width of every field is equal to the +% \cs{headwidth}. This can lead to overlapping of neighbouring fields. % -% \DescribeMacro{\fancycenter} -% If you want to prepare marks in more traditional way in a line +% \CmdIndex{fancycenter} +% If you want to prepare headers/footers in more traditional way in a line % not exceeding the \cs{headwidth}, you can use -% the following command in any mark command: +% the following command in any header/footer command: % \begin{quote} % \cs{fancycenter}\oarg{distance}\oarg{stretch}\\ -% \verb| |\marg{left-mark}\marg{center-mark}\marg{right-mark} +% \verb| |\marg{left-field}\marg{center-field}\marg{right-field} % \end{quote} % \CmdIndex{fancycenter} % This command works like % \begin{center} -% \verb|\hbox to\linewidth{|\marg{left-mark}\cs{hfil}\marg{center-mark}\cs{hfil}\marg{right-mark}\verb|}| +% \verb|\hbox to\linewidth{|\marg{left-field}\cs{hfil}\marg{center-field}\cs{hfil}\marg{right-field}\verb|}| % \end{center} % but does this more carefully trying to exactly center the central part of % the text if possible. The solution for exact centering -% is applied if the width of \meta{center-mark} is less than +% is applied if the width of \meta{center-field} is less than % \begin{quote} % \verb|\linewidth - 2*(|\meta{stretch}\verb|*|\meta{distance}\verb| +|\\ -% \verb| max(width(|\meta{left-mark}\verb|), width(|\meta{right-mark}\verb|)))|. +% \verb| max(width(|\meta{left-field}\verb|), width(|\meta{right-field}\verb|)))|. % \end{quote} -% Otherwise the \meta{center-mark} will slightly migrate to a shorter item -% (\meta{left-mark} or \meta{right-mark}), but at least \meta{distance} +% Otherwise the \meta{center-field} will slightly migrate to a shorter item +% (\meta{left-field} or \meta{right-field}), but at least \meta{distance} % space between all parts of line is provided. % The default values of \meta{distance} and \meta{stretch} % are 1em and 3. % -% If the \meta{center-mark} is empty, the \cs{fancycenter} is equivalent to +% If the \meta{center-field} is empty, the \cs{fancycenter} is equivalent to % the following command: % \begin{center} -% \verb|\hbox to\linewidth {|\marg{left-mark}\verb|\hfil |\marg{right-mark}\verb|}| +% \verb|\hbox to\linewidth {|\marg{left-field}\verb|\hfil |\marg{right-field}\verb|}| % \end{center} % % You would use this in a header for example with % \begin{quote} % \verb|\fancyhead[C]{|\cs{fancycenter}\oarg{distance}\oarg{stretch}\\ -% \verb| |\marg{left-mark}\marg{center-mark}\marg{right-mark}\verb|}| +% \verb| |\marg{left-field}\marg{center-field}\marg{right-field}\verb|}| % \end{quote} % and leave the \texttt{[L,R]} parts empty. % -% \textbf{Note 1}: If the whole of the \cs{fancycenter} is wider than -% \cs{headwidth} it will stick out on the right. See +% \textbf{Note 1}: +% When \cs{fancycenter} is used inside a header or +% \CmdIndex{linewidth}% +% \CmdIndex{headwidth}% +% footer, \cs{linewidth} usually is the same as \cs{headwidth}. Only +% when \cs{fancycenter} is used inside a box with a different width, +% \cs{linewidth} will be the width of that box. +% +% \textbf{Note 2}: +% If the whole of the \cs{fancycenter} is wider than +% \cs{linewidth} it will stick out on the right. See % section~\ref{sec:longtitles} for possible solutions. % -% \textbf{Note 2}: The usage of \cs{fancycenter} command is not limited to the -% argument of header/footer marks. You can use it anywhere in your document. +% \textbf{Note 3}: The usage of the \cs{fancycenter} command is not limited to the +% argument of headers/footers. You can use it anywhere in your +% document. Then \cs{linewidth} will be the width of the box or text in +% which it is used. % % \section{An example of two-sided printing}\label{two-sided} % @@ -1855,11 +1866,9 @@ % For example % \begin{verbatim} % \pagestyle{fancy} -% \renewcommand{\chaptermark}[1]{\markboth{Chapter \thechapter. ##1}{}} -% \renewcommand{\sectionmark}[1]{\markright{\thesection\ ##1}} +% \renewcommand{\chaptermark}[1]{\markboth{Chapter \thechapter. #1}{}} +% \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} % \end{verbatim} -% Please note that you have to double the \verb|#| signs, because the -% definitions are inside a macro. % % If the previous page style was one of the standard \LaTeX{} page % styles, or some page style that is not based on \Package{fancyhdr}, @@ -1880,12 +1889,14 @@ % ... % \pagestyle{myfancy} % \end{verbatim} +% Please note that you now have to double the \verb|#| signs, because the +% definitions are inside a macro. % % In general, when you use only one page style \texttt{fancy} in your % document, with the occasional \cs{thispagestyle} excursion to page % style \texttt{plain} or \texttt{empty}, you can just keep the % definitions globally in your document, but as soon as you use more -% than one page style, and swicth between them, it is highly advisable +% than one page style, and switch between them, it is highly advisable % to define them (including page style \texttt{fancy}) with % \cs{fancypagestyle} and put all the relevant definitions inside them. % @@ -2037,7 +2048,7 @@ % the page where ``This'' appears, or on the page where ``page'' % appears. It depends on the positioning of the \cs{label} command. % Probably it is safer to make sure the sentence isn't broken. This can -% be dome by putting the text in a \cs{parbox} or \texttt{minipage} environment. +% be done by putting the text in a \cs{parbox} or \texttt{minipage} environment. % \begin{verbatim} % \noindent % \begin{minipage}{\textwidth} @@ -2436,7 +2447,8 @@ % Of course we have to take care of two-sided printing, and we may want to % have an index page with all the blobs in the correct position. The solution % requires some hand-tuning to get the blobs nicely spaced out vertically. -% For the application that I had there were 12 sections, so I made the blobs +% For the application that I originally designed this for, there were 12 sections, +% so I made the blobs % 18 mm apart, i.e. 9~mm blob separated by 9~mm whitespace. In order to avoid % calculations they are set in a \texttt{picture} environment with the % \cs{unitlength} set to 18~mm. Page numbers are set in the headers at the @@ -2521,13 +2533,17 @@ % % \section{Float placement} % +% \textbf{Note: This section is not about \Package{fancyhdr}, but about +% page layout, especially about the placement of floats.} +% % Floats are page elements that float with respect to the rest of the % document. Standard floats are tables and figures, but with the +% \TTindex{float}% % \Package{float} package you can easily make new ones, like algorithms. Most % of the time floats work satisfactory, but sometimes \LaTeX{} seems too % stubborn to do what you want. This section describes how you can influence % \LaTeX{} so that it will do most of the time what you want. There might, -% however be some pathological cases where it is impossible to convince +% however, be some pathological cases where it is impossible to convince % \LaTeX{} to do things your way. In the following we will use figures as an % example but everything applies to other floats as well. % @@ -2537,7 +2553,8 @@ % moves it, usually to the next page. % \item From a certain point, \LaTeX{} moves all your floats to the end of % the document or the end of a chapter. -% \item \LaTeX{} complains about ``Too many floats''. +% \item \index{Too many floats}% +% \LaTeX{} complains about ``Too many floats''. % \end{enumerate} % % In the first two cases you must first check if you have given the correct @@ -2545,7 +2562,7 @@ % specifies that your figure may be placed either: Here (i.e. in the text % position where the command is given), on the Top of a page (which may be % the page where you put the command), or on a separate Page of floats. You -% could also have specified ``b'' for Bottom of the page. The order of the +% could also have specified ``\texttt{b}'' for Bottom of the page. The order of the % letters is insignificant, you cannot force \LaTeX{} to try Bottom first % and then Top by specifying \texttt{[bt]}. % @@ -2557,11 +2574,11 @@ % \texttt{[b]} in the position parameter, \latex/ must save it until it has % enough for a page of floats. So don't specify only \texttt{[h]}. If you % want to give \latex/ a chance to put the float on a page of floats, you -% must also specify ``p''. +% must also specify ``\texttt{p}''. % \item The placement would violate the constraints imposed by \latex/'s % float placement parameters. This is one of the most occurring causes and % it can easily be corrected by changing the parameters. Here is a list of -% them: +% them with their default values: % \end{enumerate} % \begin{center} % \CmdIndex{topfraction} @@ -2595,7 +2612,7 @@ % The values in the righthand column are the defaults for the standard % \latex/ classes. Other classes could use different defaults. As you see % with the default values a float will not be put in the bottom of a page if -% its height is more than 30\% of the page height. So if you specify [hb] for +% its height is more than 30\% of the page height. So if you specify \texttt{[hb]} for % a float which is taller it has to move to a float page. But if it is less % than 50\% of the page height it will have to wait until some more floats % are given before a float page can be filled to satisfy the @@ -2637,8 +2654,9 @@ % If in spite of all your attempts \latex/ still moves your floats to the end % of the document or the end of a chapter, you can insert a \cs{clearpage} % command. This will start a new page and insert all pending floats before -% continueing. If it is undesirable to have a pagebreak you can use the +% continuing. If it is undesirable to have a pagebreak you can use the % \Package{afterpage} package and the following command: +% \TTindex{afterpage}\CmdIndex{afterpage}\CmdIndex{clearpage}% % \begin{verbatim} % \afterpage{\clearpage} % \end{verbatim} @@ -2650,6 +2668,7 @@ % Finally, if you want a float only at the place where you define it, without % \latex/ moving it whatsoever, you can use the \Package{float} package and % give the command: +% \TTindex{float}\CmdIndex{restylefloat}% % \begin{verbatim} % \restylefloat{figure} % \end{verbatim} @@ -2659,6 +2678,7 @@ % If you want to avoid the unwanted pagebreak, i.e. let % \LaTeX{} move the float only if it doesn't fit on the page, then use the % \Package{afterpage} package with: +% \TTindex{afterpage}\CmdIndex{afterpage}\CmdIndex{clearpage}% % \begin{verbatim} % \afterpage{\clearpage \begin{figure}[H] ... \end{figure}} % \end{verbatim} @@ -2668,11 +2688,22 @@ % collecting too many of them. The solutions given above, especially those % with \cs{clearpage} in them will usually help. In some cases there % really are too many floats, as \latex/ has a limited number of ``boxes'' to -% store the floats. The package \Package{morefloats} can be used to increase +% store the floats. The package +% \TTindex{morefloats}% +% \Package{morefloats} can be used to increase % this number. If you need still more then you must edit a private copy of % this file, but even then there will be some limit that you cannot pass. % Then your only resort will be to change your document. % +% A much more elaborate article about float placement by Frank +% Mittelbach appeared in 2014 in TUGboat\footnote{% +% Frank Mittelbach, \emph{How to influence the position of float +% environments like figure and table in LATEX?}, TUGboat, Volume 35 +% (2014), No. 3, pp. 248–254.\\ +% \url{https://www.latex-project.org/publications/2014-FMi-TUB-tb111mitt-float-placement.pdf} +% \\Also on Stackexchange:\\ +% \url{https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat}}. +% % \section{Multipage Floats} % % \LaTeX's floats cannot be split across pages. Sometimes, however, you want @@ -2680,8 +2711,8 @@ % to split these into multiple table or figure environments, but this has a % number of undesirable effects: % \begin{itemize} -% \item Where do you split it? This is in general more difficult for tables -% than for figures. +% \item Where do you split it? This is generally a more difficult decision +% for tables than for figures. % \item How do you keep them together? % \item You don't want more than one entry in the list of figures/tables. % \end{itemize} @@ -2708,7 +2739,7 @@ % to include it in an \cs{afterpage} command (using the \Package{afterpage} % package). As a \texttt{longtable} is by definition large, it is best to put % it in a separate file, and \cs{input} it in the \cs{afterpage} command: -% \CmdIndex{afterpage} +% \CmdIndex{afterpage}\TTindex{afterpage}\CmdIndex{clearpage}% % \begin{verbatim} % \afterpage{\input{mytable}} % \end{verbatim} @@ -2721,8 +2752,8 @@ % % \subsection{Figures} % -% There isn't an equivalent \texttt{longfigure} solution, so for figures you -% will usually have to split it yourself. In general this is less of a +% There isn't an equivalent ``\texttt{longfigure}'' solution, so for figures you +% will have to split yourself. In general this is less of a % problem. However, the problem you get now is how to keep them together, % i.e. how to get the parts on subsequent pages, and how to get a single % entry in the list of figures. @@ -2732,7 +2763,8 @@ % to use only the \texttt{[p]} placement, so that they will be put on % floatpages. As they are bigger than a page this is appropriate. The first % part would then get a \cs{caption}, the subsequent parts would be used -% without a caption. If you want to add a caption-like text, enter it as +% without a caption, or a caption that will not go to the list of figures. +% If you want to add a caption-like text, enter it as % normal text rather than a \cs{caption}, so that it will not be entered in % the list of figures. It may also be desirable to issue a \cs{clearpage} % first, just like we did for the \texttt{longtable}, and to encapsulate this @@ -2764,6 +2796,8 @@ % If you want your multipage figure to start at a lefthand-side % (even-numbered) page you can use a test in the \cs{afterpage} command % (using the \Package{ifthen} package): +% \CmdIndex{afterpage} +% \CmdIndex{ifthenelse} % \begin{verbatim} % \afterpage{\clearpage % \ifthenelse{\isodd{\value{page}}{\afterpage{\input{myfigure}}} % odd page @@ -2855,7 +2889,7 @@ % Bugs and suggestions for improvements can be reported at\\ % \url{https://github.com/pietvo/fancyhdr/issues}\\ % Example files can be found at\\ -% \url{https://github.com/pietvo/fancyhdr/tree/Examples} +% \url{https://github.com/pietvo/fancyhdr-examples} % % \section{Version information} % \begin{itemize} @@ -2867,8 +2901,8 @@ % \item References to older \LaTeX{} versions removed. % \item Removed obsolete source code of \Package{extramarks.sty} % \item Changed font commands to \cs{textbf} and \cs{textsl}. -% \item Added description of the \cs{fancy\ldots offset} commands. -% \item Added various \cs{\ldots xmark} commands from \Package{extramarks.sty}. +% \item Added description of the \Cmd{fancy\ldots offset} commands. +% \item Added various \Cmd{\ldots xmark} commands from \Package{extramarks.sty}. % \item Various corrections applied. % \item Updated contact information. % \item Added Version information. :) @@ -2946,6 +2980,19 @@ % \item Some documentation corrections, especially in sections % \ref{sec:xmarks} and \ref{sec:movie}. % \end{itemize} +% \item Version 4.0.2, May 9, 2022 +% \begin{itemize} +% \item Added \cs{leavevmode}\cs{ignorespaces} to each header/footer +% field. The \cs{leavevmode} prevents a bug when a field starts with a +% \cs{color} command. The \cs{ignorespaces} skips initial spaces in +% the parameter, as is usual in a \cs{parbox}, for backwards +% compatibility. However, there are some rare cases where spurious +% spaces can still show up in the header/footer fields. In that case +% the user will have to eliminate these. +% \item Cleanup the documentation of the \cs{fancycenter} command. +% \item Miscellaneous small documentation changes. +% \item Make \cs{fancyhead} etc. \cs{long}. +% \end{itemize} % \end{itemize} % % @@ -2961,11 +3008,11 @@ % gradually. % % -% \section{Large chapter/section titles} +% \section{Long chapter/section titles} % \label{sec:longtitles} % % \index{long titles} -% Sometimes a chapter or section title is too large to fit in the header +% Sometimes a chapter or section title is too long to fit in the header % or footer. It may take more than one line in the header/footer, or it % may overwrite other parts. How can we shorten these titles in the % header/footer without changing the actual title? @@ -2998,8 +3045,8 @@ % \subsection{Using optional arguments} % % As we have seen in section~\ref{sec:scoop}, the header info comes from -% the marks. So if we want the text in the header to be smaller we have -% to supply smaller marks. This can be done by giving these as optional +% the marks. So if we want the text in the header to be shorter we have +% to supply shorter marks. This can be done by giving these as optional % arguments in the \cs{chapter} and \cs{section} commands.\footnote{At % least in the \texttt{book} and \texttt{report} documentclasses. In the % \texttt{article} class this would be the \cs{section} and @@ -3011,7 +3058,7 @@ % {This is a very long section title that will not fit in the header} % \end{verbatim} % The short titles will now appear in the header. However, these will -% also appear in the table of contents. If that is what you want than +% also appear in the table of contents. If that is what you want then % you are ready. But if you want to use the long titles in the table of % contents, you have to use some trickery. In particular you have to % supply the marks yourself. @@ -3078,7 +3125,8 @@ % \Sectioniii{Text title}{Header title}{TOC title} % \end{verbatim} % Please note that if you use the \texttt{article} class, instead of -% \cs{chaptermark} and \cs{sectionmark}, you would probably use \cs{sectionmark}\cs{subsectionmark}. +% \cs{chaptermark} and \cs{sectionmark}, you would probably use +% \cs{sectionmark} and \cs{subsectionmark}. % % \subsection{Using automatic truncation} % @@ -3113,7 +3161,9 @@ % they could theoretically touch each other. This can be prevented by % making the widths slightly smaller. And when there is only one title % in the header, you can make the width equal to or slightly smaller -% than \cs{headwidth}. +% than \cs{headwidth}. A more sophisticated solution would be to check +% if one of the header parts is small enough and then truncate the other +% one for the remaining space. % % \section{I lost my chapter/section titles} % @@ -3546,10 +3596,11 @@ % This is similar to \LaTeX's \cs{@tfor}, but it expands the \texttt{charstring}. % \begin{macrocode} % \changes{fancyhdr v3.10}{2019/01/25}{Use \cs{newcommand} instead of \cs{def}.} +% \changes{fancyhdr v4.0.2}{2022/05/10}{Make \cs{f@nch@rc} \cs{long}.} \newcommand{\f@nch@forc}[3]{\expandafter\f@nchf@rc\expandafter#1\expandafter{#2}{#3}} \newcommand{\f@nchf@rc}[3]{\def\temp@ty{#2}\ifx\@empty\temp@ty\else \f@nch@rc#1#2\f@nch@rc{#3}\fi} -\def\f@nch@rc#1#2#3\f@nch@rc#4{\def#1{#2}#4\f@nchf@rc#1{#3}{#4}} +\long\def\f@nch@rc#1#2#3\f@nch@rc#4{\def#1{#2}#4\f@nchf@rc#1{#3}{#4}} % \end{macrocode} % \end{macro} % \begin{macro}{\f@nch@for} @@ -3629,6 +3680,7 @@ % \end{macro} % % \begin{macro}{\f@nch@fancyhf} +% \changes{fancyhdr v4.0.2}{2022/05/10}{Make \cs{f@nch@fancyhf} \cs{long}.} % This macro interprets the parameters for the headers and footers.\\ % Parameters:\\ % (1) The user command that was used (like \cs{fancyhead}). This is used @@ -3642,7 +3694,7 @@ % \texttt{[eo]}, \meta{y} from \texttt{[lcr]} and \meta{z} from \texttt{[hf]}. % % \begin{macrocode} -\def\f@nch@fancyhf#1#2[#3]#4{% +\long\def\f@nch@fancyhf#1#2[#3]#4{% \def\temp@c{}% \f@nch@forc\tmpf@ra{#3}% {\expandafter\f@nch@ifin\tmpf@ra{eolcrhf,EOLCRHF}% @@ -3880,7 +3932,8 @@ % \cs{hsize} to \cs{headwidth} (this helps for multicol); reset % \bsbs, \cs{raggedleft}, \cs{raggedright} and \cs{centering} to % their default values (for tabu), and \cs{everypar} to empty.\\ -% The font is reset to \cs{normalfont}. +% The font is reset to \cs{normalfont}. Actually this is done in the +% \LaTeX{} output routine, so we don't have to do it here. % \begin{macrocode} \def\f@nch@reset{\f@nch@everypar{}\restorecr\endlinechar=13 \let\\\@normalcr \let\raggedleft\f@nch@raggedleft @@ -3906,7 +3959,8 @@ } \def\f@nch@center#1[#2]#3#4#5{% % \end{macrocode} -% At first, we execute the case when the \meta{center-mark} is empty: +% At first, we execute the case when the \meta{center-mark} is empty\footnote{% +% This code is reused from the \Package{nccfancyhdr} by Alexander I. Rozhenko}: % \begin{macrocode} \def\@tempa{#4}\ifx\@tempa\@empty \hbox to\linewidth{\color@begingroup{#3}\hfil {#5}\color@endgroup}% @@ -4032,12 +4086,22 @@ \newcommand\f@nch@vbox[2]{% \setbox0\vbox{#2}% \ifdim\ht0>#1\relax +% \end{macrocode} +% This is the part where the the header/footer is too tall for the vertical space. +% If the \texttt{[nocheck]} package option is not given, we give a +% warning message. +% \begin{macrocode} \iff@nch@check \dimen0=#1\advance\dimen0-\ht0 \f@nch@warning{% \string#1 is too small (\the#1): \MessageBreak Make it at least \the\ht0, for example:\MessageBreak \string\setlength{\string#1}{\the\ht0}% +% \end{macrocode} +% If the \texttt{[compatV3} option was given (and not +% \texttt{[nocheck]}), we will also change the +% \cs{headheight}/\cs{footskip} globally below, and announce this in the warning message. +% \begin{macrocode} \iff@nch@compatViii .\MessageBreak We now make it that large for the rest of the document.\MessageBreak This may cause the page layout to be inconsistent, however @@ -4065,6 +4129,11 @@ % \changes{fancyhdr v4.0}{2019/03/22}{Parameter \cs{headruleskip}.} % \changes{fancyhdr v4.0}{2019/03/25}{\cs{fancyheadinit} initialisation % code added and \cs{f@nch@reset} moved up.} +% \changes{fancyhdr v4.0.2}{2022/05/09}{Added +% \cs{leavevmode}\cs{ignorespaces} to each header/footer field. +% The \cs{leavevmode} prevents a bug when a field starts with a +% \cs{color} command. The \cs{ignorespaces} skips initial spaces in +% the parameter, as is usual in a \cs{parbox}, for backwards compatibility.} % Put together a header or footer given the left, center and right % text, fillers at left and right and a rule. The \cs{xlap} commands put % the text into an hbox of zero size, so overlapping text does not @@ -4091,11 +4160,11 @@ \hbox to\headwidth{% \f@nch@vbox\headheight{% \hbox{% - \rlap{\parbox[b]{\headwidth}{\raggedright#2}}% + \rlap{\parbox[b]{\headwidth}{\raggedright\leavevmode\ignorespaces#2}}% \hfill - \parbox[b]{\headwidth}{\centering#3}% + \parbox[b]{\headwidth}{\centering\leavevmode\ignorespaces#3}% \hfill - \llap{\parbox[b]{\headwidth}{\raggedleft#4}}% + \llap{\parbox[b]{\headwidth}{\raggedleft\leavevmode\ignorespaces#4}}% }% \vskip\headruleskip\relax \headrule @@ -4114,6 +4183,11 @@ % definition.} % \changes{fancyhdr v4.0}{2019/03/25}{\cs{fancyfootinit} initialisation % code added and \cs{f@nch@reset} moved up.} +% \changes{fancyhdr v4.0.2}{2022/05/09}{Added +% \cs{leavevmode}\cs{ignorespaces} to each header/footer field. +% The \cs{leavevmode} prevents a bug when a field starts with a +% \cs{color} command. The \cs{ignorespaces} skips initial spaces in +% the parameter, as is usual in a \cs{parbox}, for backwards compatibility.} % We put the \cs{footrule} in a \cs{vbox} to accommodate for flexible % footrules (e.g. using \cs{hrulefill}), so that the \cs{headwidth} will % be used as the line width. But to preserve the vertical spacing we @@ -4129,11 +4203,11 @@ \setbox0=\vbox{\footrule}\unvbox0 \vskip\footruleskip \hbox{% - \rlap{\parbox[t]{\headwidth}{\raggedright#2}}% + \rlap{\parbox[t]{\headwidth}{\raggedright\leavevmode\ignorespaces#2}}% \hfill - \parbox[t]{\headwidth}{\centering#3}% + \parbox[t]{\headwidth}{\centering\leavevmode\ignorespaces#3}% \hfill - \llap{\parbox[t]{\headwidth}{\raggedleft#4}}% + \llap{\parbox[t]{\headwidth}{\raggedleft\leavevmode\ignorespaces#4}}% }% }% }% @@ -4163,7 +4237,7 @@ % \changes{fancyhdr v4.0}{2019/03/21}{Put all the initialisation code in % \cs{f@nch@initialise}} % This macro initialises the headers and footers and \cs{chaptermark} -% and/or \cs{[sub]sectionmark} for pagestyle \texttt{fancy} +% and/or \Cmd{[sub]sectionmark} for pagestyle \texttt{fancy} % \begin{macrocode} \def\f@nch@initialise{% % \end{macrocode} @@ -4466,7 +4540,7 @@ % \end{macro} % \begin{macro}{\f@nch@pagestyle} % The actual code for \cs{fancypagestyle}. Build the page style body. -% Declare it as a fancyhdr page style. +% Declare it as a fancyhdr-based page style. % \changes{fancyhdr v4.0}{2019/09/05}{Make the definition of \cs{f@nch@pagestyle} \cs{long}.} % \begin{macrocode} \long\def\f@nch@pagestyle#1[#2]#3{% diff --git a/macros/latex/contrib/fancyhdr/fancyhdr.pdf b/macros/latex/contrib/fancyhdr/fancyhdr.pdf index b4396fbd3b..2138e986d7 100644 Binary files a/macros/latex/contrib/fancyhdr/fancyhdr.pdf and b/macros/latex/contrib/fancyhdr/fancyhdr.pdf differ -- cgit v1.2.3