Debian Codegraph @

texmf-dist/tex/generic/witharrows/witharrows.tex

raw
1 %%
2 %% This is file `witharrows.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% witharrows.dtx (with options: `plain-TeX')
8 %%
9 %% Copyright (C) 2017-2024 by F. Pantigny
10 %%
11 %% This file may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either
13 %% version 1.3 of this license or (at your option) any later
14 %% version. The latest version of this license is in:
15 %%
16 %% http://www.latex-project.org/lppl.txt
17 %%
18 %% and version 1.3 or later is part of all distributions of
19 %% LaTeX version 2005/12/01 or later.
20 %%
21 \def\myfileversion{2.9a}
22 \def\myfiledate{2024/10/19}
23
24 \input tikz.tex
25 \input expl3-generic.tex
26 \usetikzlibrary{arrows.meta}
27 \usepgfmodule{bending} % https://texnique.fr/osqa/questions/12199
28 \ExplSyntaxOn
29 \catcode `\@ = 11
30 \cs_new_protected:Npn \__witharrows_msg_new:nn { \msg_new:nnn { witharrows } }
31 \cs_new_protected:Npn \__witharrows_msg_new:nnn #1 #2 #3
32 {
33 \bool_if:NTF \c__witharrows_messages_for_Overleaf_bool
34 { \msg_new:nnn { witharrows } { #1 } { #2 \\ #3 } }
35 { \msg_new:nnnn { witharrows } { #1 } { #2 } { #3 } }
36 }
37 \cs_new_protected:Npn \__witharrows_msg_redirect_name:nn
38 { \msg_redirect_name:nnn { witharrows } }
39 \cs_new_protected:Npn \__witharrows_error:n { \msg_error:nn { witharrows } }
40 \cs_new_protected:Npn \__witharrows_warning:n { \msg_warning:nn { witharrows } }
41 \cs_new_protected:Npn \__witharrows_fatal:n { \msg_fatal:nn { witharrows } }
42 \cs_new_protected:Npn \__witharrows_error:nn { \msg_error:nnn { witharrows } }
43 \cs_generate_variant:Nn \__witharrows_error:nn { n e }
44 \cs_new_protected:Npn \__witharrows_error_or_warning:n
45 { \bool_if:NTF \c__witharrows_messages_for_Overleaf_bool \__witharrows_warning:n \__witharrows_error:n }
46 \bool_set:Nn \c__witharrows_messages_for_Overleaf_bool
47 {
48 \str_if_eq_p:on \c_sys_jobname_str { _region_ } % for Emacs
49 || \str_if_eq_p:on \c_sys_jobname_str { output } % for Overleaf
50 }
51 \bool_new:N \g__witharrows_beamer_bool
52 \cs_generate_variant:Nn \seq_set_split:Nnn { N e e }
53 \cs_generate_variant:Nn \keys_precompile:nnN { n n c }
54 \prg_generate_conditional_variant:Nnn \tl_if_novalue:n { o } { F }
55 \exp_args_generate:n { N N N n o }
56 \cs_new_protected:Npn \__witharrows_sort_seq:N #1
57 {
58 \seq_sort:Nn #1
59 {
60 \str_compare:eNeTF
61 { \str_lowercase:n { ##1 } } < { \str_lowercase:n { ##2 } }
62 \sort_return_same:
63 \sort_return_swapped:
64 }
65 }
66 \cs_new_protected:Npn \__witharrows_set_seq_of_str_from_clist:Nn #1 #2
67 {
68 \seq_set_from_clist:Nn #1 { #2 }
69 \seq_set_map_e:NNn #1 #1 { \tl_to_str:n { ##1 } }
70 }
71 \cs_new_protected:Npn \__witharrows_save:N #1
72 {
73 \seq_set_split:Nee \l_tmpa_seq
74 { \char_generate:nn { `_ } { 12 } }
75 { \cs_to_str:N #1 }
76 \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl
77 \str_set:Ne \l_tmpa_str { \seq_item:Nn \l_tmpa_seq { -1 } }
78 \use:c { \l_tmpa_str _if_exist:cF }
79 { g _\seq_use:Nnnn \l_tmpa_seq _ _ _ }
80 {
81 \use:c { \l_tmpa_str _new:c }
82 { g _\seq_use:Nnnn \l_tmpa_seq _ _ _ }
83 }
84 \use:c { \l_tmpa_str _gset_eq:cN }
85 { g _\seq_use:Nnnn \l_tmpa_seq _ _ _ } #1
86 }
87 \cs_new_protected:Npn \__witharrows_restore:N #1
88 {
89 \seq_set_split:Nee \l_tmpa_seq
90 { \char_generate:nn { `_ } { 12 } }
91 { \cs_to_str:N #1 }
92 \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl
93 \str_set:Ne \l_tmpa_str { \seq_item:Nn \l_tmpa_seq { -1 } }
94 \use:c { \l_tmpa_str _set_eq:Nc }
95 #1 { g_\seq_use:Nnnn \l_tmpa_seq _ _ _ }
96 }
97 \tikzset
98 {
99 __witharrows_node_style / .style =
100 {
101 above = \l__witharrows_ystart_dim ,
102 inner~sep = \c_zero_dim ,
103 minimum~width = \c_zero_dim ,
104 minimum~height = \l__witharrows_ygap_dim
105 }
106 }
107 \tikzset
108 {
109 __witharrows_standard / .style =
110 {
111 remember~picture ,
112 overlay ,
113 name~prefix = wa - \l__witharrows_prefix_str -
114 } ,
115 __witharrows_standard_arrow / .style =
116 {
117 __witharrows_standard ,
118 every~path / .style = WithArrows / arrow
119 }
120 }
121 \sys_if_engine_xetex:T
122 {
123 \tikzset
124 {
125 __witharrows_standard_arrow / .append~style =
126 { every~node / .append~style = { text = . } }
127 }
128 }
129 \tikzset
130 {
131 WithArrows / arrow / tips / .style =
132 { > = { Straight~Barb [ scale = 1.2 , bend ] } }
133 }
134 \tikzset
135 {
136 WithArrows / arrow / .style =
137 {
138 align = flush~left ,
139 auto = left ,
140 WithArrows / arrow / tips ,
141 bend~left = 45 ,
142 ->
143 }
144 }
145 \cs_new_protected:Npn \spread@equation
146 {
147 \openup \jot
148 \cs_set_eq:NN \spread@equation \prg_do_nothing:
149 }
150 \tl_new:N \l__witharrows_left_brace_tl
151 \tl_set_eq:NN \l__witharrows_left_brace_tl \c_novalue_tl
152 \bool_new:N \l__witharrows_in_WithArrows_bool
153 \bool_new:N \l__witharrows_in_DispWithArrows_bool
154 \bool_new:N \l__witharrows_in_code_after_bool
155 \seq_new:N \g__witharrows_position_in_the_tree_seq
156 \seq_gput_right:Nn \g__witharrows_position_in_the_tree_seq 1
157 \int_new:N \g__witharrows_last_env_int
158 \int_new:N \l__witharrows_pos_env_int
159 \int_new:N \l__witharrows_pos_arrow_int
160 \int_set:Nn \l__witharrows_pos_arrow_int 3
161 \seq_new:N \g__witharrows_arrow_int_seq
162 \int_new:N \g__witharrows_arrow_int
163 \seq_new:N \g__witharrows_line_int_seq
164 \int_new:N \g__witharrows_line_int
165 \seq_new:N \g__witharrows_col_int_seq
166 \int_new:N \g__witharrows_col_int
167 \seq_new:N \g__witharrows_static_col_int_seq
168 \int_new:N \g__witharrows_static_col_int
169 \str_new:N \l__witharrows_command_name_str
170 \str_set:Nn \l__witharrows_command_name_str { Arrow }
171 \str_new:N \l__witharrows_string_Arrow_for_msg_str
172 \str_set:Ne \l__witharrows_string_Arrow_for_msg_str { \token_to_str:N \Arrow }
173 \seq_new:N \g__witharrows_names_seq
174 \bool_new:N \l__witharrows_in_first_columns_bool
175 \bool_new:N \l__witharrows_new_group_bool
176 \bool_new:N \l__witharrows_initial_r_bool
177 \bool_new:N \l__witharrows_final_r_bool
178 \tl_new:N \l__witharrows_initial_tl
179 \tl_new:N \l__witharrows_final_tl
180 \int_new:N \l__witharrows_nb_cols_int
181 \str_new:N \l__witharrows_format_str
182 \dim_new:N \l__witharrows_arrow_width_dim
183 \dim_set_eq:NN \l__witharrows_arrow_width_dim \c_max_dim
184 \dim_new:N \l__witharrows_up_and_down_radius_dim
185 \dim_set:Nn \l__witharrows_up_and_down_radius_dim { 4 pt }
186 \seq_new:N \l__witharrows_o_arrows_seq
187 \dim_new:N \l__witharrows_xoffset_for_o_arrows_dim
188 \dim_set:Nn \l__witharrows_xoffset_for_o_arrows_dim { 2 mm }
189 \bool_new:N \l__witharrows_right_overlap_bool
190 \bool_set_true:N \l__witharrows_right_overlap_bool
191 \cs_new_protected:Npn \__witharrows_eval_if_allowed:n #1
192 {
193 \str_if_empty:NTF \l__witharrows_previous_key_str
194 {
195 \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_str
196 #1
197 }
198 { \__witharrows_error:n { Incompatible~options } }
199 }
200 \cs_new_protected:Npn \__witharrows_fix_pos_option:n #1
201 { \__witharrows_eval_if_allowed:n { \int_set:Nn \l__witharrows_pos_arrow_int { #1 } } }
202 \keys_define:nn { WithArrows / Global }
203 {
204 max-length-of-arrow .dim_set:N = \l__witharrows_max_length_of_arrow_dim ,
205 max-length-of-arrow .value_required:n = true ,
206 max-length-of-arrow .initial:n = 2 cm ,
207 ygap .dim_set:N = \l__witharrows_ygap_dim ,
208 ygap .initial:n = 0.4 ex ,
209 ygap .value_required:n = true ,
210 ystart .dim_set:N = \l__witharrows_ystart_dim ,
211 ystart .value_required:n = true ,
212 ystart .initial:n = 0.4 ex ,
213 more-columns .code:n =
214 \__witharrows_msg_redirect_name:nn { Too~much~columns~in~WithArrows } { none } ,
215 more-columns .value_forbidden:n = true ,
216 command-name .code:n =
217 \str_set:Nn \l__witharrows_command_name_str { #1 }
218 \str_set:Ne \l__witharrows_string_Arrow_for_msg_str
219 { \c_backslash_str Arrow~alias~\c_backslash_str #1 } ,
220 command-name .value_required:n = true ,
221 tikz-code .tl_set:N = \l__witharrows_tikz_code_tl ,
222 tikz-code .initial:n = \draw~(#1)~to~node{#3}~(#2)~; ,
223 tikz-code .value_required:n = true ,
224 displaystyle .bool_set:N = \l__witharrows_displaystyle_bool ,
225 displaystyle .default:n = true ,
226 show-nodes .code:n =
227 \tikzset { __witharrows_node_style / .append~style = { draw , red } } ,
228 show-node-names .bool_set:N = \l__witharrows_show_node_names_bool ,
229 show-node-names .default:n = true ,
230 group .code:n =
231 \str_if_empty:NTF \l__witharrows_previous_key_str
232 {
233 \str_set:Nn \l__witharrows_previous_key_str { group }
234 \seq_remove_all:Nn \l__witharrows_options_Arrow_seq { xoffset }
235 \int_set:Nn \l__witharrows_pos_arrow_int 7
236 }
237 { \__witharrows_error:n { Incompatible~options } } ,
238 group .value_forbidden:n = true ,
239 groups .code:n =
240 \str_if_empty:NTF \l__witharrows_previous_key_str
241 {
242 \str_set:Nn \l__witharrows_previous_key_str { groups }
243 \seq_if_in:NnF \l__witharrows_options_Arrow_seq { new-group }
244 { \seq_put_right:Nn \l__witharrows_options_Arrow_seq { new-group } }
245 \seq_remove_all:Nn \l__witharrows_options_Arrow_seq { xoffset }
246 \int_set:Nn \l__witharrows_pos_arrow_int 6
247 }
248 { \__witharrows_error:n { Incompatible~options } } ,
249 groups .value_forbidden:n = true ,
250 tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } ,
251 tikz .value_required:n = true ,
252 rr .code:n = \__witharrows_fix_pos_option:n 3 ,
253 rr .value_forbidden:n = true ,
254 ll .code:n = \__witharrows_fix_pos_option:n 1 ,
255 ll .value_forbidden:n = true ,
256 rl .code:n = \__witharrows_fix_pos_option:n 2 ,
257 rl .value_forbidden:n = true ,
258 lr .code:n = \__witharrows_fix_pos_option:n 0 ,
259 lr .value_forbidden:n = true ,
260 i .code:n = \__witharrows_fix_pos_option:n 5 ,
261 i .value_forbidden:n = true ,
262 xoffset .dim_set:N = \l__witharrows_xoffset_dim ,
263 xoffset .value_required:n = true ,
264 xoffset .initial:n = 3 mm ,
265 jot .dim_set:N = \jot ,
266 jot .value_required:n = true ,
267 interline .skip_set:N = \l__witharrows_interline_skip ,
268 start-adjust .dim_set:N = \l__witharrows_start_adjust_dim ,
269 start-adjust .initial:n = 0.4 ex ,
270 start-adjust .value_required:n = true ,
271 end-adjust .dim_set:N = \l__witharrows_end_adjust_dim ,
272 end-adjust .initial:n = 0.4 ex ,
273 end-adjust .value_required:n = true ,
274 adjust .meta:n = { start-adjust = #1 , end-adjust = #1 } ,
275 adjust .value_required:n = true ,
276 up-and-down .code:n = \keys_set:nn { WithArrows / up-and-down } { #1 } ,
277 up-and-down .value_required:n = true ,
278 no-arrows .code:n =
279 \cs_set_eq:NN \__witharrows_draw_arrows:nn \use_none:nn
280 \cs_set_eq:NN \__witharrows_draw_arrow:nnn \use_none:nnn ,
281 no-arrows .value_forbidden:n = true
282 }
283 \keys_define:nn { WithArrows / WithArrowsSpecific }
284 {
285 t .code:n = \int_set:Nn \l__witharrows_pos_env_int O ,
286 t .value_forbidden:n = true ,
287 c .code:n = \int_set:Nn \l__witharrows_pos_env_int 1 ,
288 c .value_forbidden:n = true ,
289 b .code:n = \int_set:Nn \l__witharrows_pos_env_int 2 ,
290 b .value_forbidden:n = true ,
291 right-overlap .bool_set:N = \l__witharrows_right_overlap_bool ,
292 right-overlap .value_required:n = true
293 }
294 \clist_new:N \c__witharrows_ext_delimiters_clist
295 \clist_set:Nn \c__witharrows_ext_delimiters_clist
296 {
297 ., \{, (, [, \lbrace, \lbrack, \lgroup, \langle, \lmoustache, \lceil, \lfloor
298 }
299 \keys_define:nn { WithArrows / DispWithArrowsSpecific }
300 {
301 fleqn .bool_set:N = \l__witharrows_fleqn_bool ,
302 fleqn .default:n = true ,
303 mathindent .skip_set:N = \l__witharrows_mathindent_skip ,
304 mathindent .initial:n = 25 pt ,
305 mathindent .value_required:n = true ,
306 wrap-lines .bool_set:N = \l__witharrows_wrap_lines_bool ,
307 wrap-lines .default:n = true ,
308 replace-left-brace-by .code:n =
309 {
310 \tl_set:Ne \l_tmpa_tl { \tl_head:n { #1 } }
311 \clist_if_in:NoTF
312 \c__witharrows_ext_delimiters_clist
313 \l_tmpa_tl
314 { \tl_set:Nn \l__witharrows_replace_left_brace_by_tl { #1 } }
315 { \__witharrows_error:n { Bad~value~for~replace~brace~by } }
316 } ,
317 replace-left-brace-by .initial:n = \lbrace ,
318 }
319 \keys_define:nn { WithArrows / Env }
320 {
321 name .code:n =
322 \str_set:Nn \l_tmpa_str { #1 }
323 \seq_if_in:NoTF \g__witharrows_names_seq \l_tmpa_str
324 { \__witharrows_error:n { Duplicate~name } }
325 { \seq_gput_left:No \g__witharrows_names_seq \l_tmpa_str }
326 \str_set_eq:NN \l__witharrows_name_str \l_tmpa_str ,
327 name .value_required:n = true ,
328 code-before .code:n = \tl_put_right:Nn \l__witharrows_code_before_tl { #1 } ,
329 code-before .value_required:n = true,
330 CodeBefore .meta:n = { code-before = #1 } ,
331 code-after .code:n = \tl_put_right:Nn \l__witharrows_code_after_tl { #1 } ,
332 code-after .value_required:n = true ,
333 CodeAfter .meta:n = { code-after = #1 } ,
334 format .code:n =
335 \tl_if_empty:nTF { #1 }
336 { \__witharrows_error:n { Invalid~option~format } }
337 {
338 \regex_match:nnTF { \A[rclRCL]*\Z } { #1 }
339 { \tl_set:Nn \l__witharrows_format_str { #1 } }
340 { \__witharrows_error:n { Invalid~option~format } }
341 } ,
342 format .value_required:n = true
343 }
344 \keys_define:nn { WithArrows }
345 {
346 WithArrows .inherit:n =
347 {
348 WithArrows / Global ,
349 WithArrows / WithArrowsSpecific ,
350 WithArrows / Env
351 } ,
352 WithArrows / up-and-down .inherit:n = WithArrows / up-and-down ,
353 DispWithArrows .inherit:n =
354 {
355 WithArrows / DispWithArrowsSpecific ,
356 WithArrows / Global ,
357 WithArrows / Env ,
358 } ,
359 DispWithArrows / up-and-down .inherit:n = WithArrows / up-and-down ,
360 WithArrowsOptions .inherit:n =
361 {
362 WithArrows / Global ,
363 WithArrows / WithArrowsSpecific ,
364 WithArrows / DispWithArrowsSpecific ,
365 } ,
366 WithArrowsOptions / up-and-down .inherit:n = WithArrows / up-and-down
367 }
368 \seq_new:N \l__witharrows_options_WithArrows_seq
369 \__witharrows_set_seq_of_str_from_clist:Nn \l__witharrows_options_WithArrows_seq
370 {
371 adjust, b, c, code-after, code-before, command-name,
372 right-overlap, displaystyle, end-adjust,
373 format, group, groups, i,
374 interline, jot, ll,
375 lr, max-length-of-arrow, more-columns, name,
376 no-arrows, rl, rr, up-and-down,
377 show-node-names, show-nodes, start-adjust,
378 t, tikz, tikz-code,
379 xoffset, ygap, ystart
380 }
381 \keys_define:nn { WithArrows / WithArrows }
382 {
383 unknown .code:n =
384 \__witharrows_sort_seq:N \l__witharrows_options_WithArrows_seq
385 \__witharrows_error:n { Unknown~option~WithArrows }
386 }
387 \keys_define:nn { WithArrows / DispWithArrows }
388 {
389 left-brace .tl_set:N = \l__witharrows_left_brace_tl ,
390 unknown .code:n =
391 \__witharrows_sort_seq:N \l__witharrows_options_DispWithArrows_seq
392 \__witharrows_error:n { Unknown~option~DispWithArrows } ,
393 }
394 \seq_new:N \l__witharrows_options_DispWithArrows_seq
395 \__witharrows_set_seq_of_str_from_clist:Nn \l__witharrows_options_DispWithArrows_seq
396 {
397 code-after, code-before, command-name, tikz-code, adjust,
398 displaystyle, end-adjust, fleqn, group, format, groups, i, interline, jot,
399 left-brace, ll, lr, max-length-of-arrow, mathindent, name, no-arrows,
400 up-and-down, replace-left-brace-by, rl, rr, show-node-names,
401 show-nodes, start-adjust, tikz, wrap-lines, xoffset, ygap, ystart,
402 }
403 \keys_define:nn { WithArrows / WithArrowsOptions }
404 {
405 allow-duplicate-names .code:n =
406 \__witharrows_msg_redirect_name:nn { Duplicate~name } { none } ,
407 allow-duplicate-names .value_forbidden:n = true ,
408 xoffset-for-o-arrows .dim_set:N = \l__witharrows_xoffset_for_o_arrows_dim ,
409 xoffset-for-o-arrows .value_required:n = true ,
410 unknown .code:n =
411 \__witharrows_sort_seq:N \l__witharrows_options_WithArrowsOptions_seq
412 \__witharrows_error:n { Unknown~option~WithArrowsOptions }
413 }
414 \seq_new:N \l__witharrows_options_WithArrowsOptions_seq
415 \__witharrows_set_seq_of_str_from_clist:Nn \l__witharrows_options_WithArrowsOptions_seq
416 {
417 allow-duplicate-names, b, c, command-name, right_overlap,
418 more-columns, tikz-code, adjust,
419 displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr,
420 mathindent, max-length-of-arrow, no-arrows, up-and-down, rl, rr,
421 show-node-names, show-nodes, start-adjust, t, tikz, wrap-lines, xoffset,
422 xoffset-for-o-arrows, ygap, ystart,
423 }
424 \cs_new_protected:Npn \__witharrows_set_independent:
425 {
426 \str_if_eq:onF \l_keys_value_tl { NoValue }
427 { \__witharrows_error:n { Value~for~a~key } }
428 \__witharrows_set_independent_bis:
429 }
430 \cs_new_protected:Npn \__witharrows_set_independent_bis:
431 {
432 \str_if_empty:NTF \l__witharrows_previous_key_str
433 {
434 \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_str
435 \str_set:Nn \l__witharrows_status_arrow_str { independent }
436 }
437 { \__witharrows_error:n { Incompatible~options~in~Arrow } }
438 }
439 \keys_define:nn { WithArrows / Arrow / FirstPass }
440 {
441 jump .code:n =
442 \int_compare:nNnTF { #1 } > \c_zero_int
443 { \int_set:Nn \l__witharrows_jump_int { #1 } }
444 { \__witharrows_error:n { Negative~jump } } ,
445 jump .value_required:n = true,
446 rr .code:n = \__witharrows_set_independent: ,
447 ll .code:n = \__witharrows_set_independent: ,
448 rl .code:n = \__witharrows_set_independent: ,
449 lr .code:n = \__witharrows_set_independent: ,
450 i .code:n = \__witharrows_set_independent: ,
451 rr .default:n = NoValue ,
452 ll .default:n = NoValue ,
453 rl .default:n = NoValue ,
454 lr .default:n = NoValue ,
455 i .default:n = NoValue ,
456 new-group .value_forbidden:n = true ,
457 new-group .code:n =
458 \int_compare:nTF { \l__witharrows_pos_arrow_int = 6 }
459 { \str_set:Nn \l__witharrows_status_arrow_str { new-group } }
460 { \__witharrows_error:n { new-group~without~groups } } ,
461 o .code:n =
462 \str_if_empty:NTF \l__witharrows_previous_key_str
463 {
464 \int_compare:nNnTF \l__witharrows_pos_arrow_int < 6
465 { \__witharrows_error:n { invalid~key~o } }
466 {
467 \str_set:Nn \l__witharrows_status_arrow_str { over }
468 \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_str
469 }
470 }
471 { \__witharrows_error:n { Incompatible~options~in~Arrow } } ,
472 tikz-code .code:n = \prg_do_nothing: ,
473 tikz-code .value_required:n = true ,
474 tikz .code:n = \prg_do_nothing: ,
475 tikz .value_required:n = true ,
476 start-adjust .code:n = \prg_do_nothing: ,
477 start-adjust .value_required:n = true ,
478 end-adjust .code:n = \prg_do_nothing: ,
479 end-adjust .value_required:n = true ,
480 adjust .code:n = \prg_do_nothing: ,
481 adjust .value_required:n = true ,
482 xoffset .code:n = ,
483 unknown .code:n =
484 \__witharrows_sort_seq:N \l__witharrows_options_Arrow_seq
485 \seq_if_in:NoTF \l__witharrows_options_WithArrows_seq \l_keys_key_str
486 {
487 \str_set:Nn \l_tmpa_str
488 { ~However,~this~key~can~be~used~in~the~options~of~{WithArrows}. }
489 }
490 { \str_clear:N \l_tmpa_str }
491 \__witharrows_error:n { Unknown~option~in~Arrow }
492 }
493 \seq_new:N \l__witharrows_options_Arrow_seq
494 \__witharrows_set_seq_of_str_from_clist:Nn \l__witharrows_options_Arrow_seq
495 {
496 adjust, end-adjust, i, jump, ll, lr, o , rl, rr, start-adjust, tikz,
497 tikz-code, xoffset
498 }
499 \cs_new_protected:Npn \__witharrows_fix_pos_arrow:n #1
500 {
501 \str_if_empty:NT \l__witharrows_previous_key_str
502 {
503 \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_str
504 \int_set:Nn \l__witharrows_pos_arrow_int { #1 }
505 }
506 }
507 \keys_define:nn {WithArrows / Arrow / SecondPass }
508 {
509 tikz-code .tl_set:N = \l__witharrows_tikz_code_tl ,
510 tikz-code .initial:n = \draw~(#1)~to~node{#3}~(#2)~; ,
511 tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } ,
512 rr .code:n = \__witharrows_fix_pos_arrow:n 3 ,
513 ll .code:n = \__witharrows_fix_pos_arrow:n 1 ,
514 rl .code:n = \__witharrows_fix_pos_arrow:n 2 ,
515 lr .code:n = \__witharrows_fix_pos_arrow:n 0 ,
516 i .code:n = \__witharrows_fix_pos_arrow:n 5 ,
517 o .code:n = \str_set:Nn \l__witharrows_previous_key_str { o } ,
518 xoffset .code:n =
519 \bool_lazy_all:nTF
520 {
521 { \int_compare_p:nNn \g__witharrows_arrow_int > 1 }
522 { \int_compare_p:nNn \l__witharrows_pos_arrow_int > 5 }
523 { ! \str_if_eq_p:on \l__witharrows_status_arrow_str { independent } }
524 }
525 { \__witharrows_error:n { Option~xoffset~forbidden } }
526 { \dim_set:Nn \l__witharrows_xoffset_dim { #1 } } ,
527 xoffset .value_required:n = true ,
528 start-adjust .dim_set:N = \l__witharrows_start_adjust_dim,
529 end-adjust .dim_set:N = \l__witharrows_end_adjust_dim,
530 adjust .code:n =
531 \dim_set:Nn \l__witharrows_start_adjust_dim { #1 }
532 \dim_set:Nn \l__witharrows_end_adjust_dim { #1 } ,
533 }
534 \cs_set_protected:Npn \WithArrowsOptions #1
535 {
536 \str_clear_new:N \l__witharrows_previous_key_str
537 \keys_set:nn { WithArrows / WithArrowsOptions } { #1 }
538 }
539 \cs_new_protected:Npn \__witharrows_Arrow
540 {
541 \peek_meaning:NTF [
542 { \__witharrows_Arrow_i }
543 { \__witharrows_Arrow_i [ ] }
544 }
545 \cs_new_protected:Npn \__witharrows_Arrow_i [ #1 ] #2
546 {
547 \peek_meaning:NTF [
548 { \__witharrows_Arrow_ii [ #1 ] { #2 } }
549 { \__witharrows_Arrow_ii [ #1 ] { #2 } [ ] }
550 }
551 \cs_new_protected:Npn \__witharrows_Arrow_ii [ #1 ] #2 [ #3 ]
552 {
553 \int_gincr:N \g__witharrows_arrow_int
554 \str_clear_new:N \l__witharrows_previous_key_str
555 \keys_set:nn { WithArrows / Arrow / FirstPass } { #1 , #3 }
556 \prop_put:NnV \l_tmpa_prop { initial } \g__witharrows_line_int
557 \int_set:Nn \l_tmpa_int { \g__witharrows_line_int + \l__witharrows_jump_int }
558 \prop_put:NnV \l_tmpa_prop { final } \l_tmpa_int
559 \prop_put:Nno \l_tmpa_prop { status } \l__witharrows_status_arrow_str
560 \prop_put:Nnn \l_tmpa_prop { options } { #1 , #3 }
561 \prop_put:Nnn \l_tmpa_prop { label } { #2 }
562 \prop_put:Nne \l_tmpa_prop { input-line } \msg_line_number:
563 \prop_put:Nnn \l_tmpa_prop { width } { 0 pt }
564 \prop_gclear_new:c
565 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \g__witharrows_arrow_int _ prop }
566 \prop_gset_eq:cN
567 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \g__witharrows_arrow_int _ prop }
568 \l_tmpa_prop
569 }
570 \cs_new_protected:Npn \__witharrows_Arrow_first_columns:
571 { \__witharrows_error:n { Arrow~not~in~last~column } \__witharrows_Arrow }
572 \cs_new_protected:Npn \__witharrows_pre_halign:n #1
573 {
574 \cs_if_exist:NT \tikz@library@external@loaded
575 { \tikzset { external / export = false } }
576 \tikzset { arrows = [ flex ] } % https://texnique.fr/osqa/questions/12199
577 \str_clear_new:N \l__witharrows_name_str
578 \str_clear_new:N \l__witharrows_status_arrow_str
579 \dim_zero_new:N \l__witharrows_x_dim
580 \str_clear_new:N \l__witharrows_input_line_str
581 \seq_gput_right:NV \g__witharrows_arrow_int_seq \g__witharrows_arrow_int
582 \int_gzero:N \g__witharrows_arrow_int
583 \seq_gput_right:NV \g__witharrows_line_int_seq \g__witharrows_line_int
584 \int_gzero:N \g__witharrows_line_int
585 \seq_gput_right:NV \g__witharrows_col_int_seq \g__witharrows_col_int
586 \int_gzero:N \g__witharrows_col_int
587 \seq_gput_right:NV \g__witharrows_static_col_int_seq \g__witharrows_static_col_int
588 \int_gzero:N \g__witharrows_static_col_int
589 \seq_gput_right:Nn \g__witharrows_position_in_the_tree_seq 1
590 \seq_set_eq:NN \l_tmpa_seq \g__witharrows_position_in_the_tree_seq
591 \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl
592 \str_clear_new:N \l__witharrows_prefix_str
593 \str_set:Ne \l__witharrows_prefix_str { \seq_use:Nnnn \l_tmpa_seq - - - }
594 \cs_set_eq:NN \\ \__witharrows_cr:
595 \dim_zero:N \mathsurround
596 \int_zero_new:N \l__witharrows_initial_int
597 \int_zero_new:N \l__witharrows_final_int
598 \int_zero_new:N \l__witharrows_arrow_int
599 \int_zero_new:N \l__witharrows_pos_of_arrow_int
600 \int_zero_new:N \l__witharrows_jump_int
601 \int_set:Nn \l__witharrows_jump_int 1
602 \str_set:Nn \l__witharrows_format_str { rL }
603 \skip_zero:N \l__witharrows_interline_skip
604 \tl_clear_new:N \l__witharrows_code_before_tl
605 \tl_clear_new:N \l__witharrows_code_after_tl
606 \str_clear_new:N \l__witharrows_previous_key_str
607 \bool_if:NT \l__witharrows_in_WithArrows_bool
608 { \keys_set:nn { WithArrows / WithArrows } { #1 } }
609 \bool_if:NT \l__witharrows_in_DispWithArrows_bool
610 { \keys_set:nn { WithArrows / DispWithArrows } { #1 } }
611 \bool_if:NF \l__witharrows_right_overlap_bool
612 {
613 \bool_if:NT \l__witharrows_in_WithArrows_bool
614 {
615 \dim_gzero_new:N \g__witharrows_overlap_x_dim
616 \dim_zero_new:N \l__witharrows_delta_x_dim
617 }
618 }
619 \cs_set_eq:cN \l__witharrows_command_name_str \__witharrows_Arrow_first_columns:
620 \int_set:Nn \l__witharrows_nb_cols_int { \str_count:N \l__witharrows_format_str }
621 \int_gset_eq:NN \g__witharrows_col_int \l__witharrows_nb_cols_int
622 \seq_clear_new:N \l__witharrows_format_seq
623 \seq_set_split:NnV \l__witharrows_format_seq { } \l__witharrows_format_str
624 \l__witharrows_code_before_tl
625 }
626 \cs_new_protected:Npn \__witharrows_construct_halign:
627 {
628 \seq_pop_right:NNTF \l__witharrows_format_seq \l__witharrows_type_col_str
629 {
630 \use:e
631 {
632 \int_gdecr:N \g__witharrows_col_int
633 \__witharrows_construct_halign:
634 \int_compare:nNnT \g__witharrows_col_int = \l__witharrows_nb_cols_int
635 {
636 \cs_set_eq:cN { \l__witharrows_command_name_str } \__witharrows_Arrow
637 }
638 \str_if_eq:onT \l__witharrows_type_col_str { c } \hfil
639 \str_if_eq:onT \l__witharrows_type_col_str { C } \hfil
640 \str_if_eq:onT \l__witharrows_type_col_str { r } \hfill
641 \str_if_eq:onT \l__witharrows_type_col_str { R } \hfill
642 \int_gincr:N \g__witharrows_col_int
643 \int_gset:Nn \g__witharrows_static_col_int { \int_use:N \g__witharrows_col_int }
644 \c_math_toggle_token
645 \str_if_eq:onT \l__witharrows_type_col_str { C } { { } }
646 \str_if_eq:onT \l__witharrows_type_col_str { L } { { } }
647 \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle
648 ##
649 \str_if_eq:onT \l__witharrows_type_col_str { C } { { } }
650 \str_if_eq:onT \l__witharrows_type_col_str { R } { { } }
651 \c_math_toggle_token
652 \int_compare:nNnTF \g__witharrows_col_int = \l__witharrows_nb_cols_int
653 \__witharrows_construct_nodes:
654 {
655 \str_if_eq:onT \l__witharrows_type_col_str { l } \hfil
656 \str_if_eq:onT \l__witharrows_type_col_str { L } \hfil
657 \str_if_eq:onT \l__witharrows_type_col_str { c } \hfil
658 \str_if_eq:onT \l__witharrows_type_col_str { C } \hfil
659 \bool_if:NT \l__witharrows_in_DispWithArrows_bool { \tabskip = \c_zero_skip }
660 &
661 }
662 }
663 }
664 {
665 \bool_if:NTF \l__witharrows_in_WithArrows_bool
666 {
667 \ialign
668 \bgroup
669 }
670 {
671 \halign to \l__witharrows_linewidth_dim
672 \bgroup
673 \bool_if:NT \l__witharrows_fleqn_bool
674 { \skip_horizontal:N \l__witharrows_mathindent_skip }
675 }
676 \int_gincr:N \g__witharrows_line_int
677 \int_gzero:N \g__witharrows_col_int
678 \tl_if_eq:NNF \l__witharrows_left_brace_tl \c_novalue_tl
679 {
680 \skip_horizontal:n
681 { \box_wd:N \l__witharrows_left_brace_box + \l__witharrows_delim_wd_dim }
682 }
683 \strut
684 }
685 }
686 \cs_new_protected:Npn \__witharrows_construct_nodes:
687 {
688 \tikz [ remember~picture , overlay ]
689 \node
690 [
691 node~contents = { } ,
692 __witharrows_node_style ,
693 name = wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - l ,
694 ]
695 ;
696 \hfil
697 \tikz [ remember~picture , overlay ]
698 \node
699 [
700 node~contents = { } ,
701 __witharrows_node_style ,
702 name = wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - r ,
703 ]
704 ;
705 \str_if_empty:NF \l__witharrows_name_str
706 {
707 \pgfpicture
708 \pgfnodealias
709 { \l__witharrows_name_str - \int_use:N \g__witharrows_line_int - l }
710 { wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - l }
711 \pgfnodealias
712 { \l__witharrows_name_str - \int_use:N \g__witharrows_line_int - r }
713 { wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - r }
714 \endpgfpicture
715 }
716 \bool_if:NT \l__witharrows_show_node_names_bool
717 {
718 \hbox_overlap_right:n
719 { \small wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - r }
720 }
721 }
722 \cs_new_protected:Npn \WithArrows
723 {
724 \group_begin:
725 \peek_meaning:NTF [
726 { \WithArrows_i }
727 { \WithArrows_i [ ] }
728 }
729 \cs_new_protected:Npn \WithArrows_i [ #1 ]
730 {
731 \bool_set_true:N \l__witharrows_in_WithArrows_bool
732 \bool_set_false:N \l__witharrows_in_DispWithArrows_bool
733 \str_clear_new:N \l__witharrows_type_env_str
734 \str_set:Nn \l__witharrows_type_env_str { WithArrows }
735 \__witharrows_pre_halign:n { #1 }
736 \if_mode_math: \else:
737 \__witharrows_error:n { WithArrows~outside~math~mode }
738 \fi:
739 \box_clear_new:N \l__witharrows_env_box
740 \hbox_set:Nw \l__witharrows_env_box
741 \int_compare:nNnT \l__witharrows_pos_env_int = 1 \c_math_toggle_token
742 \int_case:nn \l__witharrows_pos_env_int { 0 \vtop 1 \vcenter 2 \vbox }
743 \bgroup
744 \spread@equation
745 \__witharrows_construct_halign:
746 &&
747 \__witharrows_error:n { Too~much~columns~in~WithArrows }
748 \c_math_toggle_token
749 \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle
750 { ## }
751 \c_math_toggle_token
752 \cr
753 }
754 \cs_new_protected:Npn \endWithArrows
755 {
756 \\
757 \egroup
758 \egroup
759 \int_compare:nNnT \l__witharrows_pos_env_int = 1 \c_math_toggle_token
760 \hbox_set_end:
761 \__witharrows_post_halign:
762 \bool_if:NF \l__witharrows_right_overlap_bool
763 {
764 \box_set_wd:Nn \l__witharrows_env_box
765 { \g__witharrows_overlap_x_dim + \box_wd:N \l__witharrows_env_box }
766 }
767 \box_use_drop:N \l__witharrows_env_box
768 \group_end:
769 }
770 \cs_new_protected:Npn \__witharrows_post_halign:
771 {
772 \cs_set:Npn \WithArrowsRightX { \g__witharrows_right_x_dim }
773 \normalbaselines
774 \int_if_zero:nF \g__witharrows_arrow_int
775 {
776 \int_compare:nNnT \g__witharrows_arrow_int = 1
777 {
778 \int_compare:nNnT \l__witharrows_pos_arrow_int > 5
779 { \int_set:Nn \l__witharrows_pos_arrow_int 5 }
780 }
781 \__witharrows_scan_arrows:
782 }
783 \group_begin:
784 \tikzset { every~picture / .style = __witharrows_standard }
785 \cs_set:Npn \WithArrowsNbLines { \int_use:N \g__witharrows_line_int }
786 \cs_set_eq:NN \MultiArrow \__witharrows_MultiArrow:nn
787 \cs_set_eq:cN \l__witharrows_command_name_str \__witharrows_Arrow_code_after
788 \bool_set_true:N \l__witharrows_in_code_after_bool
789 \l__witharrows_code_after_tl
790 \group_end:
791 \seq_gpop_right:NN \g__witharrows_position_in_the_tree_seq \l_tmpa_tl
792 \seq_gpop_right:NN \g__witharrows_position_in_the_tree_seq \l_tmpa_tl
793 \seq_gput_right:Ne \g__witharrows_position_in_the_tree_seq
794 { \int_eval:n { \l_tmpa_tl + 1 } }
795 \int_compare:nNnT { \seq_count:N \g__witharrows_position_in_the_tree_seq } = 1
796 { \int_gincr:N \g__witharrows_last_env_int }
797 \seq_gpop_right:NN \g__witharrows_arrow_int_seq \l_tmpa_tl
798 \int_gset:Nn \g__witharrows_arrow_int \l_tmpa_tl
799 \seq_gpop_right:NN \g__witharrows_line_int_seq \l_tmpa_tl
800 \int_gset:Nn \g__witharrows_line_int \l_tmpa_tl
801 \seq_gpop_right:NN \g__witharrows_col_int_seq \l_tmpa_tl
802 \int_gset:Nn \g__witharrows_col_int \l_tmpa_tl
803 \seq_gpop_right:NN \g__witharrows_static_col_int_seq \l_tmpa_tl
804 \int_gset:Nn \g__witharrows_static_col_int \l_tmpa_tl
805 }
806 \cs_new_protected:Npn \__witharrows_cr:
807 {
808 \scan_stop:
809 \int_compare:nNnF \g__witharrows_col_int = \g__witharrows_static_col_int
810 { \__witharrows_error:n { omit~probably~used } }
811 \prg_replicate:nn { \l__witharrows_nb_cols_int - \g__witharrows_static_col_int } { & { } }
812 \group_align_safe_begin:
813 \peek_meaning_remove:NTF * \__witharrows_cr_i: \__witharrows_cr_i:
814 }
815 \cs_new_protected:Npn \__witharrows_cr_i:
816 { \peek_meaning:NTF [ \__witharrows_cr_ii: { \__witharrows_cr_ii: [ \c_zero_dim ] } }
817 \cs_new_protected:Npn \__witharrows_cr_ii: [ #1 ]
818 {
819 \group_align_safe_end:
820 \bool_if:NT \l__witharrows_in_DispWithArrows_bool
821 {
822 &
823 \pgfpicture
824 \pgfrememberpicturepositiononpagetrue
825 \pgfcoordinate
826 { wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - v }
827 \pgfpointorigin
828 \endpgfpicture
829 }
830 \dim_compare:nNnT { #1 } < \c_zero_dim
831 { \__witharrows_error:n { option~of~cr~negative } }
832
833 \cr
834 \noalign
835 {
836 \dim_set:Nn \l_tmpa_dim { \dim_max:nn { #1 } \c_zero_dim }
837 \skip_vertical:N \l_tmpa_dim
838 \skip_vertical:N \l__witharrows_interline_skip
839 \scan_stop:
840 }
841 }
842 \cs_new_protected:Npn \DispWithArrows
843 {
844 \group_begin:
845 \peek_meaning:NTF <
846 { \DispWithArrows_i }
847 { \DispWithArrows_i < \c_novalue_tl > }
848 }
849 \cs_new_protected:Npn \DispWithArrows_i < #1 >
850 {
851 \peek_meaning:NTF [
852 { \DispWithArrows_ii < #1 > }
853 { \DispWithArrows_ii < #1 > [ ] }
854 }
855 \cs_new_protected:Npn \DispWithArrows_ii < #1 > [ #2 ]
856 {
857 \bool_set_true:N \l__witharrows_in_DispWithArrows_bool
858 \str_clear_new:N \l__witharrows_type_env_str
859 \str_set:Nn \l__witharrows_type_env_str { DispWithArrows }
860 \tl_if_novalue:oF { #1 }
861 { \cs_set_nopar:Npn \l__witharrows_left_brace_tl { #1 } }
862 \__witharrows_pre_halign:n { #2 }
863 \tl_if_eq:NNF \l__witharrows_left_brace_tl \c_novalue_tl
864 {
865 \hbox_set:Nn \l_tmpa_box
866 {
867 \group_begin:
868 \dim_zero:N \nulldelimiterspace
869 \c_math_toggle_token
870 \left \l__witharrows_replace_left_brace_by_tl \vcenter to 1 cm { } \right.
871 \c_math_toggle_token
872 \group_end:
873 }
874 \dim_zero_new:N \l__witharrows_delim_wd_dim
875 \dim_set:Nn \l__witharrows_delim_wd_dim { \box_wd:N \l_tmpa_box }
876 \box_clear_new:N \l__witharrows_left_brace_box
877 \hbox_set:Nn \l__witharrows_left_brace_box
878 {
879 \group_begin:
880 \cs_set_eq:NN \label \__witharrows_old_label
881 \c_math_toggle_token
882 \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle
883 \l__witharrows_left_brace_tl
884 { }
885 \c_math_toggle_token
886 \group_end:
887 }
888 }
889 \if_mode_math:
890 \__witharrows_fatal:n { DispWithArrows~in~math~mode }
891 \fi:
892 \dim_zero_new:N \linewidth
893 \dim_set_eq:NN \linewidth \displaywidth
894 \if_mode_vertical:
895 \nointerlineskip
896 \hbox_to_wd:nn { .6 \linewidth } { }
897 \fi:
898 \c_math_toggle_token \c_math_toggle_token
899 \dim_zero_new:N \l__witharrows_linewidth_dim
900 \dim_set_eq:NN \l__witharrows_linewidth_dim \displaywidth
901 \box_clear_new:N \l__witharrows_halign_box
902 \setbox \l__witharrows_halign_box \vtop \bgroup
903 \tabskip =
904 \bool_if:NTF \l__witharrows_fleqn_bool
905 \c_zero_skip
906 { 0 pt plus 1000 pt minus 1000 pt }
907 \spread@equation
908 \__witharrows_construct_halign:
909 \tabskip = 0 pt plus 1000 pt minus 1000 pt
910 &
911 $ ## $
912 \tabskip = \c_zero_skip
913 &&
914 \__witharrows_fatal:n { Too~much~columns~in~DispWithArrows }
915 \bool_if:nT \c_false_bool { ## }
916 \cr
917 }
918 \cs_new_protected:Npn \endDispWithArrows
919 {
920 \\
921 \egroup
922 \unskip \unpenalty \unskip \unpenalty
923 \box_set_to_last:N \l_tmpa_box
924 \nointerlineskip
925 \box_use:N \l_tmpa_box
926 \dim_gzero_new:N \g__witharrows_alignment_dim
927 \dim_gset:Nn \g__witharrows_alignment_dim { \box_wd:N \l_tmpa_box }
928 \box_clear_new:N \l__witharrows_new_box
929 \hbox_set:Nn \l__witharrows_new_box { \hbox_unpack_drop:N \l_tmpa_box }
930 \dim_compare:nNnT
931 { \box_wd:N \l__witharrows_new_box } < \g__witharrows_alignment_dim
932 { \dim_gset:Nn \g__witharrows_alignment_dim { \box_wd:N \l__witharrows_new_box } }
933 \egroup
934 \tl_if_eq:NNTF \l__witharrows_left_brace_tl \c_novalue_tl
935 { \box_use_drop:N \l__witharrows_halign_box }
936 {
937 \hbox_to_wd:nn \l__witharrows_linewidth_dim
938 {
939 \bool_if:NTF \l__witharrows_fleqn_bool
940 { \skip_horizontal:N \l__witharrows_mathindent_skip }
941 \hfil
942 \hbox_to_wd:nn \g__witharrows_alignment_dim
943 {
944 \box_use_drop:N \l__witharrows_left_brace_box
945 \dim_set:Nn \l_tmpa_dim
946 {
947 \box_ht:N \l__witharrows_halign_box
948 + \box_dp:N \l__witharrows_halign_box
949 }
950 \group_begin:
951 \dim_zero:N \nulldelimiterspace
952 \c_math_toggle_token
953 \left \l__witharrows_replace_left_brace_by_tl
954 \vcenter to \l_tmpa_dim { \vfil }
955 \right.
956 \c_math_toggle_token
957 \group_end:
958 \hfil
959 }
960 \hfil
961 }
962 \skip_horizontal:N -\l__witharrows_linewidth_dim
963 \vcenter { \box_use_drop:N \l__witharrows_halign_box }
964 }
965 \dim_gzero_new:N \g__witharrows_right_x_dim
966 \dim_gset_eq:NN \g__witharrows_right_x_dim \c_max_dim
967 \pgfpicture
968 \pgfrememberpicturepositiononpagetrue
969 \int_step_variable:nNn \g__witharrows_line_int \l_tmpa_int
970 {
971 \cs_if_free:cTF
972 { pgf @ sh @ ns @ wa - \l__witharrows_prefix_str - \l_tmpa_int - v }
973 { \__witharrows_fatal:n { Inexistent~v-node } }
974 {
975 \pgfpointanchor
976 { wa - \l__witharrows_prefix_str - \l_tmpa_int - v }
977 { center }
978 \dim_compare:nNnT \pgf@x < \g__witharrows_right_x_dim
979 { \dim_gset_eq:NN \g__witharrows_right_x_dim \pgf@x }
980 }
981 }
982 \endpgfpicture
983 \__witharrows_post_halign:
984 \c_math_toggle_token \c_math_toggle_token
985 \group_end:
986 }
987 \cs_new_protected:Npn \__witharrows_if_in_last_col_of_disp:Nn #1 #2
988 {
989 \bool_if:NTF \l__witharrows_in_WithArrows_bool
990 { \__witharrows_error:nn { Not~allowed~in~WithArrows } { #1 } }
991 {
992 \int_compare:nNnTF \g__witharrows_col_int < \l__witharrows_nb_cols_int
993 { \__witharrows_error:nn { Not~allowed~in~DispWithArrows } { #1 } }
994 { #2 }
995 }
996 }
997 \cs_new_protected:Npn \__witharrows_scan_arrows:
998 {
999 \group_begin:
1000 \int_compare:nNnT \l__witharrows_pos_arrow_int = 7
1001 {
1002 \__witharrows_scan_arrows_i:
1003 \int_set:Nn \l__witharrows_pos_arrow_int 8
1004 }
1005 \__witharrows_scan_arrows_i:
1006 \group_end:
1007 }
1008 \cs_new_protected:Npn \__witharrows_scan_arrows_i:
1009 {
1010 \int_zero_new:N \l__witharrows_first_arrow_of_group_int
1011 \int_zero_new:N \l__witharrows_first_line_of_group_int
1012 \int_zero_new:N \l__witharrows_last_line_of_group_int
1013 \seq_clear_new:N \l__witharrows_first_arrows_seq
1014 \seq_clear_new:N \l__witharrows_last_arrows_seq
1015 \bool_set_true:N \l__witharrows_new_group_bool
1016 \int_set:Nn \l__witharrows_arrow_int 1
1017 \int_until_do:nNnn \l__witharrows_arrow_int > \g__witharrows_arrow_int
1018 {
1019 \prop_get:cnN
1020 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1021 { initial } \l_tmpa_tl
1022 \int_set:Nn \l__witharrows_initial_int \l_tmpa_tl
1023 \prop_get:cnN
1024 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1025 { final } \l_tmpa_tl
1026 \int_set:Nn \l__witharrows_final_int \l_tmpa_tl
1027 \prop_get:cnN
1028 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1029 { status } \l__witharrows_status_arrow_str
1030 \prop_get:cnN
1031 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1032 { input-line } \l__witharrows_input_line_str
1033 \int_compare:nNnTF \l__witharrows_final_int > \g__witharrows_line_int
1034 {
1035 \int_compare:nNnF \l__witharrows_pos_arrow_int = 8
1036 { \__witharrows_error:n { Too~few~lines~for~an~arrow } }
1037 }
1038 \__witharrows_treat_an_arrow_in_scan:
1039 \int_incr:N \l__witharrows_arrow_int
1040 }
1041 \bool_lazy_and:nnT
1042 { ! \int_compare_p:nNn \l__witharrows_pos_arrow_int = 7 }
1043 { \int_compare_p:nNn \l__witharrows_first_arrow_of_group_int > \c_zero_int }
1044 { \__witharrows_draw_arrows:nn \l__witharrows_first_arrow_of_group_int \g__witharrows_arrow_int }
1045 }
1046 \cs_new_protected:Npn \__witharrows_treat_an_arrow_in_scan:
1047 {
1048 \bool_lazy_and:nnT
1049 { \int_compare_p:nNn \l__witharrows_arrow_int > 1 }
1050 {
1051 \bool_lazy_or_p:nn
1052 {
1053 \bool_lazy_and_p:nn
1054 {
1055 \int_compare_p:nNn
1056 \l__witharrows_initial_int > \l__witharrows_last_line_of_group_int
1057 }
1058 { \bool_not_p:n { \int_compare_p:nNn \l__witharrows_pos_arrow_int = 7 } }
1059 }
1060 { \str_if_eq_p:on \l__witharrows_status_arrow_str { new-group } }
1061 }
1062 {
1063 \int_if_zero:nF \l__witharrows_first_arrow_of_group_int
1064 {
1065 \__witharrows_draw_arrows:nn
1066 \l__witharrows_first_arrow_of_group_int
1067 { \l__witharrows_arrow_int - 1 }
1068 }
1069 \bool_set_true:N \l__witharrows_new_group_bool
1070 }
1071 \bool_if:nTF \l__witharrows_new_group_bool
1072 {
1073 \bool_set_false:N \l__witharrows_new_group_bool
1074 \int_set_eq:NN \l__witharrows_first_arrow_of_group_int \l__witharrows_arrow_int
1075 \int_set_eq:NN \l__witharrows_first_line_of_group_int \l__witharrows_initial_int
1076 \int_set_eq:NN \l__witharrows_last_line_of_group_int \l__witharrows_final_int
1077 \seq_clear:N \l__witharrows_first_arrows_seq
1078 \seq_put_left:NV \l__witharrows_first_arrows_seq \l__witharrows_arrow_int
1079 \seq_clear:N \l__witharrows_last_arrows_seq
1080 \seq_put_left:NV \l__witharrows_last_arrows_seq \l__witharrows_arrow_int
1081 \int_compare:nNnF \l__witharrows_pos_arrow_int = 8
1082 { \dim_set:Nn \l__witharrows_x_dim { - \c_max_dim } }
1083 }
1084 {
1085 \str_if_eq:onF \l__witharrows_status_arrow_str { independent }
1086 {
1087 \int_compare:nNnT \l__witharrows_initial_int = \l__witharrows_first_line_of_group_int
1088 { \seq_put_left:NV \l__witharrows_first_arrows_seq \l__witharrows_arrow_int }
1089 \int_compare:nNnTF \l__witharrows_final_int > \l__witharrows_last_line_of_group_int
1090 {
1091 \int_set_eq:NN \l__witharrows_last_line_of_group_int \l__witharrows_final_int
1092 \seq_clear:N \l__witharrows_last_arrows_seq
1093 \seq_put_left:NV \l__witharrows_last_arrows_seq \l__witharrows_arrow_int
1094 }
1095 {
1096 \int_compare:nNnT \l__witharrows_final_int = \l__witharrows_last_line_of_group_int
1097 { \seq_put_left:NV \l__witharrows_last_arrows_seq \l__witharrows_arrow_int }
1098 }
1099 }
1100 }
1101 \str_if_eq:onF \l__witharrows_status_arrow_str { independent }
1102 {
1103 \int_compare:nNnF \l__witharrows_pos_arrow_int = 8
1104 { \__witharrows_update_x:nn \l__witharrows_initial_int \l__witharrows_final_int }
1105 }
1106 }
1107 \cs_new_protected:Npn \__witharrows_draw_arrows:nn #1 #2
1108 {
1109 \group_begin:
1110 \int_zero_new:N \l__witharrows_first_arrow_int
1111 \int_set:Nn \l__witharrows_first_arrow_int { #1 }
1112 \int_zero_new:N \l__witharrows_last_arrow_int
1113 \int_set:Nn \l__witharrows_last_arrow_int { #2 }
1114 \int_set:Nn \l__witharrows_arrow_int \l__witharrows_first_arrow_int
1115 \int_until_do:nNnn \l__witharrows_arrow_int > \l__witharrows_last_arrow_int
1116 {
1117 \prop_get:cnN
1118 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1119 { initial } \l_tmpa_tl
1120 \int_set:Nn \l__witharrows_initial_int \l_tmpa_tl
1121 \prop_get:cnN
1122 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1123 { final } \l_tmpa_tl
1124 \int_set:Nn \l__witharrows_final_int \l_tmpa_tl
1125 \prop_get:cnN
1126 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1127 { status } \l__witharrows_status_arrow_str
1128 \int_compare:nNnF \l__witharrows_final_int > \g__witharrows_line_int
1129 {
1130 \str_if_eq:onTF \l__witharrows_status_arrow_str { over }
1131 { \seq_put_right:NV \l__witharrows_o_arrows_seq \l__witharrows_arrow_int }
1132 \__witharrows_draw_arrow:
1133 }
1134 \int_incr:N \l__witharrows_arrow_int
1135 }
1136 \__witharrows_draw_o_arrows_of_the_group:
1137 \group_end:
1138 }
1139 \cs_new_protected:Npn \__witharrows_draw_arrow:
1140 {
1141 \group_begin:
1142 \prop_get:cnN
1143 { g__witharrows_arrow _\l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1144 { options }
1145 \l_tmpa_tl
1146 \str_clear_new:N \l__witharrows_previous_key_str
1147 \exp_args:NNNno \exp_args:NNno \exp_args:Nno
1148 \keys_set_known:nn
1149 { WithArrows / Arrow / SecondPass }
1150 { \l_tmpa_tl , tikz = { xshift = \l__witharrows_xoffset_dim } }
1151 \bool_set_false:N \l__witharrows_initial_r_bool
1152 \bool_set_false:N \l__witharrows_final_r_bool
1153 \int_case:nn \l__witharrows_pos_arrow_int
1154 {
1155 0 { \bool_set_true:N \l__witharrows_final_r_bool }
1156 2 { \bool_set_true:N \l__witharrows_initial_r_bool }
1157 3
1158 {
1159 \bool_set_true:N \l__witharrows_initial_r_bool
1160 \bool_set_true:N \l__witharrows_final_r_bool
1161 }
1162 }
1163 \int_compare:nNnT \l__witharrows_pos_arrow_int = 5
1164 {
1165 \dim_set:Nn \l__witharrows_x_dim { - \c_max_dim }
1166 \__witharrows_update_x:nn \l__witharrows_initial_int \l__witharrows_final_int
1167 }
1168 \tl_set:Ne \l__witharrows_initial_tl
1169 { \int_use:N \l__witharrows_initial_int - \bool_if:NTF \l__witharrows_initial_r_bool rl }
1170 \tl_set:Ne \l__witharrows_final_tl
1171 { \int_use:N \l__witharrows_final_int - \bool_if:NTF \l__witharrows_final_r_bool rl }
1172 \prop_get:cnN
1173 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1174 { label }
1175 \l_tmpa_tl
1176 \seq_if_in:NeTF \l__witharrows_first_arrows_seq
1177 { \int_use:N \l__witharrows_arrow_int }
1178 { \bool_set_true:N \l_tmpa_bool }
1179 { \bool_set_false:N \l_tmpa_bool }
1180 \seq_if_in:NeTF \l__witharrows_last_arrows_seq
1181 { \int_use:N \l__witharrows_arrow_int }
1182 { \bool_set_true:N \l_tmpb_bool }
1183 { \bool_set_false:N \l_tmpb_bool }
1184 \int_compare:nNnT \l__witharrows_pos_arrow_int = 5
1185 {
1186 \bool_set_true:N \l_tmpa_bool
1187 \bool_set_true:N \l_tmpb_bool
1188 }
1189 \dim_gzero_new:N \g__witharrows_x_initial_dim
1190 \dim_gzero_new:N \g__witharrows_x_final_dim
1191 \dim_gzero_new:N \g__witharrows_y_initial_dim
1192 \dim_gzero_new:N \g__witharrows_y_final_dim
1193 \pgfpicture
1194 \pgfrememberpicturepositiononpagetrue
1195 \pgfpointanchor { wa - \l__witharrows_prefix_str - \l__witharrows_initial_tl } { south }
1196 \dim_gset:Nn \g__witharrows_x_initial_dim \pgf@x
1197 \dim_gset:Nn \g__witharrows_y_initial_dim \pgf@y
1198 \pgfpointanchor { wa - \l__witharrows_prefix_str - \l__witharrows_final_tl } { north }
1199 \dim_gset:Nn \g__witharrows_x_final_dim \pgf@x
1200 \dim_gset:Nn \g__witharrows_y_final_dim \pgf@y
1201 \endpgfpicture
1202 \bool_lazy_and:nnTF
1203 {
1204 \dim_compare_p:nNn { \g__witharrows_y_initial_dim - \g__witharrows_y_final_dim }
1205 > \l__witharrows_max_length_of_arrow_dim
1206 }
1207 { \int_compare_p:nNn { \l__witharrows_final_int - \l__witharrows_initial_int } = 1 }
1208 {
1209 \tl_gset:Ne \g_tmpa_tl
1210 {
1211 \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5
1212 { \dim_use:N \g__witharrows_x_initial_dim }
1213 { \dim_use:N \l__witharrows_x_dim } ,
1214 \dim_eval:n
1215 {
1216 ( \g__witharrows_y_initial_dim + \g__witharrows_y_final_dim ) / 2
1217 + 0.5 \l__witharrows_max_length_of_arrow_dim
1218 }
1219 }
1220 \tl_gset:Ne \g_tmpb_tl
1221 {
1222 \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5
1223 { \dim_use:N \g__witharrows_x_final_dim }
1224 { \dim_use:N \l__witharrows_x_dim } ,
1225 \dim_eval:n
1226 {
1227 ( \g__witharrows_y_initial_dim + \g__witharrows_y_final_dim ) / 2
1228 - 0.5 \l__witharrows_max_length_of_arrow_dim
1229 }
1230 }
1231 }
1232 {
1233 \tl_gset:Ne \g_tmpa_tl
1234 {
1235 \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5
1236 { \dim_use:N \g__witharrows_x_initial_dim }
1237 { \dim_use:N \l__witharrows_x_dim } ,
1238 \bool_if:NTF \l_tmpa_bool
1239 { \dim_eval:n { \g__witharrows_y_initial_dim + \l__witharrows_start_adjust_dim } }
1240 { \dim_use:N \g__witharrows_y_initial_dim }
1241 }
1242 \tl_gset:Ne \g_tmpb_tl
1243 {
1244 \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5
1245 { \dim_use:N \g__witharrows_x_final_dim }
1246 { \dim_use:N \l__witharrows_x_dim } ,
1247 \bool_if:NTF \l_tmpb_bool
1248 { \dim_eval:n { \g__witharrows_y_final_dim - \l__witharrows_end_adjust_dim } }
1249 { \dim_use:N \g__witharrows_y_final_dim }
1250 }
1251 }
1252 \bool_if:NF \l__witharrows_right_overlap_bool
1253 {
1254 \bool_if:NT \l__witharrows_in_WithArrows_bool
1255 {
1256 \pgfpicture
1257 \pgfrememberpicturepositiononpagetrue
1258 \pgfpointanchor { wa - \l__witharrows_prefix_str - 1 - r } { south }
1259 \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5
1260 {
1261 \dim_set:Nn \l__witharrows_delta_x_dim
1262 {
1263 \pgf@x -
1264 ( \dim_min:nn \g__witharrows_x_initial_dim \g__witharrows_x_final_dim )
1265 }
1266 }
1267 { \dim_set:Nn \l__witharrows_delta_x_dim { \pgf@x - \l__witharrows_x_dim } }
1268 \endpgfpicture
1269 }
1270 }
1271 \__witharrows_draw_arrow:nno \g_tmpa_tl \g_tmpb_tl \l_tmpa_tl
1272 \group_end:
1273 }
1274 \cs_generate_variant:Nn \__witharrows_def_function_arrow:n { o }
1275 \cs_new_protected:Npn \__witharrows_def_function_arrow:n #1
1276 {
1277 \cs_set:Npn \__witharrows_arrow:nnn ##1 ##2 ##3
1278 {
1279 \tikzpicture
1280 [ __witharrows_standard_arrow ]
1281 \pgf@relevantforpicturesizetrue
1282 #1
1283 \dim_compare:nNnTF \pgf@picminx = { 16000 pt }
1284 { \dim_zero:N \l_tmpa_dim }
1285 { \dim_set:Nn \l_tmpa_dim { \pgf@picmaxx - \pgf@picminx } }
1286 \dim_add:Nn \l_tmpa_dim \l__witharrows_xoffset_dim
1287 \int_compare:nNnT \l__witharrows_arrow_int > 0 % added 2024/10/01
1288 {
1289 \prop_gput:cnV
1290 { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop }
1291 { width }
1292 \l_tmpa_dim
1293 }
1294 \bool_if:NF \l__witharrows_right_overlap_bool
1295 {
1296 \bool_if:NT \l__witharrows_in_WithArrows_bool
1297 {
1298 \dim_gset:Nn \g__witharrows_overlap_x_dim
1299 {
1300 \dim_max:nn
1301 \g__witharrows_overlap_x_dim
1302 { \l_tmpa_dim - \l__witharrows_delta_x_dim }
1303 }
1304 }
1305 }
1306 \pgfresetboundingbox
1307 \endtikzpicture
1308 }
1309 }
1310 \cs_generate_variant:Nn \__witharrows_draw_arrow:nnn { n n o }
1311 \cs_new_protected:Npn \__witharrows_draw_arrow:nnn #1 #2 #3
1312 {
1313 \bool_lazy_and:nnT \l__witharrows_wrap_lines_bool \l__witharrows_in_DispWithArrows_bool
1314 { \tl_set_eq:NN \l__witharrows_tikz_code_tl \c__witharrows_tikz_code_wrap_lines_tl }
1315 \__witharrows_def_function_arrow:o \l__witharrows_tikz_code_tl
1316 \__witharrows_arrow:nnn { #1 } { #2 } { #3 }
1317 }
1318 \tl_const:Nn \c__witharrows_tikz_code_wrap_lines_tl
1319 {
1320 \pgfset { inner~sep = 0pt }
1321 \draw ( #1 ) to node ( __witharrows_label ) { } ( #2 ) ;
1322 \pgfpointanchor { wa - \l__witharrows_prefix_str - __witharrows_label } { west }
1323 \dim_set:Nn \l_tmpa_dim { \g__witharrows_right_x_dim - \pgf@x - 0.33333 em }
1324 \path \pgfextra { \tl_gset:Ne \g_tmpa_tl \tikz@text@width } ;
1325 \tl_if_empty:NF \g_tmpa_tl
1326 {
1327 \dim_set:Nn \l_tmpb_dim \g_tmpa_tl
1328 \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim
1329 { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim }
1330 }
1331 \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
1332 {
1333 \path ( __witharrows_label.west )
1334 node [ anchor = west , text~width = \dim_use:N \l_tmpa_dim ]
1335 { \skip_horizontal:n { 0.33333 em } #3 } ;
1336 }
1337 }
1338 \cs_new_protected:Npn \__witharrows_update_x:nn #1 #2
1339 {
1340 \dim_gset_eq:NN \g_tmpa_dim \l__witharrows_x_dim
1341 \pgfpicture
1342 \pgfrememberpicturepositiononpagetrue
1343 \int_step_inline:nnn { #1 } { #2 }
1344 {
1345 \pgfpointanchor { wa - \l__witharrows_prefix_str - ##1 - l } { center }
1346 \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \g_tmpa_dim \pgf@x }
1347 }
1348 \endpgfpicture
1349 \dim_set_eq:NN \l__witharrows_x_dim \g_tmpa_dim
1350 }
1351 \cs_new_protected:Npn \__witharrows_draw_o_arrows_of_the_group:
1352 {
1353 \seq_sort:Nn \l__witharrows_o_arrows_seq
1354 {
1355 \prop_get:cnN
1356 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##1 _ prop }
1357 { final } \l_tmpa_tl
1358 \prop_get:cnN
1359 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##2 _ prop }
1360 { final } \l_tmpb_tl
1361 \int_compare:nNnTF \l_tmpa_tl < \l_tmpb_tl
1362 \sort_return_same:
1363 {
1364 \int_compare:nNnTF \l_tmpa_tl > \l_tmpb_tl
1365 \sort_return_swapped:
1366 {
1367 \prop_get:cnN
1368 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##1 _ prop }
1369 { initial } \l_tmpa_tl
1370 \prop_get:cnN
1371 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##2 _ prop }
1372 { initial } \l_tmpb_tl
1373 \int_compare:nNnTF \l_tmpa_tl < \l_tmpb_tl
1374 \sort_return_swapped:
1375 \sort_return_same:
1376 }
1377 }
1378 }
1379 \seq_map_inline:Nn \l__witharrows_o_arrows_seq
1380 {
1381 \prop_get:cnN
1382 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##1 _ prop }
1383 { initial } \l_tmpa_tl
1384 \int_set:Nn \l__witharrows_initial_int \l_tmpa_tl
1385 \prop_get:cnN
1386 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##1 _ prop }
1387 { final } \l_tmpa_tl
1388 \int_set:Nn \l__witharrows_final_int \l_tmpa_tl
1389 \prop_get:cnN
1390 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ##1 _ prop }
1391 { input-line } \l__witharrows_input_line_str
1392 \dim_gzero:N \g_tmpa_dim
1393 \bool_set_false:N \g_tmpa_bool
1394 \pgfpicture
1395 \pgfrememberpicturepositiononpagetrue
1396 \int_step_inline:nnn \l__witharrows_first_arrow_int \l__witharrows_last_arrow_int
1397 {
1398 \prop_get:cnN
1399 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ####1 _ prop }
1400 { initial } \l_tmpa_tl
1401 \prop_get:cnN
1402 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ####1 _ prop }
1403 { final } \l_tmpb_tl
1404 \prop_get:cnN
1405 { g__witharrows_arrow _ \l__witharrows_prefix_str _ ####1 _ prop }
1406 { status } \l__witharrows_status_arrow_str
1407 \bool_lazy_any:nF
1408 {
1409 { \int_compare_p:n { ##1 = ####1 } }
1410 { \int_compare_p:nNn \l__witharrows_initial_int > \l_tmpa_tl }
1411 { \int_compare_p:nNn \l_tmpb_tl > \l__witharrows_final_int }
1412 { \str_if_eq_p:on \l__witharrows_status_arrow_str { independent } }
1413 }
1414 {
1415 \bool_gset_true:N \g_tmpa_bool
1416 \prop_get:cnN
1417 { g__witharrows _ arrow _ \l__witharrows_prefix_str _ ####1 _ prop }
1418 { width }
1419 \l_tmpa_tl
1420 \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \g_tmpa_dim \l_tmpa_tl }
1421 }
1422 }
1423 \endpgfpicture
1424 \bool_if:NTF \g_tmpa_bool
1425 {
1426 \int_set:Nn \l__witharrows_arrow_int { ##1 }
1427 \dim_set_eq:NN \l__witharrows_xoffset_dim \g_tmpa_dim
1428 \dim_add:Nn \l__witharrows_xoffset_dim \l__witharrows_xoffset_for_o_arrows_dim
1429 \__witharrows_draw_arrow:
1430 }
1431 { \__witharrows_error:n { o~arrow~with~no~arrow~under } }
1432 }
1433 }
1434 \cs_new:Npn \WithArrowsLastEnv { \int_use:N \g__witharrows_last_env_int }
1435 \keys_define:nn { WithArrows / Arrow / code-after }
1436 {
1437 tikz .code:n =
1438 \tikzset { WithArrows / arrow / .append~style = { #1 } } ,
1439 tikz .value_required:n = true ,
1440 rr .value_forbidden:n = true ,
1441 rr .code:n = \__witharrows_fix_pos_option:n 0 ,
1442 ll .value_forbidden:n = true,
1443 ll .code:n = \__witharrows_fix_pos_option:n 1 ,
1444 rl .value_forbidden:n = true ,
1445 rl .code:n = \__witharrows_fix_pos_option:n 2 ,
1446 lr .value_forbidden:n = true ,
1447 lr .code:n = \__witharrows_fix_pos_option:n 3 ,
1448 v .value_forbidden:n = true ,
1449 v .code:n = \__witharrows_fix_pos_option:n 4 ,
1450 tikz-code .tl_set:N = \l__witharrows_tikz_code_tl ,
1451 tikz-code .value_required:n = true ,
1452 xoffset .dim_set:N = \l__witharrows_xoffset_dim ,
1453 xoffset .value_required:n = true ,
1454 unknown .code:n =
1455 \__witharrows_sort_seq:N \l__witharrows_options_Arrow_code_after_seq
1456 \__witharrows_error:n { Unknown~option~Arrow~in~code-after }
1457 }
1458 \seq_new:N \l__witharrows_options_Arrow_code_after_seq
1459 \__witharrows_set_seq_of_str_from_clist:Nn \l__witharrows_options_Arrow_code_after_seq
1460 { ll, lr, rl, rr, tikz, tikz-code, v, x, offset }
1461 \cs_new_protected:Npn \__witharrows_Arrow_code_after
1462 {
1463 \peek_meaning:NTF [
1464 { \__witharrows_Arrow_code_after_i }
1465 { \__witharrows_Arrow_code_after_i [ ] }
1466 }
1467 \cs_new_protected:Npn \__witharrows_Arrow_code_after_i [ #1 ] #2 #3 #4
1468 {
1469 \peek_meaning:NTF [
1470 { \__witharrows_Arrow_code_after_ii [ #1 ] { #2 } { #3 } { #4 } }
1471 { \__witharrows_Arrow_code_after_ii [ #1 ] { #2 } { #3 } { #4 } [ ] }
1472 }
1473 \cs_new_protected:Npn \__witharrows_Arrow_code_after_ii [ #1 ] #2 #3 #4 [ #5 ]
1474 {
1475 \int_set_eq:NN \l__witharrows_pos_arrow_int \c_one_int
1476 \str_clear_new:N \l__witharrows_previous_key_str
1477 \group_begin:
1478 \keys_set:nn { WithArrows / Arrow / code-after }
1479 { #1, #5, tikz = { xshift = \l__witharrows_xoffset_dim } }
1480 \bool_set_false:N \l__witharrows_initial_r_bool
1481 \bool_set_false:N \l__witharrows_final_r_bool
1482 \int_case:nn \l__witharrows_pos_arrow_int
1483 {
1484 0
1485 {
1486 \bool_set_true:N \l__witharrows_initial_r_bool
1487 \bool_set_true:N \l__witharrows_final_r_bool
1488 }
1489 2 { \bool_set_true:N \l__witharrows_initial_r_bool }
1490 3 { \bool_set_true:N \l__witharrows_final_r_bool }
1491 }
1492 \tl_if_eq:nnTF { #2 } { #3 }
1493 { \__witharrows_error:nn { Both~lines~are~equal } { #2 } }
1494 {
1495 \cs_if_free:cTF { pgf@sh@ns@wa - \l__witharrows_prefix_str - #2 - l }
1496 { \__witharrows_error:ne { Wrong~line~in~Arrow } { #2 } }
1497 {
1498 \cs_if_free:cTF { pgf@sh@ns@wa - \l__witharrows_prefix_str - #3 - l }
1499 { \__witharrows_error:ne { Wrong~line~in~Arrow } { #3 } }
1500 {
1501 \int_compare:nNnTF \l__witharrows_pos_arrow_int = 4
1502 {
1503 \pgfpicture
1504 \pgfrememberpicturepositiononpagetrue
1505 \pgfpointanchor { wa - \l__witharrows_prefix_str - #2 - l }
1506 { south }
1507 \dim_set_eq:NN \l_tmpa_dim \pgf@x
1508 \dim_set_eq:NN \l_tmpb_dim \pgf@y
1509 \pgfpointanchor { wa - \l__witharrows_prefix_str - #3 - l }
1510 { north }
1511 \dim_set:Nn \l_tmpa_dim
1512 { \dim_max:nn \l_tmpa_dim \pgf@x }
1513 \tl_gset:Ne \g_tmpa_tl
1514 { \dim_use:N \l_tmpa_dim , \dim_use:N \l_tmpb_dim }
1515 \tl_gset:Ne \g_tmpb_tl
1516 { \dim_use:N \l_tmpa_dim , \dim_use:N \pgf@y }
1517 \endpgfpicture
1518 }
1519 {
1520 \pgfpicture
1521 \pgfrememberpicturepositiononpagetrue
1522 \pgfpointanchor
1523 {
1524 wa - \l__witharrows_prefix_str -
1525 #2 - \bool_if:NTF \l__witharrows_initial_r_bool r l
1526 }
1527 { south }
1528 \tl_gset:Ne \g_tmpa_tl
1529 { \dim_use:N \pgf@x , \dim_use:N \pgf@y }
1530 \pgfpointanchor
1531 {
1532 wa - \l__witharrows_prefix_str -
1533 #3 - \bool_if:NTF \l__witharrows_final_r_bool r l
1534 }
1535 { north }
1536 \tl_gset:Ne \g_tmpb_tl
1537 { \dim_use:N \pgf@x , \dim_use:N \pgf@y }
1538 \endpgfpicture
1539 }
1540 \__witharrows_draw_arrow:nnn \g_tmpa_tl \g_tmpb_tl { #4 }
1541 }
1542 }
1543 }
1544 \group_end:
1545 }
1546 \cs_new_protected:Npn \__witharrows_MultiArrow:nn #1 #2
1547 {
1548 \exp_args:Nne
1549 \regex_match:nnTF
1550 { \A \d+ (\,\d+)* ( \, \.\.\. (\,\d+)+ )* \Z }
1551 { #1 }
1552 { \__witharrows_MultiArrow_i:nn { #1 } { #2 } }
1553 { \__witharrows_error:ne { Invalid~specification~for~MultiArrow } { #1 } }
1554 }
1555 \cs_new_protected:Npn \__witharrows_MultiArrow_i:nn #1 #2
1556 {
1557 \foreach \x in { #1 }
1558 {
1559 \cs_if_free:cTF { pgf@sh@ns@wa - \l__witharrows_prefix_str - \x - l }
1560 { \__witharrows_error:ne { Wrong~line~specification~in~MultiArrow } \x }
1561 { \clist_gput_right:Ne \g_tmpa_clist \x }
1562 }
1563 \int_compare:nTF { \clist_count:N \g_tmpa_clist < 2 }
1564 { \__witharrows_error:n { Too~small~specification~for~MultiArrow } }
1565 {
1566 \clist_sort:Nn \g_tmpa_clist
1567 {
1568 \int_compare:nNnTF { ##1 } > { ##2 }
1569 \sort_return_swapped:
1570 \sort_return_same:
1571 }
1572 \clist_pop:NN \g_tmpa_clist \l_tmpa_tl
1573 \clist_reverse:N \g_tmpa_clist
1574 \clist_pop:NN \g_tmpa_clist \l_tmpb_tl
1575 \exp_args:No \__witharrows_MultiArrow_i:n \g_tmpa_clist
1576 \tikzpicture
1577 [
1578 __witharrows_standard ,
1579 every~path / .style = { WithArrows / arrow }
1580 ]
1581 \draw [<->] ([xshift = \l__witharrows_xoffset_dim]\l_tmpa_tl-r.south)
1582 -- ++(5mm,0)
1583 -- node (__witharrows_label) {}
1584 ([xshift = \l__witharrows_xoffset_dim+5mm]\l_tmpb_tl-r.south)
1585 -- ([xshift = \l__witharrows_xoffset_dim]\l_tmpb_tl-r.south) ;
1586 \pgfpointanchor { wa - \l__witharrows_prefix_str - __witharrows_label } { west }
1587 \dim_set:Nn \l_tmpa_dim { 20 cm }
1588 \path \pgfextra { \tl_gset:Ne \g_tmpa_tl \tikz@text@width } ;
1589 \tl_if_empty:NF \g_tmpa_tl { \dim_set:Nn \l_tmpa_dim \g_tmpa_tl }
1590 \bool_lazy_and:nnT \l__witharrows_wrap_lines_bool \l__witharrows_in_DispWithArrows_bool
1591 {
1592 \dim_set:Nn \l_tmpb_dim
1593 { \g__witharrows_right_x_dim - \pgf@x - 0.3333 em }
1594 \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim
1595 { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim }
1596 }
1597 \path (__witharrows_label.west)
1598 node [ anchor = west, text~width = \dim_use:N \l_tmpa_dim ] { #2 } ;
1599 \endtikzpicture
1600 }
1601 }
1602 \cs_new_protected:Npn \__witharrows_MultiArrow_i:n #1
1603 {
1604 \tikzpicture
1605 [
1606 __witharrows_standard ,
1607 every~path / .style = { WithArrows / arrow }
1608 ]
1609 \foreach \k in { #1 }
1610 {
1611 \draw [ <- ]
1612 ( [xshift = \l__witharrows_xoffset_dim]\k-r.south ) -- ++(5mm,0) ;
1613 } % ;
1614 \endtikzpicture
1615 }
1616 \bool_if:NTF \c__witharrows_messages_for_Overleaf_bool
1617 { \str_const:Nn \c__witharrows_available_keys_str { } }
1618 {
1619 \str_const:Nn \c__witharrows_available_keys_str
1620 { For~a~list~of~the~available~keys,~type~H~<return>. }
1621 }
1622 \str_new:N \l_witharrows_body_str
1623 \cs_new:Npn \__witharrows_potential_body_i:
1624 {
1625 \str_if_empty:NF \l_witharrows_body_str
1626 { \\ If~you~want~to~see~the~body~of~the~environment,~type~H~<return>. }
1627 }
1628 \cs_new:Npn \__witharrows_potential_body_ii:
1629 {
1630 \str_if_empty:NTF \l_witharrows_body_str
1631 { No~further~help~available }
1632 {
1633 The~body~of~your~environment~was:\\
1634 \l_witharrows_body_str
1635 }
1636 }
1637 \str_const:Nn \c__witharrows_option_ignored_str
1638 { If~you~go~on,~this~option~will~be~ignored. }
1639 \str_const:Nn \c__witharrows_command_ignored_str
1640 { If~you~go~on,~this~command~will~be~ignored. }
1641 \__witharrows_msg_new:nn { Bad~value~for~replace~brace~by }
1642 {
1643 Incorrect~value.\\
1644 Bad~value~for~the~option~'\l_keys_key_str'.~The~value~must~begin~
1645 with~an~extensible~left~delimiter.~The~possible~values~are:~.,
1646 \token_to_str:N \{,~(,~[,~\token_to_str:N \lbrace,~
1647 \token_to_str:N \lbrack,~\token_to_str:N \lgroup,~
1648 \token_to_str:N \langle,~\token_to_str:N \lmoustache,~
1649 \token_to_str:N \lfloor\ and~\token_to_str:N \lceil\
1650 (and~\token_to_str:N \lvert\ and~\token_to_str:N \lVert\
1651 if~amsmath~or~unicode-math~is~loaded~in~LaTeX).\\
1652 \c__witharrows_option_ignored_str
1653 }
1654 \__witharrows_msg_new:nn { option~of~cr~negative }
1655 {
1656 Bad~value.\\
1657 The~argument~of~the~command~\token_to_str:N\\~
1658 should~be~positive~in~the~row~\int_use:N \g__witharrows_line_int\
1659 of~your~environment~\{\l__witharrows_type_env_str\}.\\
1660 \c__witharrows_option_ignored_str
1661 }
1662 \__witharrows_msg_new:nn { omit~probably~used }
1663 {
1664 Strange~problem.\\
1665 Maybe~you~have~used~a~command~
1666 \token_to_str:N\omit\ in~the~line~\int_use:N \g__witharrows_line_int\
1667 (or~another~line)~of~your~environment~\{\l__witharrows_type_env_str\}.\\
1668 You~can~go~on~but~you~may~have~others~errors.
1669 }
1670 \__witharrows_msg_new:nnn { Invalid~option~format }
1671 {
1672 Invalide~value.\\
1673 The~key~'format'~should~contain~only~letters~r,~c~and~l~and~
1674 must~not~be~empty.\\
1675 \c__witharrows_option_ignored_str
1676 \__witharrows_potential_body_i:
1677 }
1678 { \__witharrows_potential_body_ii: }
1679 \__witharrows_msg_new:nnn { invalid~key~o }
1680 {
1681 Invalid~use~of~a~key.\\
1682 The~key~'o'~for~individual~arrows~can~be~used~only~in~mode~
1683 'group'~or~in~mode~'groups'.\\
1684 \c__witharrows_option_ignored_str
1685 \__witharrows_potential_body_i:
1686 }
1687 { \__witharrows_potential_body_ii: }
1688 \__witharrows_msg_new:nnn { Value~for~a~key }
1689 {
1690 Misuse~of~a~key.\\
1691 The~key~'\l_keys_key_str'~should~be~used~without~value. \\
1692 However,~you~can~go~on~for~this~time.
1693 \__witharrows_potential_body_i:
1694 }
1695 { \__witharrows_potential_body_ii: }
1696 \__witharrows_msg_new:nnn { Unknown~option~in~Arrow }
1697 {
1698 Unknown~option.\\
1699 The~key~'\l_keys_key_str'~is~unknown~for~the~command~
1700 \l__witharrows_string_Arrow_for_msg_str\ in~the~row~
1701 \int_use:N \g__witharrows_line_int\ of~your~environment~
1702 \{\l__witharrows_type_env_str\}. \l_tmpa_str \\
1703 \c__witharrows_option_ignored_str \\
1704 \c__witharrows_available_keys_str
1705 }
1706 {
1707 The~available~keys~are~(in~alphabetic~order):~
1708 \seq_use:Nnnn \l__witharrows_options_Arrow_seq {~and~} {,~} {~and~}.
1709 }
1710 \__witharrows_msg_new:nnn { Unknown~option~WithArrows }
1711 {
1712 Unknown~option.\\
1713 The~key~'\l_keys_key_str'~is~unknown~in~\{\l__witharrows_type_env_str\}. \\
1714 \c__witharrows_option_ignored_str \\
1715 \c__witharrows_available_keys_str
1716 }
1717 {
1718 The~available~keys~are~(in~alphabetic~order):~
1719 \seq_use:Nnnn \l__witharrows_options_WithArrows_seq {~and~} {,~} {~and~}.
1720 }
1721 \__witharrows_msg_new:nnn { Unknown~option~DispWithArrows }
1722 {
1723 Unknown~option.\\
1724 The~key~'\l_keys_key_str'~is~unknown~in~\{\l__witharrows_type_env_str\}. \\
1725 \c__witharrows_option_ignored_str \\
1726 \c__witharrows_available_keys_str
1727 }
1728 {
1729 The~available~keys~are~(in~alphabetic~order):~
1730 \seq_use:Nnnn \l__witharrows_options_DispWithArrows_seq {~and~} {,~} {~and~}.
1731 }
1732 \__witharrows_msg_new:nnn { Unknown~option~WithArrowsOptions }
1733 {
1734 Unknown~option.\\
1735 The~key~'\l_keys_key_str'~is~unknown~in~
1736 \token_to_str:N \WithArrowsOptions. \\
1737 \c__witharrows_option_ignored_str \\
1738 \c__witharrows_available_keys_str
1739 }
1740 {
1741 The~available~keys~are~(in~alphabetic~order):~
1742 \seq_use:Nnnn \l__witharrows_options_WithArrowsOptions_seq {~and~} {,~} {~and~}.
1743 }
1744 \__witharrows_msg_new:nnn { Unknown~option~Arrow~in~code-after }
1745 {
1746 Unknown~option.\\
1747 The~key~'\l_keys_key_str'~is~unknown~in~
1748 \token_to_str:N \Arrow\ in~code-after. \\
1749 \c__witharrows_option_ignored_str \\
1750 \c__witharrows_available_keys_str
1751 }
1752 {
1753 The~available~keys~are~(in~alphabetic~order):~
1754 \seq_use:Nnnn \l__witharrows_options_Arrow_code_after_seq {~and~} {,~} {~and~}.
1755 }
1756 \__witharrows_msg_new:nnn { Too~much~columns~in~WithArrows }
1757 {
1758 Too~much~columns.\\
1759 Your~environment~\{\l__witharrows_type_env_str\}~has~\int_use:N
1760 \l__witharrows_nb_cols_int\ columns~and~you~try~to~use~one~more.~
1761 Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str.~
1762 If~you~really~want~to~use~more~columns~(after~the~arrows)~you~should~use~
1763 the~option~'more-columns'~at~a~global~level~or~for~an~environment. \\
1764 However,~you~can~go~one~for~this~time.
1765 \__witharrows_potential_body_i:
1766 }
1767 { \__witharrows_potential_body_ii: }
1768 \__witharrows_msg_new:nnn { Too~much~columns~in~DispWithArrows }
1769 {
1770 Too~much~columns.\\
1771 Your~environment~\{\l__witharrows_type_env_str\}~has~\int_use:N
1772 \l__witharrows_nb_cols_int\ columns~and~you~try~to~use~one~more.~
1773 Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str\
1774 at~the~end~of~row~\int_use:N \g__witharrows_line_int. \\
1775 This~error~is~fatal.
1776 \__witharrows_potential_body_i:
1777 }
1778 { \__witharrows_potential_body_ii: }
1779 \__witharrows_msg_new:nn { Negative~jump }
1780 {
1781 Incorrect~value.\\
1782 You~can't~use~a~negative~value~for~the~option~'jump'~of~command~
1783 \l__witharrows_string_Arrow_for_msg_str\
1784 in~the~row~\int_use:N \g__witharrows_line_int\
1785 of~your~environment~\{\l__witharrows_type_env_str\}.~
1786 You~can~create~an~arrow~going~backwards~with~the~option~'<-'~of~Tikz. \\
1787 \c__witharrows_option_ignored_str
1788 }
1789 \__witharrows_msg_new:nn { new-group~without~groups }
1790 {
1791 Misuse~of~a~key.\\
1792 You~can't~use~the~option~'new-group'~for~the~command~
1793 \l__witharrows_string_Arrow_for_msg_str\
1794 because~you~are~not~in~'groups'~mode.~Try~to~use~the~option~
1795 'groups'~in~your~environment~\{\l__witharrows_type_env_str\}. \\
1796 \c__witharrows_option_ignored_str
1797 }
1798 \__witharrows_msg_new:nnn
1799 { Too~few~lines~for~an~arrow }
1800 {
1801 Impossible~arrow.\\
1802 Line~\l__witharrows_input_line_str\
1803 :~an~arrow~specified~in~the~row~\int_use:N \l__witharrows_initial_int\
1804 of~your~environment~\{\l__witharrows_type_env_str\}~can't~be~drawn~
1805 because~it~arrives~after~the~last~row~of~the~environment. \\
1806 If~you~go~on,~this~arrow~will~be~ignored.
1807 \__witharrows_potential_body_i:
1808 }
1809 { \__witharrows_potential_body_ii: }
1810 \__witharrows_msg_new:nn { o~arrow~with~no~arrow~under }
1811 {
1812 Problem~with~the~key~'o'.\\
1813 Line~\l__witharrows_input_line_str\
1814 :~there~is~no~arrow~'under'~your~arrow~of~type~'o'.\\
1815 If~you~go~on,~this~arrow~won't~be~drawn.
1816 }
1817 \__witharrows_msg_new:nnn { WithArrows~outside~math~mode }
1818 {
1819 You~are~outside~math~mode.\\
1820 The~environment~\{\l__witharrows_type_env_str\}~should~be~used~only~in~math~mode~
1821 like~the~environment~\{aligned\}~of~amsmath. \\
1822 Nevertheless,~you~can~go~on.
1823 \__witharrows_potential_body_i:
1824 }
1825 { \__witharrows_potential_body_ii: }
1826 \__witharrows_msg_new:nnn { DispWithArrows~in~math~mode }
1827 {
1828 You~are~in~math~mode.\\
1829 The~environment~\{\l__witharrows_type_env_str\}~should~be~used~only~outside~math~
1830 mode~like~the~environments~\{align\}~and~\{align*\}~of~amsmath. \\
1831 This~error~is~fatal.
1832 \__witharrows_potential_body_i:
1833 }
1834 { \__witharrows_potential_body_ii: }
1835 \__witharrows_msg_new:nn { Incompatible~options~in~Arrow }
1836 {
1837 Incompatible~options.\\
1838 You~try~to~use~the~option~'\l_keys_key_str'~but~
1839 this~option~is~incompatible~or~redundant~with~the~option~
1840 '\l__witharrows_previous_key_str'~set~in~the~same~command~
1841 \l__witharrows_string_Arrow_for_msg_str. \\
1842 \c__witharrows_option_ignored_str
1843 }
1844 \__witharrows_msg_new:nn { Incompatible~options a}
1845 {
1846 Incompatible~options.\\
1847 You~try~to~use~the~option~'\l_keys_key_str'~but~
1848 this~option~is~incompatible~or~redundant~with~the~option~
1849 '\l__witharrows_previous_key_str'~set~in~the~same~command~
1850 \bool_if:NT \l__witharrows_in_code_after_bool
1851 {
1852 \l__witharrows_string_Arrow_for_msg_str\
1853 in~the~code-after~of~your~environment~\{\l__witharrows_type_env_str\}
1854 }. \\
1855 \c__witharrows_option_ignored_str
1856 }
1857 \__witharrows_msg_new:nnn { Arrow~not~in~last~column }
1858 {
1859 Bad~use~of~\l__witharrows_string_Arrow_for_msg_str.\\
1860 You~should~use~the~command~\l__witharrows_string_Arrow_for_msg_str\
1861 only~in~the~last~column~(column~\int_use:N\l__witharrows_nb_cols_int)~
1862 in~the~row~\int_use:N \g__witharrows_line_int\
1863 of~your~environment~\{\l__witharrows_type_env_str\}.\\
1864 However~you~can~go~on~for~this~time.
1865 \__witharrows_potential_body_i:
1866 }
1867 { \__witharrows_potential_body_ii: }
1868 \__witharrows_msg_new:nn { Wrong~line~in~Arrow }
1869 {
1870 Wrong~line.\\
1871 The~specification~of~line~'#1'~you~use~in~the~command~
1872 \l__witharrows_string_Arrow_for_msg_str\
1873 in~the~'code-after'~of~\{\l__witharrows_type_env_str\}~doesn't~exist. \\
1874 \c__witharrows_option_ignored_str
1875 }
1876 \__witharrows_msg_new:nn { Both~lines~are~equal }
1877 {
1878 Both~lines~are~equal.\\
1879 In~the~'code-after'~of~\{\l__witharrows_type_env_str\}~you~try~to~
1880 draw~an~arrow~going~to~itself~from~the~line~'#1'.~This~is~not~possible. \\
1881 \c__witharrows_option_ignored_str
1882 }
1883 \__witharrows_msg_new:nn { Wrong~line~specification~in~MultiArrow }
1884 {
1885 Wrong~line~specification.\\
1886 The~specification~of~line~'#1'~doesn't~exist. \\
1887 If~you~go~on,~it~will~be~ignored~for~\token_to_str:N \MultiArrow.
1888 }
1889 \__witharrows_msg_new:nn { Too~small~specification~for~MultiArrow }
1890 {
1891 Too~small~specification.\\
1892 The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\
1893 is~too~small:~you~need~at~least~two~lines. \\
1894 \c__witharrows_command_ignored_str
1895 }
1896 \__witharrows_msg_new:nn { Not~allowed~in~DispWithArrows }
1897 {
1898 Forbidden~command.\\
1899 The~command~\token_to_str:N #1
1900 is~allowed~only~in~the~last~column~
1901 (column~\int_use:N\l__witharrows_nb_cols_int)~of~\{\l__witharrows_type_env_str\}. \\
1902 \c__witharrows_option_ignored_str
1903 }
1904 \__witharrows_msg_new:nn { Not~allowed~in~WithArrows }
1905 {
1906 Forbidden~command.\\
1907 The~command~\token_to_str:N #1 is~not~allowed~in~\{\l__witharrows_type_env_str\}~
1908 (it's~allowed~in~the~last~column~of~\{DispWithArrows\}). \\
1909 \c__witharrows_option_ignored_str
1910 }
1911 \__witharrows_msg_new:nn { Inexistent~v-node }
1912 {
1913 There~is~a~problem.\\
1914 Maybe~you~have~put~a~command~\token_to_str:N\cr\
1915 instead~of~a~command~\token_to_str:N\\~at~the~end~of~
1916 the~row~\l_tmpa_int\
1917 of~your~environment~\{\l__witharrows_type_env_str\}. \\
1918 This~error~is~fatal.
1919 }
1920 \__witharrows_msg_new:nn { Option~xoffset~forbidden }
1921 {
1922 Incorrect~key.\\
1923 You~can't~use~the~option~'xoffset'~in~the~command~
1924 \l__witharrows_string_Arrow_for_msg_str\ in~the~row~\int_use:N \g__witharrows_line_int\
1925 of~your~environment~\{\l__witharrows_type_env_str\}~
1926 because~you~are~using~the~option~
1927 ' \int_compare:nNnTF \l__witharrows_pos_arrow_int = 7
1928 { group }
1929 { groups } '.~It's~possible~for~an~independent~arrow~or~if~there~is~
1930 only~one~arrow. \\
1931 \c__witharrows_option_ignored_str
1932 }
1933 \__witharrows_msg_new:nnn { Duplicate~name }
1934 {
1935 Duplicate~name.\\
1936 The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~
1937 the~same~environment~name~twice.~You~can~go~on,~but,~
1938 maybe,~you~will~have~incorrect~results. \\
1939 For~a~list~of~the~names~already~used,~type~H~<return>. \\
1940 If~you~don't~want~to~see~this~message~again,~use~the~option~
1941 'allow-duplicate-names'.
1942 }
1943 {
1944 The~names~already~defined~in~this~document~are:~
1945 \seq_use:Nnnn \g__witharrows_names_seq { ,~ } { ,~ } { ~and~ }.
1946 }
1947 \__witharrows_msg_new:nn { Invalid~specification~for~MultiArrow }
1948 {
1949 Invalid~specification.\\
1950 The~specification~of~rows~for~\token_to_str:N\MultiArrow\
1951 (i.e.~#1)~is~invalid. \\
1952 \c__witharrows_command_ignored_str
1953 }
1954 \cs_new_protected:Npn \WithArrowsNewStyle #1 #2
1955 {
1956 \keys_if_exist:nnTF { WithArrows / Global } { #1 }
1957 { \__witharrows_error:nn { Key~already~defined } { #1 } }
1958 {
1959 \seq_clear:N \l_tmpa_seq
1960 \keyval_parse:NNn \__witharrows_valid_key:n \__witharrows_valid_key:nn { #2 }
1961 \seq_if_empty:NTF \l_tmpa_seq
1962 {
1963 \seq_put_right:Ne \l__witharrows_options_WithArrows_seq
1964 { \tl_to_str:n { #1 } }
1965 \seq_put_right:Ne \l__witharrows_options_DispWithArrows_seq
1966 { \tl_to_str:n { #1 } }
1967 \seq_put_right:Ne \l__witharrows_options_WithArrowsOptions_seq
1968 { \tl_to_str:N { #1 } }
1969 \keys_precompile:nnc
1970 { WithArrows / WithArrowsOptions }
1971 { #2 }
1972 { __witharrows _ style _ #1 _ tl }
1973 \keys_define:nn { WithArrows / Global }
1974 { #1 .code:n = \use:c { __witharrows _ style _ #1 _ tl } }
1975 }
1976 { \__witharrows_error:nn { Impossible~style } { #1 } }
1977 }
1978 }
1979 \__witharrows_msg_new:nn { Impossible~style }
1980 {
1981 Impossible~style.\\
1982 It's~impossible~to~define~the~style~'#1'~
1983 because~it~contains~unknown~keys:~'
1984 \seq_use:Nnnn \l_tmpa_seq { '~and~' } { ',~'} { ',~and~}'.
1985 }
1986 \cs_new_protected:Npn \__witharrows_valid_key:n #1
1987 {
1988 \keys_if_exist:nnF { WithArrows / Global } { #1 }
1989 { \seq_put_right:Nn \l_tmpa_seq { #1 } }
1990 }
1991 \cs_new_protected:Npn \__witharrows_valid_key:nn #1 #2
1992 {
1993 \keys_if_exist:nnF { WithArrows / Global } { #1 }
1994 { \seq_put_right:Nn \l_tmpa_seq { #1 } }
1995 }
1996 \__witharrows_msg_new:nn { Key~already~defined }
1997 {
1998 Key~already~defined.\\
1999 The~key~'#1'~is~already~defined. \\
2000 If~you~go~on,~your~instruction~\token_to_str:N\WithArrowsNewStyle\
2001 will~be~ignored.
2002 }
2003 \keys_define:nn { WithArrows / up-and-down }
2004 {
2005 radius .dim_set:N = \l__witharrows_up_and_down_radius_dim ,
2006 radius .value_required:n = true ,
2007 width .code:n =
2008 \str_case:nnF { #1 }
2009 {
2010 { min } { \dim_zero:N \l__witharrows_arrow_width_dim }
2011 { max } { \dim_set_eq:NN \l__witharrows_arrow_width_dim \c_max_dim }
2012 }
2013 { \dim_set:Nn \l__witharrows_arrow_width_dim { #1 } } ,
2014 width .value_required:n = true ,
2015 unknown .code:n = \__witharrows_error:n { Option~unknown~for~up-and-down }
2016 }
2017 \__witharrows_msg_new:nn { Option~unknown~for~up-and-down }
2018 {
2019 Unknown~option.\\
2020 The~option~'\l_keys_key_str'~is~unknown.~\c__witharrows_option_ignored_str
2021 }
2022 \tl_const:Nn \c__witharrows_tikz_code_up_tl
2023 {
2024 \dim_case:nnF \l__witharrows_arrow_width_dim
2025 {
2026 \c_max_dim
2027 {
2028 \draw [ rounded~corners = \l__witharrows_up_and_down_radius_dim ]
2029 let \p1 = ( #1 ) , \p2 = ( #2 )
2030 in (\p1) -- node { #3 } (\x2,\y1) -- (\p2) ;
2031 }
2032 \c_zero_dim
2033 {
2034 \path node
2035 {
2036 \hbox_gset:Nn \g_tmpa_box { #3 }
2037 \dim_gset:Nn \g_tmpa_dim
2038 { \box_wd:N \g_tmpa_box + \l__witharrows_up_and_down_radius_dim }
2039 } ;
2040 \draw
2041 let \p1 = ( #1 ) , \p2 = ( #2 )
2042 in (\x2-\g_tmpa_dim,\y1)
2043 -- node { \box_use:N \g_tmpa_box }
2044 (\x2-\l__witharrows_up_and_down_radius_dim,\y1)
2045 [ rounded~corners = \l__witharrows_up_and_down_radius_dim ]
2046 -| (\p2) ;
2047 }
2048 }
2049 {
2050 \draw
2051 let \p1 = ( #1 ) , \p2 = ( #2 )
2052 in (\x2 - \l__witharrows_arrow_width_dim - \l__witharrows_up_and_down_radius_dim,\y1)
2053 -- node { #3 } (\x2-\l__witharrows_up_and_down_radius_dim,\y1)
2054 [ rounded~corners = \l__witharrows_up_and_down_radius_dim ]
2055 -| (\p2) ;
2056 }
2057 }
2058 \tl_const:Nn \c__witharrows_tikz_code_down_tl
2059 {
2060 \dim_case:nnF \l__witharrows_arrow_width_dim
2061 {
2062 \c_max_dim
2063 {
2064 \draw [ rounded~corners = \l__witharrows_up_and_down_radius_dim ]
2065 let \p1 = ( #1 ) , \p2 = ( #2 )
2066 in (\p1) -- (\x1,\y2) -- node { #3 } (\p2) ;
2067 }
2068 \c_zero_dim
2069 {
2070 \path node
2071 {
2072 \hbox_gset:Nn \g_tmpa_box { #3 }
2073 \dim_gset:Nn \g_tmpa_dim
2074 { \box_wd:N \g_tmpa_box + \l__witharrows_up_and_down_radius_dim }
2075 } ;
2076 \draw
2077 let \p1 = ( #1 ) , \p2 = ( #2 )
2078 in (\p1)
2079 { [ rounded~corners = \l__witharrows_up_and_down_radius_dim ] -- (\x1,\y2) }
2080 -- (\x1-\l__witharrows_up_and_down_radius_dim,\y2)
2081 -- node { \box_use:N \g_tmpa_box } (\x1-\g_tmpa_dim,\y2)
2082 -- ++ (-2mm,0) ;
2083 }
2084 }
2085 {
2086 \draw
2087 let \p1 = ( #1 ) , \p2 = ( #2 )
2088 in (\p1)
2089 { [ rounded~corners = \l__witharrows_up_and_down_radius_dim ] -- (\x1,\y2) }
2090 -- (\x1-\l__witharrows_up_and_down_radius_dim,\y2)
2091 -- node { #3 }
2092 (\x1 - \l__witharrows_arrow_width_dim - \l__witharrows_up_and_down_radius_dim,\y2)
2093 -- ++ (-2mm,0) ;
2094 }
2095 }
2096 \keys_define:nn { WithArrows / Arrow / FirstPass }
2097 {
2098 up .code:n = \__witharrows_set_independent_bis: ,
2099 down .code:n = \__witharrows_set_independent_bis: ,
2100 up .default:n = NoValue ,
2101 down .default:n = NoValue
2102 }
2103 \keys_define:nn { WithArrows / Arrow / SecondPass }
2104 {
2105 up .code:n =
2106 \str_if_empty:NT \l__witharrows_previous_key_str
2107 {
2108 \str_set:Nn \l__witharrows_previous_key_str { up }
2109 \cs_if_exist:NTF \tikz@library@calc@loaded
2110 {
2111 \keys_set:no { WithArrows / up-and-down } \l_keys_value_tl
2112 \int_set:Nn \l__witharrows_pos_arrow_int 1
2113 \bool_set_false:N \l__witharrows_wrap_lines_bool
2114 \tl_set_eq:NN \l__witharrows_tikz_code_tl \c__witharrows_tikz_code_up_tl
2115 }
2116 { \__witharrows_error:n { calc~not~loaded } }
2117 } ,
2118 down .code:n =
2119 \str_if_empty:NT \l__witharrows_previous_key_str
2120 {
2121 \str_set:Nn \l__witharrows_previous_key_str { down }
2122 \cs_if_exist:NTF \tikz@library@calc@loaded
2123 {
2124 \keys_set:no { WithArrows / up-and-down } \l_keys_value_tl
2125 \int_set:Nn \l__witharrows_pos_arrow_int 1
2126 \bool_set_false:N \l__witharrows_wrap_lines_bool
2127 \tl_set_eq:NN \l__witharrows_tikz_code_tl \c__witharrows_tikz_code_down_tl
2128 }
2129 { \__witharrows_error:n { calc~not~loaded } }
2130 }
2131 }
2132 \seq_put_right:Nn \l__witharrows_options_Arrow_seq { down }
2133 \seq_put_right:Nn \l__witharrows_options_Arrow_seq { up }
2134 \__witharrows_msg_new:nn { calc~not~loaded }
2135 {
2136 calc~not~loaded.\\
2137 You~can't~use~the~option~'\l_keys_key_str'~because~you~don't~have~loaded~the~
2138 Tikz~library~'calc'.You~should~add~'\token_to_str:N\usetikzlibrary{calc}'~
2139 ~in~the~preamble~of~your~document. \\
2140 \c__witharrows_option_ignored_str
2141 }
2142 \catcode `\@ = 12
2143 \ExplSyntaxOff
2144 \endinput
2145 %%
2146 %% End of file `witharrows.tex'.