blob: 58c104c0e1f550ccc81f040ffd1347d12b2c69de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
%
% ***************** THE DASHRULEX PACKAGE *****************
%
% Copyright (C) 2024 by Qu Yi <toquyi@163.com>
%
% This work may be distributed and/or modified under the
% conditions of the CC-BY 4.0 License.
% The latest version of this license is in
% https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}[2012/02/12]
\RequirePackage{xparse}
\ProvidesExplPackage{dashrulex}{2024/03/18}{1.00b}
{Draw dashed rules}
\DeclareDocumentCommand{\hdashrule}{O{0pt}O{x}mmm}
{
\tl_if_blank:nTF {#5}
{ \rule[#1]{#3}{#4} }
{
\mbox{}
\use:c { #2leaders }
\hbox:n
{
\clist_map_inline:nn {#5}
{ \drx@parse@dash{#1}{#4}{##1} }
}
\skip_horizontal:n {#3}
\mbox{}
}
}
\NewDocumentCommand{\drx@parse@dash}
{mm>{\SplitArgument{1}{|}}m}
{\drx@parse@dash@inner{#1}{#2}#3}
\cs_set_protected:Npn \drx@parse@dash@inner #1#2#3#4
{
\IfNoValueTF{#4}
{\vrulemod[#1]{#3}{#2}\skip_horizontal:n {#3}}
{\vrulemod[#1]{#3}{#2}\skip_horizontal:n {#4}}
}
\NewDocumentCommand{\hanyrule}{O{x}mm}
{
\mbox{}
\use:c { #1leaders }
\hbox:n { \clist_map_inline:nn {#3} {##1} }
\skip_horizontal:n {#2}
\mbox{}
}
\int_new:N \l__drx_vrule_counter_int
\int_set:Nn \l__drx_vrule_counter_int { 1 }
\dim_new:N \l__drx_vrule_height_dim
\tl_new:N \l__drx_tmpa_tl
\cs_new_protected:Npn \drx@step@counter@height #1
{
\int_incr:N \l__drx_vrule_counter_int
\dim_add:Nn \l__drx_vrule_height_dim {#1}
}
\NewDocumentCommand{\vrulemod}{O{0pt}oomm}
{
\group_begin:
\IfValueTF{#2}
{
\tl_set:Nn \l__drx_tmpa_tl { [#2] }
\IfValueT{#3}{\tl_put_right:Nn \l__drx_tmpa_tl { [#3] }}
}
{\IfValueT{#3}{\tl_set:Nn \l__drx_tmpa_tl { [#3] }}}
\exp_last_unbraced:Nnf
\raisebox{#1}{\l__drx_tmpa_tl}
{
\clist_map_inline:nn {#5}
{
\int_compare:nNnTF { \l__drx_vrule_counter_int } > { 1 }
{
\int_if_even:nTF { \l__drx_vrule_counter_int }
{ \drx@step@counter@height{##1} }
{
\kern -#4
\exp_args:NV
\raisebox\l__drx_vrule_height_dim{\rule{#4}{##1}}
\drx@step@counter@height{##1}
}
}
{
\rule{#4}{##1}
\drx@step@counter@height{##1}
}
}
}
\group_end:
}
\endinput
%
% End of file `dashrulex.sty'.
|