% % ***************** THE DASHRULEX PACKAGE ***************** % % Copyright (C) 2024 by Qu Yi % % 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/12/03}{1.01f} {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} } } } \ExplSyntaxOff \NewDocumentCommand{\drx@parse@dash} {mm>{\SplitArgument{1}{:}}m} {\drx@parse@dash@inner{#1}{#2}#3} \ExplSyntaxOn \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} } } \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: \IfValueT{#2} { \tl_set:Nn \l__drx_tmpa_tl { [#2] } \IfValueT{#3}{\tl_put_right: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} } { \tex_kern:D -#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'.