diff options
author | Karl Berry <karl@freefriends.org> | 2018-02-12 22:57:04 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-02-12 22:57:04 +0000 |
commit | cf5b4b5f3a94209907198376f392cf77602c846a (patch) | |
tree | 521481fae493addaff72712c1cb60c217c5a772e /Master/texmf-dist/tex/latex | |
parent | d4a78554dddf1342cb938ec9a07035d87b0cef58 (diff) |
witharrows (12feb18)
git-svn-id: svn://tug.org/texlive/trunk@46616 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/witharrows/witharrows.sty | 386 |
1 files changed, 251 insertions, 135 deletions
diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index 513e618da95..296989cac2a 100644 --- a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty +++ b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{1.4} -\def\myfiledate{2018/01/20} +\def\myfileversion{1.5} +\def\myfiledate{2018/02/12} \RequirePackage{tikz} \usetikzlibrary{calc,arrows.meta,bending} \RequirePackage{l3keys2e} @@ -54,34 +54,44 @@ If~you~want,~you~can~use~the~option~"footnote"~and~the~footnotes~ within~the~environments~{WithArrows}~will~be~extracted~with~the~tools~ of~the~package~footnote.} -\cs_new_protected:Nn \__wa_test_beamer:n - {\@ifclassloaded {beamer} +\bool_if:NT \g__wa_footnote_bool + {\@ifclassloaded {beamer} {\msg_fatal:nn {witharrows} {Option~incompatible~with~Beamer}} - {} } -\bool_if:NT \g__wa_footnote_bool - {\__wa_test_beamer:n {footnote} + {} \@ifpackageloaded{footnotehyper} {\msg_fatal:nn {witharrows} {footnote~with~footnotehyper~package}} {} \usepackage{footnote}} \bool_if:NT \g__wa_footnotehyper_bool - {\__wa_test_beamer:n {footnotehyper} + {\@ifclassloaded {beamer} + {\msg_fatal:nn {witharrows} + {Option~incompatible~with~Beamer}} + {} \@ifpackageloaded{footnote} {\msg_fatal:nn {witharrows} {footnotehyper~with~footnote~package}} {} \usepackage{footnotehyper} \bool_gset_true:N \g__wa_footnote_bool} -\tikzset{__wa_node_style/.style={ +\tikzset{__wa_node_style/.style= { above = \l__wa_ystart_dim, inner~sep = 0 pt, minimum~width = 0pt, minimum~height = \l__wa_ygap_dim, red, - \bool_if:NT \l__wa_shownodes_bool {draw}}} -\tikzset{TipsOfWithArrows/.style= { > = {Straight~Barb[scale=1.2,bend]}} } + \bool_if:NT \l__wa_shownodes_bool {draw} }} +\tikzset{__wa_standard/.style= { remember~picture, + overlay, + name~prefix = wa-\l__wa_prefix_str- }} +\tikzset{WithArrows/arrow/tips/.style = { > = {Straight~Barb[scale=1.2,bend]} }} +\tikzset{WithArrows/arrow/.style = { align = left, + auto = left, + font = {\small\itshape}, + WithArrows/arrow/tips, + bend~left = 45, + -> }} \cs_if_free:NT \spread@equation {\cs_set:Npn \spread@equation{\openup\jot \cs_set:Npn \spread@equation {}}} @@ -92,18 +102,10 @@ \skip_new:N \l__wa_interline_skip \bool_new:N \l__wa_MoreColumns_bool \int_new:N \l__wa_pos_env_int -\int_new:N \l__wa_pos_arrows_int -\int_new:N \l__wa_previous_pos_arrows_int -\dim_new:N \l__wa_ygap_dim -\dim_set:Nn \l__wa_ygap_dim {0.4 ex} -\dim_new:N \l__wa_ystart_dim -\dim_set:Nn \l__wa_ystart_dim {0.4 ex} \dim_new:N \l__wa_xoffset_dim \dim_set:Nn \l__wa_xoffset_dim {3mm} -\bool_new:N \l__wa_shownodes_bool -\bool_new:N \l__wa_shownodenames_bool -\bool_new:N \l__wa_displaystyle_bool -\tl_clear_new:N \l__wa_options_tikz_tl +\int_new:N \l__wa_pos_arrows_int +\int_new:N \l__wa_previous_pos_arrows_int \dim_new:N \g__wa_x_dim \seq_new:N \g__wa_arrow_int_seq \int_new:N \g__wa_arrow_int @@ -113,71 +115,90 @@ \int_new:N \g__wa_line_bis_int \int_set:Nn \l__wa_level_int 1 \keys_define:nn {WithArrows/GlobalOrEnv} - { t .code:n = {\int_set:Nn \l__wa_pos_env_int 0}, + { t .code:n = \int_set:Nn \l__wa_pos_env_int 0, t .value_forbidden:n = true, - c .code:n = {\int_set:Nn \l__wa_pos_env_int 1}, + c .code:n = \int_set:Nn \l__wa_pos_env_int 1, c .value_forbidden:n = true, - b .code:n = {\int_set:Nn \l__wa_pos_env_int 2}, + b .code:n = \int_set:Nn \l__wa_pos_env_int 2, b .value_forbidden:n = true, ygap .dim_set:N = \l__wa_ygap_dim, ygap .value_required:n = true, + ygap .initial:n = 0.4 ex, ystart .dim_set:N = \l__wa_ystart_dim, ystart .value_required:n = true, + ystart .initial:n = 0.4 ex, MoreColumns .bool_set:N = \l__wa_MoreColumns_bool, MoreColumns .value_forbidden:n = true, CommandName .tl_set:N = \l__wa_CommandName_tl, - CommandName .initial:n = {Arrow}, + CommandName .initial:n = Arrow , CommandName .value_required:n = true, + TikzCode .tl_set:N = \l__wa_tikz_code_tl, + TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , + TikzCode .value_required:n = true, displaystyle .bool_set:N = \l__wa_displaystyle_bool, + displaystyle .initial:n = false, shownodes .bool_set:N = \l__wa_shownodes_bool, + shownodes .initial:n = false, shownodenames .bool_set:N = \l__wa_shownodenames_bool, + shownodenames .initial:n = false, group .code:n = {\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1} {\msg_error:nn {witharrows} {Two~options~are~incompatible}} - \int_set:Nn \l__wa_previous_pos_arrows_int 5 - \int_set:Nn \l__wa_pos_arrows_int 5}, + \int_set:Nn \l__wa_previous_pos_arrows_int 6 + \int_set:Nn \l__wa_pos_arrows_int 6} , group .value_forbidden:n = true, groups .code:n = {\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1} {\msg_error:nn {witharrows} {Two~options~are~incompatible}} - \int_set:Nn \l__wa_previous_pos_arrows_int 6 - \int_set:Nn \l__wa_pos_arrows_int 6}, - groups .value_forbidden:n = true} -\keys_define:nn {WithArrows} - {tikz .code:n = {\tl_put_right:Nn \l__wa_options_tikz_tl {,#1}}, + \int_set:Nn \l__wa_previous_pos_arrows_int 7 + \int_set:Nn \l__wa_pos_arrows_int 7} , + groups .value_forbidden:n = true, + CodeBefore .code:n = {\int_compare:nNnTF \l__wa_level_int = 1 + {\msg_error:nn {witharrows} {Option~will~be~ignored}} + {\tl_put_right:Nn \l__wa_code_before_tl {#1}}} , + CodeAfter .code:n = {\int_compare:nNnTF \l__wa_level_int = 1 + {\msg_error:nn {witharrows} {Option~will~be~ignored}} + {\tl_put_right:Nn \l__wa_code_after_tl {#1}}} , + unknown .code:n = \msg_error:nn {witharrows} {Option~unknown} + } +\keys_define:nn {WithArrows/General} + {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}}, + tikz .initial:n = {}, tikz .value_required:n = true, rr .value_forbidden:n = true, - rr .code:n = {\__wa_analyze_option_position:n 0}, + rr .code:n = \__wa_analyze_option_position:n 0 , ll .value_forbidden:n = true, - ll .code:n = {\__wa_analyze_option_position:n 1}, + ll .code:n = \__wa_analyze_option_position:n 1 , rl .value_forbidden:n = true, - rl .code:n = {\__wa_analyze_option_position:n 2}, + rl .code:n = \__wa_analyze_option_position:n 2 , lr .value_forbidden:n = true, - lr .code:n = {\__wa_analyze_option_position:n 3}, + lr .code:n = \__wa_analyze_option_position:n 3 , i .value_forbidden:n = true, - i .code:n = {\__wa_analyze_option_position:n 4}, + i .code:n = \__wa_analyze_option_position:n 5 , xoffset .code:n = {\bool_if:nTF {\int_compare_p:nNn \l__wa_level_int = 3 && - \int_compare_p:nNn \l__wa_pos_arrows_int > 4} + \int_compare_p:nNn \l__wa_pos_arrows_int > 5} {\msg_error:nn {witharrows} {Option~incompatible~with~"group(s)"}} - {\dim_set:Nn \l__wa_xoffset_dim {#1}}}, + {\dim_set:Nn \l__wa_xoffset_dim {#1}}} , xoffset .value_required:n = true, jot .code:n = {\int_compare:nNnTF \l__wa_level_int = 2 {\dim_set:Nn \jot {#1}} - {\msg_error:nn {witharrows} {Option~will~be~ignored} }}, + {\msg_error:nn {witharrows} + {Option~will~be~ignored}}} , jot .value_required:n = true, interline .code:n = {\int_compare:nNnTF \l__wa_level_int = 2 {\skip_set:Nn \l__wa_interline_skip {#1}} - {\msg_error:nn {witharrows} {Option~will~be~ignored}}}, + {\msg_error:nn {witharrows} + {Option~will~be~ignored}}} , interline .value_required:n = true, - jump .code:n = {\msg_error:nn {witharrows} {Option~will~be~ignored}}, - unknown .code:n = {\msg_error:nn {witharrows} {Option~unknown}} + jump .code:n = \msg_error:nn {witharrows} {Option~will~be~ignored} , + unknown .code:n = \msg_error:nn {witharrows} {Option~unknown} } \keys_define:nn {WithArrows/jump} {jump .code:n = {\int_set:Nn \l__wa_jump_int {#1} \int_compare:nNnF \l__wa_jump_int > 0 {\msg_error:nn {witharrows} - {The~option~"jump"~must~be~non~negative}}}, + {The~option~"jump"~must~be~non~negative}}} , jump .value_required:n = true} \cs_new_protected:Nn \__wa_analyze_option_position:n {\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1} @@ -185,13 +206,13 @@ {Two~options~are~incompatible}} \int_set:Nn \l__wa_previous_pos_arrows_int {#1} \bool_if:nTF { \int_compare_p:nNn \l__wa_level_int = 3 && - \int_compare_p:nNn \l__wa_pos_arrows_int > 4} + \int_compare_p:nNn \l__wa_pos_arrows_int > 5} {\msg_error:nn {witharrows} {Option~incompatible~with~"group(s)"}} {\int_set:Nn \l__wa_pos_arrows_int {#1}}} \NewDocumentCommand \WithArrowsOptions {m} {\int_set:Nn \l__wa_previous_pos_arrows_int {-1} - \keys_set_known:nnN {WithArrows} {#1} \l_tmpa_tl + \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl \keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl} \NewDocumentCommand \__wa_Arrow {O{} m O{}} { @@ -205,9 +226,9 @@ \prop_put:NnV \l_tmpa_prop {options} \l_tmpa_tl \prop_put:Nnn \l_tmpa_prop {label} {#2} \prop_gclear_new:c - {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\g__wa_arrow_int _prop} + {g__wa_arrow_\l__wa_prefix_str _\int_use:N\g__wa_arrow_int _prop} \prop_gset_eq:cN - {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\g__wa_arrow_int _prop} + {g__wa_arrow_\l__wa_prefix_str _\int_use:N\g__wa_arrow_int _prop} \l_tmpa_prop } \cs_new_protected:Nn \__wa_Arrow_first_column: @@ -224,22 +245,26 @@ \seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1 \seq_set_eq:NN \l_tmpa_seq \g__wa_position_in_the_tree_seq \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl - \tl_clear_new:N \l__wa_prefix_tl - \tl_set:Nx \l__wa_prefix_tl {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}} + \str_clear_new:N \l__wa_prefix_str + \str_set:Nx \l__wa_prefix_str {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}} \reverse_if:N \if_mode_math: - \msg_error:nn {witharrows} {{WithArrows}~used~outside~math~mode} - \fi - \bool_if:NT \g__wa_footnote_bool {\begin{savenotes}} + \msg_error:nn {witharrows} + {{WithArrows}~used~outside~math~mode} + \fi: \cs_set_eq:NN \\ \__wa_cr: \mathsurround = \c_zero_dim \int_zero_new:N \l__wa_initial_int \int_zero_new:N \l__wa_final_int \int_zero_new:N \l__wa_arrow_int \skip_zero:N \l__wa_interline_skip + \tl_clear_new:N \l__wa_code_before_tl + \tl_clear_new:N \l__wa_code_after_tl \int_set:Nn \l__wa_previous_pos_arrows_int {-1} \int_set:Nn \l__wa_level_int 2 - \keys_set_known:nnN {WithArrows} {#1} \l_tmpa_tl + \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl \keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl + \bool_if:NT \g__wa_footnote_bool {\begin{savenotes}} + \l__wa_code_before_tl \cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow \int_case:nn \l__wa_pos_env_int {0 {\vtop} @@ -255,15 +280,11 @@ & \int_gincr:N \g__wa_line_bis_int $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$ - \tikz[remember~picture,overlay] - \node[__wa_node_style] - (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-l) {} ; + \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-l) {} ; \hfil - \tikz[remember~picture,overlay] - \node[__wa_node_style] - (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-r) {} ; + \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-r) {} ; \bool_if:NT \l__wa_shownodenames_bool - {\hbox_overlap_right:n {\small wa-\tl_use:N\l__wa_prefix_tl + {\hbox_overlap_right:n {\small wa-\l__wa_prefix_str -\int_use:N\g__wa_line_int}} && \bool_if:NF \l__wa_MoreColumns_bool {\msg_error:nn {witharrows} {Third~column~in~a~{WithArrows}~environment}} @@ -275,14 +296,21 @@ \egroup \int_compare:nNnT \g__wa_line_bis_int < \g__wa_line_int {\msg_error:nn {witharrows} {All~lines~must~have~an~ampersand}} - \int_compare:nNnT \g__wa_arrow_int > 0 - {\int_compare:nNnTF \l__wa_pos_arrows_int > 4 + \int_compare:nNnT \g__wa_arrow_int > 0 + {\int_compare:nNnTF \l__wa_pos_arrows_int > 5 \__wa_draw_arrows: {\__wa_draw_arrows:nn 1 \g__wa_arrow_int}} + \group_begin: + \tikzset{every~picture/.style = __wa_standard} + \cs_set:Npn \NbLines {\int_use:N \g__wa_line_int} + \cs_set_eq:NN \MultiArrow \__wa_MultiArrow:nn + \cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow_code_after + \l__wa_code_after_tl + \group_end: \bool_if:NT \g__wa_footnote_bool {\end{savenotes}} \seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl \seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl - \seq_gput_right:Nx \g__wa_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl + 1}} + \seq_gput_right:Nx \g__wa_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl+1}} \int_compare:nNnT {\seq_count:N \g__wa_position_in_the_tree_seq} = 1 {\int_gincr:N \g__wa_last_env_int} \seq_gpop_right:NN \g__wa_arrow_int_seq {\l_tmpa_tl} @@ -311,15 +339,16 @@ \int_set:Nn \l__wa_arrow_int 1 \int_until_do:nNnn \l__wa_arrow_int > \g__wa_arrow_int { - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop} {initial} \l_tmpa_tl \int_set:Nn \l__wa_initial_int {\l_tmpa_tl} - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop} {final} \l_tmpa_tl \int_set:Nn \l__wa_final_int {\l_tmpa_tl} - \bool_if:nT { \int_compare_p:nNn \l__wa_pos_arrows_int = 6 + \bool_if:nT { \int_compare_p:nNn \l__wa_pos_arrows_int = 7 && \int_compare_p:nNn \l__wa_arrow_int > 1 - && \int_compare_p:nNn \l__wa_initial_int > \l__wa_last_line_of_group_int} + && \int_compare_p:nNn + \l__wa_initial_int > \l__wa_last_line_of_group_int} {\__wa_draw_arrows:nn \l__wa_first_arrow_of_group_int {\l__wa_arrow_int - 1} \bool_set_true:N \l__wa_new_group_bool} \bool_if:nTF \l__wa_new_group_bool @@ -327,9 +356,9 @@ \int_set:Nn \l__wa_first_arrow_of_group_int \l__wa_arrow_int \int_set:Nn \l__wa_first_line_of_group_int \l__wa_initial_int \int_set:Nn \l__wa_last_line_of_group_int \l__wa_final_int - \tikz[remember~picture] - \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-l) - in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ; + \tikz [__wa_standard] + \path let \p1=(\int_use:N\l__wa_initial_int-l) + in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ; } {\int_set:Nn \l__wa_last_line_of_group_int {\int_max:nn \l__wa_last_line_of_group_int \l__wa_final_int}} @@ -340,7 +369,7 @@ \group_end: } \cs_generate_variant:Nn \keys_set:nn {no} -\cs_new_protected:Nn \keys_set_WithArrows: {\keys_set:no {WithArrows}} +\cs_new_protected:Nn \__wa_keys_set: {\keys_set:no {WithArrows/General}} \cs_new_protected:Nn \__wa_draw_arrows:nn {\group_begin: \int_zero_new:N \l__wa_first_arrow_int @@ -350,20 +379,27 @@ \int_set:Nn \l__wa_arrow_int \l__wa_first_arrow_int \int_until_do:nNnn \l__wa_arrow_int > \l__wa_last_arrow_int { - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop} {initial} \l_tmpa_tl \int_set:Nn \l__wa_initial_int {\l_tmpa_tl} - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop} {final} \l_tmpa_tl \int_set:Nn \l__wa_final_int {\l_tmpa_tl} - \int_compare:nNnT \l__wa_final_int > \g__wa_line_int - {\msg_fatal:nn {witharrows} {Too~few~lines~for~an~arrow}} - \group_begin: + \int_compare:nNnTF \l__wa_final_int > \g__wa_line_int + {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}} + {\__wa_draw_arrows_i:} + \int_incr:N \l__wa_arrow_int + } + \group_end: + } +\cs_new:Nn \__wa_draw_arrows_i: + {\group_begin: \int_set:Nn \l__wa_previous_pos_arrows_int {-1} \int_set:Nn \l__wa_level_int 3 - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop} {options} \l_tmpa_tl - \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl} + \exp_args:NNo \exp_args:No + \__wa_keys_set: {\l_tmpa_tl,tikz={xshift = \l__wa_xoffset_dim}} \bool_set_false:N \l__wa_initial_r_bool \bool_set_false:N \l__wa_final_r_bool \int_case:nn \l__wa_pos_arrows_int @@ -371,63 +407,126 @@ \bool_set_true:N \l__wa_final_r_bool} 2 {\bool_set_true:N \l__wa_initial_r_bool} 3 {\bool_set_true:N \l__wa_final_r_bool}} - \int_compare:nNnT \l__wa_pos_arrows_int = 4 + \int_compare:nNnT \l__wa_pos_arrows_int = 5 { - \tikz[remember~picture] - \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-l) + \tikz [__wa_standard] + \path let \p1 = (\int_use:N\l__wa_initial_int-l) in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ; \__wa_actualise_x_value:nn \l__wa_initial_int \l__wa_final_int - } + } \tl_set:Nx \l__wa_initial_tl - {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int- - \bool_if:NTF\l__wa_initial_r_bool rl .south} + {\int_use:N\l__wa_initial_int-\bool_if:NTF\l__wa_initial_r_bool rl .south} \tl_set:Nx \l__wa_final_tl - {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_final_int- - \bool_if:NTF\l__wa_final_r_bool rl .north} - \begin{tikzpicture}[remember~picture, - overlay, - align=left, - auto=left, - font = {\small\itshape}, - TipsOfWithArrows, - ->, - looseness=1, - bend~left=45] - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} - {label} \l_tmpa_tl - \draw \exp_after:wN [\l__wa_options_tikz_tl] - let \p1 = (\tl_use:N \l__wa_initial_tl), - \p2 = (\tl_use:N \l__wa_final_tl) in - (\int_compare:nNnTF \l__wa_pos_arrows_int > 3 - {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y1} - {\x1 + \dim_use:N \l__wa_xoffset_dim, \y1} ) - to node [node~contents = {\tl_use:N \l_tmpa_tl}] {} - (\int_compare:nNnTF \l__wa_pos_arrows_int > 3 - {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y2} - {\x2 + \dim_use:N \l__wa_xoffset_dim, \y2} ) ; - \end{tikzpicture} + {\int_use:N\l__wa_final_int-\bool_if:NTF\l__wa_final_r_bool rl .north} + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop} + {label} + \l_tmpa_tl + \int_compare:nNnTF \l__wa_pos_arrows_int < 5 + {\tikz [__wa_standard] + \path let \p1 = (\l__wa_initial_tl), + \p2 = (\l__wa_final_tl) + in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p1} + \tl_gset:Nx \g_tmpb_tl {\p2}} ; } + {\tikz [__wa_standard] + \path let \p1 = (\l__wa_initial_tl), + \p2 = (\l__wa_final_tl) + in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g__wa_x_dim , \y1} + \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g__wa_x_dim , \y2}} ; } + \__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl} + \group_end: } +\cs_new_protected:Nn \__wa_def_function_tmpa:n + {\cs_set:Nn \__wa_tmpa:nnn + {\begin{tikzpicture}[__wa_standard,every~path/.style = {WithArrows/arrow}] + #1 + \end{tikzpicture}}} +\cs_new_protected:Nn \__wa_draw_arrow:nnn + {\exp_args:No \__wa_def_function_tmpa:n \l__wa_tikz_code_tl + \__wa_tmpa:nnn {#1} {#2} {#3} } +\cs_new_protected:Nn \__wa_actualise_x_value:nn + {\int_step_inline:nnnn {#1} \c_one {#2} + {\tikz [__wa_standard] + \path let \p1 = (##1-l) + in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\dim_max:nn \g__wa_x_dim {\x1}}}; }} +\cs_new:Npn \WithArrowsLastEnv {\int_use:N \g__wa_last_env_int} +\keys_define:nn {WithArrows/CodeAfter} + {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}} , + tikz .value_required:n = true, + rr .value_forbidden:n = true, + rr .code:n = \__wa_analyze_option_position:n 0 , + ll .value_forbidden:n = true, + ll .code:n = \__wa_analyze_option_position:n 1 , + rl .value_forbidden:n = true, + rl .code:n = \__wa_analyze_option_position:n 2 , + lr .value_forbidden:n = true, + lr .code:n = \__wa_analyze_option_position:n 3 , + v .value_forbidden:n = true, + v .code:n = \__wa_analyze_option_position:n 4 , + TikzCode .tl_set:N = \l__wa_tikz_code_tl, + TikzCode .value_required:n = true, + xoffset .dim_set:N = \l__wa_xoffset_dim, + xoffset .value_required:n = true} +\NewDocumentCommand \__wa_Arrow_code_after {O{} mmm O{}} + {\int_set:Nn \l__wa_pos_arrows_int 1 + \int_set:Nn \l__wa_previous_pos_arrows_int {-1} + \group_begin: + \int_set:Nn \l__wa_level_int 3 + \keys_set:nn {WithArrows/CodeAfter} + {#1,#5,tikz={xshift = \l__wa_xoffset_dim}} + \bool_set_false:N \l__wa_initial_r_bool + \bool_set_false:N \l__wa_final_r_bool + \int_case:nn \l__wa_pos_arrows_int + {0 {\bool_set_true:N \l__wa_initial_r_bool + \bool_set_true:N \l__wa_final_r_bool} + 2 {\bool_set_true:N \l__wa_initial_r_bool} + 3 {\bool_set_true:N \l__wa_final_r_bool}} + \cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-#2-l} + {\msg_error:nnn {witharrows} {Wrong~line~specification~in~Arrow} {#2}} + {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-#3-l} + {\msg_error:nnn {witharrows} {Wrong~line~specification~in~Arrow} {#3}} + {\int_compare:nNnTF \l__wa_pos_arrows_int = 4 + {\tikz [__wa_standard] + \path let \p1 = (#2-l.south), + \p2 = (#3-l.north), + \p3 = (\dim_max:nn {\x1} {\x2} , \y1), + \p4 = (\dim_max:nn {\x1} {\x2} , \y2) + in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p3} + \tl_gset:Nx \g_tmpb_tl {\p4}} ; } + {\tikz [__wa_standard] + \path let \p1 = (#2-\bool_if:NTF\l__wa_initial_r_bool rl .south), + \p2 = (#3-\bool_if:NTF\l__wa_final_r_bool rl .north) + in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p1} + \tl_gset:Nx \g_tmpb_tl {\p2}} ; } + \__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }} \group_end: - \int_incr:N \l__wa_arrow_int } - \group_end: - } -\cs_new_protected:Nn \__wa_actualise_x_value:nn - {\group_begin: - \int_set:Nn \l__wa_initial_int {#1} - \int_set:Nn \l__wa_final_int {#2} - \int_compare:nNnT \l__wa_final_int > \g__wa_line_int - {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}} - \int_set:Nn \l_tmpa_int \l__wa_initial_int - \int_until_do:nNnn \l_tmpa_int > \l__wa_final_int - {\tikz[remember~picture] - \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l_tmpa_int-l) - in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\dim_max:nn \g__wa_x_dim {\x1}}} ; - \int_incr:N \l_tmpa_int - } - \group_end: - } -\NewDocumentCommand \WithArrowsLastEnv {} - {\int_use:N \g__wa_last_env_int} +\cs_new_protected:Nn \__wa_MultiArrow:nn + { + \foreach \x in {#1} {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-\x-l} + {\msg_error:nnx {witharrows} + {Wrong~line~specification~in~MultiArrow} {\x}} + {\clist_gput_right:Nx \g_tmpa_clist {\x}}} + \int_compare:nNnTF {\clist_count:N \g_tmpa_clist} < 2 + {\msg_error:nn {witharrows} {Too~small~specification~for~MultiArrow}} + {\clist_sort:Nn \g_tmpa_clist + {\int_compare:nNnTF {##1} > {##2} + {\sort_return_swapped:} + {\sort_return_same:}} + \clist_pop:NN \g_tmpa_clist \l_tmpa_tl + \clist_reverse:N \g_tmpa_clist + \clist_pop:NN \g_tmpa_clist \l_tmpb_tl + \exp_args:Nx \__wa_MultiArrow_i:n {\g_tmpa_clist} + \begin{tikzpicture}[__wa_standard,every~path/.style={WithArrows/arrow}] + \draw [<->] ($(\l_tmpa_tl-r.south)+(\l__wa_xoffset_dim,0)$) + -- ++(5mm,0) + -- node {#2} ($(\l_tmpb_tl-r.south)+(\l__wa_xoffset_dim+5mm,0)$) + -- ($(\l_tmpb_tl-r.south)+(\l__wa_xoffset_dim,0)$) ; + \end{tikzpicture} } } + +\cs_new_protected:Nn \__wa_MultiArrow_i:n + {\begin{tikzpicture}[__wa_standard,every~path/.style={WithArrows/arrow}] + \foreach \k in {#1} + {\draw[<-] ($(\k-r.south)+(\l__wa_xoffset_dim,0)$) -- ++(5mm,0) ;} ; + \end{tikzpicture}} \msg_new:nnn {witharrows} {Third~column~in~a~{WithArrows}~environment} {By~default,~a~\{WithArrows\}~environment~can~only~have~two~columns.~ @@ -443,7 +542,8 @@ \msg_new:nnn {witharrows} {Too~few~lines~for~an~arrow} {An~arrow~specified~in~line~\int_use:N \l__wa_initial_int\ can't~be~drawn~ - because~it~arrives~after~the~last~line~of~the~environment.} + because~it~arrives~after~the~last~line~of~the~environment.~If~you~go~on,~ + this~arrow~will~be~ignored.} \msg_new:nnn {witharrows} {{WithArrows}~used~outside~math~mode} {The~environment~\{WithArrows\}~should~be~used~only~in~math~mode.~ @@ -459,7 +559,8 @@ 3 {lr} 4 {i} 5 {group} - 6 {groups}}"~ + 6 {groups} + 7 {v}}"~ previously~set~in~the~same~ \int_case:nn\l__wa_level_int {1 {command~\token_to_str:N\WithArrowsOptions} @@ -469,8 +570,9 @@ \msg_new:nnnn {witharrows} {All~lines~must~have~an~ampersand} {All~lines~of~an~environment~\{WithArrows\}~must~have~an~second~column~ - (because~the~nodes~are~created~in~the~second~column).~You~can~go~on~but~maybe~ - you~will~have~an~pgf~error~for~an~undefined~shape.} + (because~the~nodes~are~created~in~the~second~column).~ + You~can~go~on~but~maybe~you~will~have~an~pgf~error~for~ + an~undefined~shape.} {The~ampersand~can~be~implicit~ (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} \msg_new:nnn {witharrows} @@ -488,8 +590,8 @@ If~you~go~on,~it~will~be~ignored.} \msg_new:nnn {witharrows} {Option~unknown} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~meaningless~in~the~context.~ - If~you~go~on,~it~will~be~ignored.} + {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~ + meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.} \msg_new:nnn {witharrows} {Arrow~in~first~column} {You~should~not~use~the~command~\token_to_str:N\Arrow\ @@ -502,6 +604,20 @@ ~a~new~functionality~with~\token_to_str:N\Arrow\ in~the~ first~column).\\ However~you~can~go~on~for~this~time.} +\msg_new:nnn {witharrows} + {Wrong~line~specification~in~Arrow} + {The~specification~of~line~"#1"~you~use~in~\token_to_str:N\Arrow\ + ~doesn't~exist.\\ + If~you~go~on,~the~arrow~will~be~ignored.} +\msg_new:nnn {witharrows} + {Wrong~line~specification~in~MultiArrow} + {The~specification~of~line~"#1"~doesn't~exist.\\ + If~you~go~on,~it~will~be~ignored~for~\token_to_str:N \MultiArrow.} +\msg_new:nnn {witharrows} + {Too~small~specification~for~MultiArrow} + {The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\ + is~too~small:~we~need~at~least~two~lines.~If~you~go~on,~the~ + command~\token_to_str:N\MultiArrow\ ~will~be~ignored.} \endinput %% %% End of file `witharrows.sty'. |