diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/witharrows/witharrows.sty | 223 |
1 files changed, 137 insertions, 86 deletions
diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index 296989cac2a..66b60045581 100644 --- a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty +++ b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty @@ -18,10 +18,10 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{1.5} -\def\myfiledate{2018/02/12} +\def\myfileversion{1.6} +\def\myfiledate{2018/05/10} \RequirePackage{tikz} -\usetikzlibrary{calc,arrows.meta,bending} +\usetikzlibrary{arrows.meta,bending} \RequirePackage{l3keys2e} \ProvidesExplPackage {witharrows} @@ -93,14 +93,13 @@ bend~left = 45, -> }} \cs_if_free:NT \spread@equation - {\cs_set:Npn \spread@equation{\openup\jot - \cs_set:Npn \spread@equation {}}} + {\cs_set_protected:Npn \spread@equation + {\openup\jot + \cs_set_protected:Npn \spread@equation {}}} \seq_new:N \g__wa_position_in_the_tree_seq \seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1 \int_new:N \g__wa_last_env_int - \skip_new:N \l__wa_interline_skip -\bool_new:N \l__wa_MoreColumns_bool \int_new:N \l__wa_pos_env_int \dim_new:N \l__wa_xoffset_dim \dim_set:Nn \l__wa_xoffset_dim {3mm} @@ -113,6 +112,7 @@ \int_new:N \g__wa_line_int \seq_new:N \g__wa_line_bis_int_seq \int_new:N \g__wa_line_bis_int +\tl_new:N \l__wa_name_tl \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, @@ -127,8 +127,16 @@ 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 .code:n = { \msg_redirect_name:nnn + {witharrows} + {Third~column~in~an~environment} + {none} }, MoreColumns .value_forbidden:n = true, + AllowLineWithoutAmpersand .code:n = { \msg_redirect_name:nnn + {witharrows} + {All~lines~must~have~an~ampersand} + {none} }, + AllowLineWithoutAmpersand .value_forbidden:n = true, CommandName .tl_set:N = \l__wa_CommandName_tl, CommandName .initial:n = Arrow , CommandName .value_required:n = true, @@ -156,9 +164,15 @@ 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 + CodeBefore .value_required:n = true, + 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}}} , + CodeAfter .value_required:n = true, + name .code:n = {\int_compare:nNnTF \l__wa_level_int = 1 + {\msg_error:nn {witharrows} {Option~will~be~ignored}} + {\tl_set:Nn \l__wa_name_tl {#1}}} , + name .value_required:n = true, unknown .code:n = \msg_error:nn {witharrows} {Option~unknown} } \keys_define:nn {WithArrows/General} @@ -195,10 +209,10 @@ 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}}} , + {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}}} , jump .value_required:n = true} \cs_new_protected:Nn \__wa_analyze_option_position:n {\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1} @@ -252,7 +266,7 @@ {{WithArrows}~used~outside~math~mode} \fi: \cs_set_eq:NN \\ \__wa_cr: - \mathsurround = \c_zero_dim + \dim_zero:N \mathsurround \int_zero_new:N \l__wa_initial_int \int_zero_new:N \l__wa_final_int \int_zero_new:N \l__wa_arrow_int @@ -280,14 +294,27 @@ & \int_gincr:N \g__wa_line_bis_int $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$ - \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-l) {} ; + \tl_if_empty:NTF \l__wa_name_tl + {\tikz [remember~picture,overlay] + \node [__wa_node_style, + name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-l] {} ;} + {\tikz [remember~picture,overlay] + \node [__wa_node_style, + name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-l, + alias = \l__wa_name_tl-\int_use:N\g__wa_line_int-l] {} ;} \hfil - \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-r) {} ; + \tl_if_empty:NTF \l__wa_name_tl + {\tikz [remember~picture,overlay] + \node [__wa_node_style, + name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-r] {} ;} + {\tikz [remember~picture,overlay] + \node [__wa_node_style, + name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-r, + alias = \l__wa_name_tl-\int_use:N\g__wa_line_int-r] {} ;} \bool_if:NT \l__wa_shownodenames_bool {\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}} + && \msg_error:nn {witharrows} {Third~column~in~an~environment} $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {##}$ \cr } @@ -356,13 +383,14 @@ \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 [__wa_standard] - \path let \p1=(\int_use:N\l__wa_initial_int-l) - in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ; - } + \begin{tikzpicture} [__wa_standard] + \tikz@parse@node\pgfutil@firstofone (\int_use:N\l__wa_initial_int-l) + \dim_gset:Nn \g__wa_x_dim \pgf@x + \end{tikzpicture} + } {\int_set:Nn \l__wa_last_line_of_group_int {\int_max:nn \l__wa_last_line_of_group_int \l__wa_final_int}} - \__wa_actualise_x_value:nn \l__wa_initial_int \l__wa_final_int + \__wa_update_x_value:nn \l__wa_initial_int \l__wa_final_int \int_incr:N \l__wa_arrow_int } \__wa_draw_arrows:nn \l__wa_first_arrow_of_group_int \g__wa_arrow_int @@ -386,8 +414,12 @@ {final} \l_tmpa_tl \int_set:Nn \l__wa_final_int {\l_tmpa_tl} \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:} + {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}} + {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-\int_use:N\l__wa_initial_int-l} + { \msg_error:nn {witharrows} {A~PGF~node~doesn't~exist} } + {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-\int_use:N\l__wa_final_int-l} + { \msg_error:nn {witharrows} {A~PGF~node~doesn't~exist} } + {\__wa_draw_arrows_i:}}} \int_incr:N \l__wa_arrow_int } \group_end: @@ -409,10 +441,11 @@ 3 {\bool_set_true:N \l__wa_final_r_bool}} \int_compare:nNnT \l__wa_pos_arrows_int = 5 { - \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 + \begin{tikzpicture} [__wa_standard] + \tikz@parse@node\pgfutil@firstofone (\int_use:N\l__wa_initial_int-l) + \dim_gset:Nn \g__wa_x_dim \pgf@x + \end{tikzpicture} + \__wa_update_x_value:nn \l__wa_initial_int \l__wa_final_int } \tl_set:Nx \l__wa_initial_tl {\int_use:N\l__wa_initial_int-\bool_if:NTF\l__wa_initial_r_bool rl .south} @@ -422,16 +455,19 @@ {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}} ; } + {\begin{tikzpicture} [__wa_standard] + \tikz@scan@one@point\pgfutil@firstofone(\l__wa_initial_tl) + \tl_gset:Nx \g_tmpa_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y} + \tikz@scan@one@point\pgfutil@firstofone(\l__wa_final_tl) + \tl_gset:Nx \g_tmpb_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y} + \end{tikzpicture} +} + {\begin{tikzpicture} [__wa_standard] + \tikz@scan@one@point\pgfutil@firstofone (\l__wa_initial_tl) + \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g__wa_x_dim , \dim_use:N \pgf@y} + \tikz@scan@one@point\pgfutil@firstofone (\l__wa_final_tl) + \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g__wa_x_dim , \dim_use:N \pgf@y} + \end{tikzpicture}} \__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl} \group_end: } \cs_new_protected:Nn \__wa_def_function_tmpa:n @@ -442,11 +478,13 @@ \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 +\cs_new_protected:Nn \__wa_update_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_if_exist:cT {pgf@sh@ns@wa-\l__wa_prefix_str-##1-l} + {\begin{tikzpicture} [__wa_standard] + \tikz@scan@one@point\pgfutil@firstofone (##1-l) + \dim_gset:Nn \g__wa_x_dim {\dim_max:nn \g__wa_x_dim \pgf@x} + \end{tikzpicture} } } } \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}} , @@ -480,22 +518,27 @@ 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}} + {\msg_error:nnx {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}} + {\msg_error:nnx {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}} ; } + {\begin{tikzpicture} [__wa_standard] + \tikz@scan@one@point\pgfutil@firstofone(#2-l.south) + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \tikz@scan@one@point\pgfutil@firstofone(#3-l.north) + \dim_set:Nn \l_tmpa_dim {\dim_max:nn \l_tmpa_dim \pgf@x} + \tl_gset:Nx \g_tmpa_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \l_tmpb_dim} + \tl_gset:Nx \g_tmpb_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \pgf@y} + \end{tikzpicture} } + {\begin{tikzpicture} [__wa_standard] + \tikz@scan@one@point\pgfutil@firstofone + (#2-\bool_if:NTF\l__wa_initial_r_bool rl .south) + \tl_gset:Nx \g_tmpa_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y} + \tikz@scan@one@point\pgfutil@firstofone + (#3-\bool_if:NTF\l__wa_final_r_bool rl .north) + \tl_gset:Nx \g_tmpb_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y} + \end{tikzpicture}} \__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }} \group_end: } @@ -503,7 +546,8 @@ { \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}} + {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}} @@ -528,8 +572,8 @@ {\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.~ + {Third~column~in~an~environment} + {By~default,~an~environment~\{WithArrows\}~can~only~have~two~columns.~ Maybe~you~have~forgotten~a~\str_use:N \c_backslash_str \str_use:N \c_backslash_str.~If~you~really~want~more~than~two~columns,~ you~should~use~the~option~"MoreColumns"~at~a~global~level~or~for~ @@ -542,38 +586,40 @@ \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.~If~you~go~on,~ - this~arrow~will~be~ignored.} + because~it~arrives~after~the~last~line~of~the~environment~(remind~that~ + the~command~\token_to_str:N\Arrow\ must~be~in~the~*start*~line~ + of~the~arrow).~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.~ Nevertheless,~you~can~go~on.} -\msg_new:nnn {witharrows} - {Two~options~are~incompatible} - {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~ - this~option~is~incompatible~or~redundant~with~the~option~" - \int_case:nn\l__wa_previous_pos_arrows_int - {0 {rr} - 1 {ll} - 2 {rl} - 3 {lr} - 4 {i} - 5 {group} - 6 {groups} - 7 {v}}"~ - previously~set~in~the~same~ - \int_case:nn\l__wa_level_int - {1 {command~\token_to_str:N\WithArrowsOptions} - 2 {declaration~of~options~of~the~environment~\{WithArrows\}} - 3 {command~\token_to_str:N\Arrow}}.~ - If~you~go~on,~I~will~overwrite~the~first~option.} +\msg_new:nnn {witharrows} + {Two~options~are~incompatible} + {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~ + this~option~is~incompatible~or~redundant~with~the~option~" + \int_case:nn\l__wa_previous_pos_arrows_int + {0 {rr} + 1 {ll} + 2 {rl} + 3 {lr} + 4 {v} + 5 {i} + 6 {group} + 7 {groups}}"~ + previously~set~in~the~same~ + \int_case:nn\l__wa_level_int + {1 {command~\token_to_str:N\WithArrowsOptions} + 2 {declaration~of~options~of~the~environment~\{WithArrows\}} + 3 {command~\token_to_str:N\Arrow}}.~ + If~you~go~on,~I~will~overwrite~the~first~option.} \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.} - {The~ampersand~can~be~implicit~ + {All~lines~of~an~environment~\{WithArrows\}~should~have~an~second~column~ + (because~the~nodes~are~created~in~the~second~column).~However,~you~can~go~but~you~will~ + have~an~error~if~one~of~your~arrows~needs~an~PGF~node~absent~by~lack~of~ampersand.~ + If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~ + AllowLineWithoutAmpersand.} + {Morevoer, the~ampersand~can~be~implicit~ (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} \msg_new:nnn {witharrows} {Option~incompatible~with~"group(s)"} @@ -618,6 +664,11 @@ {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.} +\msg_new:nnn {witharrows} + {A~PGF~node~doesn't~exist} + {A~PGF~node~necessary~to~draw~an~arrow~doesn't~exist~ + because~you~didn't~put~an~ampersand~in~the~corresponding~line.~ + If~you~go~on,~the~arrow~will~be~ignored.} \endinput %% %% End of file `witharrows.sty'. |