summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/multicolrule
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-01-02 22:38:45 +0000
committerKarl Berry <karl@freefriends.org>2019-01-02 22:38:45 +0000
commit96127255d3941d19fe21092832cd440feb3b389e (patch)
tree0d9cdb91268fb5b05bdddead8b0ff65adbd212b5 /Master/texmf-dist/tex/latex/multicolrule
parent023983237fa8328ef5350e22cd5db6d01193d73c (diff)
multicolrule (2jan19)
git-svn-id: svn://tug.org/texlive/trunk@49579 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/multicolrule')
-rw-r--r--Master/texmf-dist/tex/latex/multicolrule/multicolrule.sty186
1 files changed, 126 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/latex/multicolrule/multicolrule.sty b/Master/texmf-dist/tex/latex/multicolrule/multicolrule.sty
index 1494adbee72..93bcc3950f5 100644
--- a/Master/texmf-dist/tex/latex/multicolrule/multicolrule.sty
+++ b/Master/texmf-dist/tex/latex/multicolrule/multicolrule.sty
@@ -15,19 +15,25 @@
%%
\RequirePackage{expl3}
\RequirePackage{xparse}
-\ProvidesExplPackage {multicolrule} {2018/12/21} {1.1}
- {Decorative~vertical~rules~between~columns}
+ % |\DeclareMCRulePattern| \marg{name} \marg{key-value list}
+ % \end{syntax}
+
+\ProvidesExplPackage {multicolrule} {2019/01/01} {1.2}
+ {Decorative vertical rules between columns}
\RequirePackage{l3keys2e}
\RequirePackage{xpatch}
\RequirePackage{xcolor}
\RequirePackage{scrlfile}
\msg_new:nnn {multicolrule} {patch-success} {Patched~#1.}
\msg_new:nnn {multicolrule} {patch-failure} {Error~patching~#1.}
-\msg_new:nnn {multicolrule} {tikz-required}
+\msg_new:nnnn {multicolrule} {tikz-required} {Tikz~required}
{The~'#1'~setting~requires~tikz~to~work.~Either~load~tikz~before~you~load~
multicolrule~or~use~multicolrule's~'tikz'~package~option.}
-\msg_new:nnn {multicolrule} {multicol-loaded} {You~are~using~the~'twocolumn'~
- option~with~multicol~already~loaded.~You~will~likely~run~into~problems.}
+\msg_new:nnnn {multicolrule} {multicol-loaded} {Multicol~loaded} {You~are~
+ using~the~'twocolumn'~option~with~multicol~already~loaded.~You~will~likely~
+ run~into~problems.}
+\msg_new:nnnn {multicolrule} {pattern-undefined} {Pattern~undefined}
+ {The~multicolrule~pattern~'#1'~has~not~been~defined.}
\bool_new:N \g__mcrule_twocolumn_bool
\bool_new:N \g__mcrule_use_tikz_bool
\int_new:N \l__mcrule_repeat_int
@@ -39,6 +45,11 @@
\dim_new:N \l__mcrule_extend_reserve_dim
\tl_new:N \l__mcrule_color_name_tl
\tl_new:N \l__mcrule_color_model_tl
+\prop_new:N \g__mcrule_patterns_prop
+\int_new:N \g__mcrule_pattern_count_int
+\int_new:N \g__mcrule_pattern_for_int
+\int_new:N \g__mcrule_pattern_after_int
+\seq_new:N \l__mcrule_pattern_list_seq
\@ifpackageloaded{tikz}
{
\bool_gset_true:N \g__mcrule_use_tikz_bool
@@ -54,14 +65,15 @@
\cs_new:Npn \__mcrule_column_depth: {}
\cs_new_protected:Npn \__mcrule_patch_mcol_output:N #1
{
- \xpatchcmd{#1} {\vrule\@width\columnseprule} {\mcruledivider}
+ \xpatchcmd{#1} {\columnseprulecolor\vrule\@width\columnseprule}
+ {\mcruledivider}
{\msg_info:nnn {multicolrule} {patch-success} {#1}}
{\msg_info:nnn {multicolrule} {patch-failure} {#1}}
}
\cs_new_protected:Npn \__mcrule_patch_twocol_output:N #1
{
\xpatchcmd{#1} {\normalcolor\vrule\@width\columnseprule}
- {\columnseprulecolor\mcruledivider}
+ {\mcruledivider}
{\msg_info:nnn {multicolrule} {patch-success} {#1}}
{\msg_info:nnn {multicolrule} {patch-failure} {#1}}
}
@@ -95,17 +107,44 @@
\cs_gset_eq:NN \RLmulticolcolumns \RTLmulticolcolumns
}
}
-\cs_new:Npn \mcruledivider
+\cs_new_protected:Npn \mcruledivider
{
+ \int_compare:nNnTF {\g__mcrule_pattern_after_int} > {\c_zero_int}
+ {
+ \int_gdecr:N \g__mcrule_pattern_after_int
+ }
+ {
+ \bool_lazy_and:nnT
+ {\int_compare_p:nNn {\seq_count:N \l__mcrule_pattern_list_seq} > {\c_zero_int}}
+ {! \int_compare_p:nNn {\g__mcrule_pattern_for_int} = {\c_zero_int}}
+ {
+ \int_gincr:N \g__mcrule_pattern_count_int
+ \int_compare:nNnT {\g__mcrule_pattern_count_int} >
+ {\seq_count:N \l__mcrule_pattern_list_seq}
+ {
+ \int_gset:Nn \g__mcrule_pattern_count_int {\c_one_int}
+ }
+ \tl_set:Nx \l_tmpa_tl {\seq_item:Nn \l__mcrule_pattern_list_seq {\g__mcrule_pattern_count_int} }
+ \tl_if_blank:VF \l_tmpa_tl
+ {
+ \__mcrule_set_pattern:V \l_tmpa_tl
+ }
+ \int_compare:nNnT {\g__mcrule_pattern_for_int} > {\c_zero_int}
+ {
+ \int_gdecr:N \g__mcrule_pattern_for_int
+ }
+ }
+ }
+ \columnseprulecolor
\bool_lazy_and:nnT
- {\dim_compare_p:nNn {\columnseprule} > {0pt}}
- {\int_compare_p:nNn {\l__mcrule_repeat_int} > {0}}
+ {\dim_compare_p:nNn {\columnseprule} > {\c_zero_dim}}
+ {\int_compare_p:nNn {\l__mcrule_repeat_int} > {\c_zero_int}}
{
- \__mcrule_divider:
- \prg_replicate:nn {\l__mcrule_repeat_int - 1}
+ \mcrule_divider:
+ \prg_replicate:nn {\l__mcrule_repeat_int - \c_one_int}
{
\hspace{\l__mcrule_repeat_distance_dim}
- \__mcrule_divider:
+ \mcrule_divider:
}
}
}
@@ -129,28 +168,28 @@
{\bool_not_p:n {\g__mcrule_twocolumn_bool}}
{
\dim_compare:nNnTF
- {\@colroom - \__mcrule_column_height: - \__mcrule_extend_reserve:} > {0pt}
+ {\@colroom - \__mcrule_column_height: - \__mcrule_extend_reserve:} > {\c_zero_dim}
{\@colroom - \__mcrule_column_height: - \__mcrule_extend_reserve:}
- {0pt}
+ {\c_zero_dim}
}
{\l__mcrule_extend_bot_dim}
}
\cs_new:Npn \__mcrule_extend_reserve:
{
- \dim_compare:nNnTF {\l__mcrule_extend_reserve_dim} > {0pt}
+ \dim_compare:nNnTF {\l__mcrule_extend_reserve_dim} > {\c_zero_dim}
{\dim_eval:n {\l__mcrule_extend_reserve_dim + \multicolsep}}
- {0pt}
+ {\c_zero_dim}
}
-\cs_new:Npn \__mcrule_divider: {\vrule\@width\columnseprule}
+\cs_new:Npn \mcrule_divider: {\vrule\@width\columnseprule}
\cs_new_nopar:Npn \__mcrule_pattern:nnn #1#2#3
{
\box_move_down:nn {\__mcrule_column_total_depth:}
{
\vbox_to_ht:nn {\__mcrule_column_total_height:}
{
- \vfill
- \kern #2 \hbox:n{#1} \kern #3
- \vfill
+ \tex_vfill:D
+ \tex_kern:D #2 \hbox:n{#1} \tex_kern:D #3
+ \tex_vfill:D
}
}
}
@@ -160,11 +199,11 @@
{
\vbox_to_ht:nn {\__mcrule_column_total_height:}
{
- \cleaders \vbox:n
+ \tex_cleaders:D \vbox:n
{
- \kern #2 \hbox:n{#1} \kern #3
+ \tex_kern:D #2 \hbox:n{#1} \tex_kern:D #3
}
- \vfill
+ \tex_vfill:D
}
}
}
@@ -241,6 +280,25 @@
{\color[\l__mcrule_color_model_tl]{\l__mcrule_color_name_tl}}
}
}
+\cs_new_protected:Npn \__mcrule_set_pattern_list:n #1
+{
+ \seq_set_split:Nnn \l__mcrule_pattern_list_seq {,} {#1}
+ \int_gzero:N \g__mcrule_pattern_count_int
+ \int_gzero:N \g__mcrule_pattern_after_int
+ \int_gset:Nn \g__mcrule_pattern_for_int {-1}
+}
+\cs_new_protected:Npn \__mcrule_set_pattern:n #1
+{
+ \prop_get:NnNTF \g__mcrule_patterns_prop {#1} \l_tmpa_tl
+ {
+ \keys_set_filter:nnV {mcrule} {patterns} \l_tmpa_tl
+ }
+ {
+ \msg_error:nnn {multicolrule} {pattern-undefined} {#1}
+ }
+ \tl_set:Nn \l_tmpa_tl {\prop_item:Nn \g__mcrule_patterns_prop {#1}}
+}
+\cs_generate_variant:Nn \__mcrule_set_pattern:n {V}
\keys_define:nn {mcrule}
{
extend-top .dim_set:N = \l__mcrule_extend_top_dim,
@@ -249,51 +307,51 @@
extend-fill .default:n = true,
extend-reserve .dim_set:N = \l__mcrule_extend_reserve_dim,
line-style .choice:,
- line-style / default .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / default .code:n = \cs_set:Npn \mcrule_divider:
{\vrule\@width\columnseprule},
- line-style / solid .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / solid .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_solid_line:},
- line-style / dots .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dots .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {.}{1pt}{1pt}},
- line-style / dense-dots .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dense-dots .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {.}{1pt}{0pt}},
- line-style / loose-dots .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loose-dots .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {.}{2pt}{2pt}},
- line-style / circles .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / circles .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {\__mcrule_circle:}{1pt}{1pt}},
- line-style / dense-circles .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dense-circles .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {\__mcrule_circle:}{1pt}{0pt}},
- line-style / loose-circles .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loose-circles .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {\__mcrule_circle:}{2pt}{2pt}},
- line-style / solid-circles .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / solid-circles .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {\__mcrule_solid_circle:}{1pt}{1pt}},
- line-style / dense-solid-circles .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dense-solid-circles .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {\__mcrule_solid_circle:}{1pt}{0pt}},
- line-style / loose-solid-circles .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loose-solid-circles .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn {\__mcrule_solid_circle:}{2pt}{2pt}},
- line-style / dotted .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dotted .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_line_pattern:nnnn {dotted}{\columnseprule}{1pt}{1pt}},
- line-style / densely-dotted .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / densely-dotted .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_line_pattern:nnnn {densely~dotted}{\columnseprule}{1pt}{0pt}},
- line-style / loosely-dotted .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loosely-dotted .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_line_pattern:nnnn {loosely~dotted}{\columnseprule}{2pt}{2pt}},
- line-style / dashed .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dashed .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_line_pattern:nnnn {dashed}{3pt}{1.5pt}{1.5pt}},
- line-style / densely-dashed .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / densely-dashed .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_line_pattern:nnnn {densely~dashed}{3pt}{1pt}{1pt}},
- line-style / loosely-dashed .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loosely-dashed .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_line_pattern:nnnn {loosely~dashed}{3pt}{3pt}{3pt}},
- line-style / dash-dot .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dash-dot .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern_line:n{dash~dot}},
- line-style / densely-dash-dot .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / densely-dash-dot .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern_line:n{densely~dash~dot}},
- line-style / loosely-dash-dot .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loosely-dash-dot .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern_line:n{loosely~dash~dot}},
- line-style / dash-dot-dot .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / dash-dot-dot .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern_line:n{dash~dot~dot}},
- line-style / densely-dash-dot-dot .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / densely-dash-dot-dot .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern_line:n{densely~dash~dot~dot}},
- line-style / loosely-dash-dot-dot .code:n = \cs_set:Npn \__mcrule_divider:
+ line-style / loosely-dash-dot-dot .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern_line:n{loosely~dash~dot~dot}},
color .code:n = {
\tl_set:Nn \l__mcrule_color_name_tl {#1}
@@ -303,11 +361,11 @@
\tl_set:Nn \l__mcrule_color_model_tl {#1}
\__mcrule_set_rule_color:
},
- custom-line .code:n = \cs_set:Npn \__mcrule_divider:
+ custom-line .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tikz_picture:n {#1}},
- custom-pattern .code:n = \cs_set:Npn \__mcrule_divider:
+ custom-pattern .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_pattern:nnn #1},
- custom-tile .code:n = \cs_set:Npn \__mcrule_divider:
+ custom-tile .code:n = \cs_set:Npn \mcrule_divider:
{\__mcrule_tile_pattern:nnn #1},
width .choice:,
width / ultra-thin .code:n = \dim_set:Nn \columnseprule {0.1pt},
@@ -317,30 +375,38 @@
width / thick .code:n = \dim_set:Nn \columnseprule {0.8pt},
width / very-thick .code:n = \dim_set:Nn \columnseprule {1.2pt},
width / ultra-thick .code:n = \dim_set:Nn \columnseprule {1.6pt},
- width / unknown .code:n = {\dim_set:Nn \columnseprule {#1}},
- repeat .int_set:N = \l__mcrule_repeat_int,
- repeat-distance .dim_set:N = \l__mcrule_repeat_distance_dim,
- single .meta:n = {
+ width / unknown .code:n = \dim_set:Nn \columnseprule {#1},
+ repeat .int_set:N = \l__mcrule_repeat_int,
+ repeat-distance .dim_set:N = \l__mcrule_repeat_distance_dim,
+ single .meta:n = {
repeat = 1,
repeat-distance = #1
},
- single .default:n = \columnseprule,
- double .meta:n = {
+ single .default:n = \columnseprule,
+ double .meta:n = {
repeat = 2,
repeat-distance = #1
},
- double .default:n = \columnseprule,
- triple .meta:n = {
+ double .default:n = \columnseprule,
+ triple .meta:n = {
repeat = 3,
repeat-distance = #1
},
- triple .default:n = \columnseprule,
+ triple .default:n = \columnseprule,
+ patterns .code:n = \__mcrule_set_pattern_list:n {#1},
+ patterns .groups:n = {patterns},
+ pattern-after .int_gset:N = \g__mcrule_pattern_after_int,
+ pattern-for .int_gset:N = \g__mcrule_pattern_for_int,
}
\NewDocumentCommand{\SetMCRule}{m}
{
\keys_set:nn {mcrule} {#1}
}
-%% Copyright (C) 2018 by Karl Hagen <latex@polysyllabic.com>
+\NewDocumentCommand{\DeclareMCRulePattern}{m m}
+{
+ \prop_gput:Nnn \g__mcrule_patterns_prop {#1} {#2}
+}
+%% Copyright (C) 2018-2019 by Karl Hagen <latex@polysyllabic.com>
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either