diff options
author | Karl Berry <karl@freefriends.org> | 2018-08-17 22:07:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-08-17 22:07:14 +0000 |
commit | f9047214bb3b3331596399de89146394b95ff879 (patch) | |
tree | 766444bdbf0bb129dd29adbe952f48389910b377 /Master/texmf-dist/tex/latex | |
parent | 75514ad93d6ce5ed759579702f8059c7a48c1d86 (diff) |
witharrows (17aug18)
git-svn-id: svn://tug.org/texlive/trunk@48422 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/witharrows/witharrows.sty | 172 |
1 files changed, 162 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index 789ee8a9624..f9bb8aa968a 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.8} -\def\myfiledate{2018/07/25} +\def\myfileversion{1.9} +\def\myfiledate{2018/08/17} \RequirePackage{tikz} \usetikzlibrary{arrows.meta,bending} \RequirePackage{l3keys2e} @@ -140,6 +140,7 @@ \bool_new:N \l__wa_fleqn_bool \dim_new:N \l__wa_mathindent_dim \dim_set:Nn \l__wa_mathindent_dim {25pt} +\bool_new:N \l__wa_wrap_lines_bool \int_set:Nn \l__wa_level_int 1 \keys_define:nn {WithArrows/GlobalOrEnv} { t .code:n = {\bool_if:NTF \l__wa_in_witharrows_bool @@ -229,7 +230,12 @@ {Multiple~labels} {none}}}, AllowMultipleLabels .value_forbidden:n = true, - fleqn .default:n = true, + wrap-lines .code:n = {\bool_if:NTF \l__wa_in_witharrows_bool + {\msg_error:nn {witharrows} {Option~will~be~ignored}} + {\tl_if_eq:nnTF {#1} {true} + {\bool_set_true:N \l__wa_wrap_lines_bool} + {\bool_set_false:N \l__wa_wrap_lines_bool}}}, + wrap-lines .default:n = true, unknown .code:n = \msg_error:nn {witharrows} {Option~unknown} } \keys_define:nn {WithArrows/General} @@ -425,7 +431,8 @@ {\group_align_safe_end: \bool_if:NF \l__wa_in_witharrows_bool {\bool_if:NTF \l__wa_notag_bool - {&} + {& \tikz [remember~picture,overlay] + \coordinate [name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-v ] ; } { \tl_if_empty:NT \l__wa_tag_tl {\int_gincr:N \c@equation} @@ -452,7 +459,11 @@ \bool_gset_eq:NN \g_tmpa_bool \l__wa_tag_star_bool & \cs_set_eq:NN \theequation \g_tmpa_tl \bool_if:NT \g_tmpa_bool {\cs_set:Npn \tagform@ {}} - \hbox_overlap_left:n \@eqnnum + \hbox_overlap_left:n + { \tikz [__wa_standard] + \coordinate [name = \int_use:N \g__wa_line_int-v ] ; + \quad + \@eqnnum} }} \cr\noalign{\skip_vertical:n {#1 + \l__wa_interline_skip} \scan_stop:}} @@ -533,6 +544,16 @@ \egroup \egroup $$ + \bool_if:NT \l__wa_wrap_lines_bool + {\dim_gzero_new:N \g__wa_x_right_dim + \dim_gset:Nn \g__wa_x_right_dim \c_max_dim + \begin{tikzpicture} [__wa_standard] + \int_step_variable:nnnNn 1 1 \g__wa_line_int \l_tmpa_int + {\tikz@parse@node\pgfutil@firstofone (\l_tmpa_int-v) + \dim_set:Nn \l_tmpa_dim \pgf@x + \dim_compare:nNnT \l_tmpa_dim < \g__wa_x_right_dim + {\dim_gset:Nn \g__wa_x_right_dim \l_tmpa_dim} } + \end{tikzpicture}} \__wa_post_environment: \bool_if:nT \c__wa_mathtools_loaded_bool {\MH_if_boolean:nT {show_only_refs} @@ -675,7 +696,16 @@ #1 \end{tikzpicture}}} \cs_new_protected:Nn \__wa_draw_arrow:nnn - {\exp_args:No \__wa_def_function_tmpa:n \l__wa_tikz_code_tl + { + \bool_if:nT {\l__wa_wrap_lines_bool && ! \l__wa_in_witharrows_bool} + {\tl_set:Nn \l__wa_tikz_code_tl + {\draw (##1) to node (__wa_label) {} (##2) ; + \tikz@parse@node \pgfutil@firstofone (__wa_label.west) + \path (__wa_label.west) + node [anchor = west, + text~width = \dim_eval:n {\g__wa_x_right_dim - \pgf@x - 0.3333 em}] + {##3} ; }} + \exp_args:No \__wa_def_function_tmpa:n \l__wa_tikz_code_tl \__wa_tmpa:nnn {#1} {#2} {#3} } \cs_generate_variant:Nn \__wa_draw_arrow:nnn {nno} \cs_new_protected:Nn \__wa_update_x_value:nn @@ -760,16 +790,25 @@ \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)$) + \draw [<->] ([xshift = \l__wa_xoffset_dim]\l_tmpa_tl-r.south) -- ++(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)$) ; + -- node (__wa_label) {} + ([xshift = \l__wa_xoffset_dim+5mm]\l_tmpb_tl-r.south) + -- ([xshift = \l__wa_xoffset_dim]\l_tmpb_tl-r.south) ; + \tikz@parse@node \pgfutil@firstofone (__wa_label.west) + \path (__wa_label.west) + node [anchor = west, + text~width = + {\bool_if:nTF {\l__wa_wrap_lines_bool && ! \l__wa_in_witharrows_bool} + {\dim_eval:n {\g__wa_x_right_dim - \pgf@x - 0.3333 em}} + {20 cm}} + ] {#2} ; \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) ;} ; + {\draw[<-] ([xshift = \l__wa_xoffset_dim]\k-r.south) -- ++(5mm,0) ;} ; \end{tikzpicture}} \msg_new:nnn {witharrows} {Third~column~in~an~environment~{WithArrows}} @@ -910,6 +949,119 @@ If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~ "AllowMultipleLabels"~at~the~global~or~ environment~level~(this~doesn't~work~if~you~use~cleveref).} +\coffin_new:N \l__wa_halign_coffin +\NewDocumentEnvironment {CasesWithArrows} {m O{}} + {\hbox_set:Nn \l_tmpa_box {$\left\{\vcenter to 1cm {} \right.$} + \dim_zero_new:N \l__wa_delim_wd_dim + \dim_set:Nn \l__wa_delim_wd_dim {\box_wd:N \l_tmpa_box} + \box_clear_new:N \l__wa_left_part_box + \hbox_set:Nn \l__wa_left_part_box + {$\bool_if:NT \l__wa_displaystyle_bool \displaystyle #1 {}$} + \bool_if:nT \c__wa_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\MT_showonlyrefs_false: + \MH_set_boolean_T:n {show_only_refs} + \bool_set_true:N \l__wa_notag_bool}} + \bool_if:NT \c__wa_amsmath_loaded_bool \intertext@ + \if_mode_math: + \msg_error:nn {witharrows} + {{DispWithArrows}~used~in~math~mode} + \fi: + \bool_set_false:N \l__wa_in_witharrows_bool + % + \__wa_pre_environment:n {#2} + \nointerlineskip + \hbox_to_wd:nn {0.6\linewidth} {} + $$ + \spread@equation + \vcoffin_set:Nnw \l__wa_halign_coffin \displaywidth + \bool_if:NTF \l__wa_fleqn_bool + {\tabskip = \c_zero_skip} + {\tabskip = 0 pt plus 1000 pt minus 1000 pt} + \bool_if:NTF \c__wa_amsmath_loaded_bool + {\cs_set_eq:NN \__wa_old_label \ltx@label} + {\cs_set_eq:NN \__wa_old_label \label} + \cs_set:Npn \notag {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{DispWithArrows}} + {\notag}} + \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{DispWithArrows}} + {\nonumber}} + \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{DispWithArrows}} + {\tag}} + \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{DispWithArrows}} + {\label}} + \halign to \displaywidth \bgroup + \int_gincr:N \g__wa_line_int + \cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow_first_column: + \strut + \bool_if:NT \l__wa_fleqn_bool + {\skip_horizontal:n \l__wa_mathindent_dim} + \hfil + \skip_horizontal:n {\box_wd:N \l__wa_left_part_box + \l__wa_delim_wd_dim} + $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {##}$ + \tabskip = \c_zero_skip + & + \cs_set:Npn \notag {\bool_set_true:N \l__wa_notag_bool} + \cs_set_eq:NN \nonumber \notag + \cs_set_eq:NN \tag \__wa_tag + \cs_set_eq:NN \label \__wa_label:n + $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$ + \tabskip = 0 pt plus 1000 pt minus 1000 pt + \int_gincr:N \g__wa_line_bis_int + \tikz [remember~picture,overlay] + \node [__wa_node_style, + name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-l, + alias = {\tl_if_empty:NF \l__wa_name_tl + {\l__wa_name_tl-\int_use:N\g__wa_line_int-l}} ] {} ; + \hfil + \tikz [remember~picture,overlay] + \node [__wa_node_style, + name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-r, + alias = {\tl_if_empty:NF \l__wa_name_tl + {\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}} + & ## + \tabskip = \c_zero_skip + && \msg_error:nn {witharrows} {Third~column~in~an~environment~{DispWithArrows}} + \if_false: ## \fi: + \cr} + { \\ + \egroup + \unskip\unpenalty\unskip\unpenalty + \box_set_to_last:N \l_tmpa_box + \nointerlineskip + \box_use:N \l_tmpa_box + \dim_gzero_new:N \g__wa_alignment_dim + \dim_gset:Nn \g__wa_alignment_dim {\box_wd:N \l_tmpa_box} + \box_clear_new:N \l__wa_new_box + \hbox_set:Nn \l__wa_new_box {\hbox_unpack_clear:N \l_tmpa_box} + \dim_compare:nNnT {\box_wd:N \l__wa_new_box} < \g__wa_alignment_dim + {\dim_gset:Nn \g__wa_alignment_dim {\box_wd:N \l__wa_new_box}} + \vcoffin_set_end: + \hbox_to_wd:nn \displaywidth + { + \bool_if:NTF \l__wa_fleqn_bool + {\skip_horizontal:n \l__wa_mathindent_dim} + {\hfil} + \hbox_to_wd:nn \g__wa_alignment_dim + { \box_use_drop:N \l__wa_left_part_box + \dim_set:Nn \l_tmpa_dim { \box_ht:N \l__wa_halign_coffin + + \box_dp:N \l__wa_halign_coffin} + $\left\{ \vcenter to \l_tmpa_dim {\vfil} \right.$} + \hfil} + \coffin_typeset:Nnnnn \l__wa_halign_coffin {l} {vc} {-\displaywidth} \c_zero_dim + $$ + \__wa_post_environment: + \bool_if:nT \c__wa_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + \MT_showonlyrefs_true:} + \ignorespacesafterend + } \endinput %% %% End of file `witharrows.sty'. |