summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/witharrows/witharrows.tex
blob: 675da4518eeb472922557ad6eb6c35415a4ebffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
% This document is compatible with the following workflows :
%    pdflatex,
%    xelatex (with xdvipdfmx),
%    latex --> dvips --> ps2pdf (or Adobe Distiller).
\documentclass{article}

\usepackage{ifxetex}

\ifxetex
  \usepackage{xltxtra}
\else
  \usepackage{expl3}
  \usepackage{xparse}
  \usepackage[T1]{fontenc}
\fi

\usepackage{xspace}


\usepackage[dvipsnames]{xcolor}

\usepackage{lmodern}

\ifxetex
   \usepackage[xetex]{geometry}
\else
   \usepackage{geometry}
\fi

\geometry{papersize={16.5cm,24cm},total={12.5cm,21cm},headheight=13.2pt,includeheadfoot,twoside,centering}


\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{bending}
\usetikzlibrary{decorations.pathreplacing}


\usepackage{footnote}

\usepackage{witharrows}

\usepackage{fancyvrb}
\usepackage{mathtools}


% this following lines only for this document

\usepackage{amsfonts}

\def\interitem{\vskip 7mm plus 2 mm minus 3mm}          
\def\emphase#1{{\color{RoyalPurple}#1}}
\fvset{commandchars=\~\#\@,formatcom={\color{gray}}}
\DeclareMathOperator{\re}{Re}
\let\group\begingroup


\begin{document}


\parindent0pt

\title{Extension witharrows, v. 1.0}

\author{Fran\c cois Pantigny}

\date{2017/08/17}

\maketitle



\begin{abstract}
The LaTeX package \verb|witharrows| gives an environment \verb|{WithArrows}| which is similar to environment
\verb|{aligned}| of \verb|amsmath| (and \verb|mathtools|) but gives the possibility to draw arrows on the right
side of the alignment. These arrows are usually used to give explanations concerning the mathematical calculus presented.
\end{abstract}


\vskip1cm

This package uses Tikz to draw the arrows. It can be used with \verb|xelatex|, \verb|pdflatex| but also by the
classical workflow \verb|latex|-\verb|dvips|-\verb|ps2pdf| (or Distiller). Two compilations may be necessary.

\medskip
This package gives an environment \verb|{WithArrows}| to construct alignments of equations with
arrows for the explanations on the right side :
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 ~emphase#\Arrow{we expand}@ \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$



\medskip
The arrow has been drawn with the command \verb|\Arrow| on the ligne from which it starts. The command \verb|\Arrow|
can be used anywhere on the line but the best way is to put it at the end.


\medskip
The ends of the lines of the tabular can be coded by \verb|\\| but also by \verb|\cr| (like in the command
\verb|\halign| of TeX). In fact, in an environment \verb|{WithArrows}|, the command \verb|\\| has no option for the
spacing between rows like in many environments of LaTeX.




\section{Options for the shape of the arrows}

The commande \verb|\Arrow| has several options. These options can be put between square brackets, before, or after
the mandatory argument.

The option \verb|jump| gives the number of lines the arrow must jump (the default value is, of course,~$1$)
\footnote{It's not possible to give a non-positive value to \texttt{jump}. See below the way to draw an arrow which
goes backwards.}
%
\begin{Verbatim}
$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 \Arrow~emphase#[jump=2]@{we expand} \\
  & = (a+b)^2 + 2(a+b) +1 \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 \\
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 \Arrow[jump=2]{we expand} \\
  & = (a+b)^2 + 2(a+b) +1 \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 \\
\end{WithArrows}$




\interitem
It's possible to put several arrows which start from the same line.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 ~emphase#\Arrow{}\Arrow{}[jump=2]@ \\
  & = (a+b)^2 + 2(a+b) +1 \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 \Arrow{}\Arrow{}[jump=2] \\
  & = (a+b)^2 + 2(a+b) +1 \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 
\end{WithArrows}$


\interitem
The option \verb|xoffset| shift the arrows to the right (we usually don't want the arrows to be stucked
on the text). The default value of \verb|xoffset| is $3$~mm.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 
\Arrow[~emphase#xoffset=1cm@]{with \texttt{xoffset=1cm}} \\
  & = (a+b)^2 + 2(a+b) +1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 
\Arrow[xoffset=1cm]{with \texttt{xoffset=1cm}} \\
  & = (a+b)^2 + 2(a+b) +1 \\
\end{WithArrows}$




\interitem 
The arrows are drawn with Tikz. That's why the command \verb|\Arrow| has an option
\verb|tikz| which can be used to give to the arrow (in fact, the command \verb|\path| of Tikz) the options
proposed by Tikz for such an arrow. The following example gives an blue thick arrow.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow[~emphase#tikz={blue,thick}@]{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow[tikz={blue,thick}]{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$



\interitem
It's also possible to change the arrowheadss. For example, we can draw an arrow which goes backwards 
with the Tikz option~\verb|<-|.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow~emphase#[tikz=<-]@{we factorize} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow[tikz=<-]{we factorize} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$



\interitem
It's also possible to suppress both tips of the arrow with the Tikz option \verb|-|.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow[~emphase#tikz=-@]{very classical} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow[tikz=-]{very classical} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$



\interitem
In order to have straight arrows instead of curved ones, we must use the Tikz option ``\verb|bend left = 0|''.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow~emphase#[tikz={bend left=0}]@{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow[tikz={bend left=0}]{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$



\interitem
One of the most useful options is ``\verb|text width|'' to control the with of the text associated to the arrow. 
%
\begin{Verbatim}
$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 
\Arrow[jump=2,~emphase#tikz={text width=5.3cm}@]{We have done...} \\
  & = (a+b)^2 + 2(a+b) +1 \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = \bigl((a+b)+1\bigr)^2 
\Arrow[jump=2,tikz={text width=5.3cm}]{We have done a two-stages expansion but it would have been clever
to expand with the multinomial theorem.} \\
  & = (a+b)^2 + 2(a+b) +1 \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 
\end{WithArrows}$


\interitem
If we want to change the font of the text associated to the arrow, we can, of course, put a command like
\verb|\bfseries|, \verb|\large| or \verb|\sffamily| at the beginning of the text. But, by default, the texts
are composed with a combination of \verb|\small| and \verb|\itshape|. When adding \verb|\bfseries| at the beginning
of the text, we won't suppress the \verb|\small| and the \verb|\itshape| and we will consequently have a text in a
bold, italic and small font.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow{~emphase#\bfseries@ we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow{\bfseries we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$


\interitem 
If we put commands \verb|\\| in the text to force newlines, a command of font placed in the beginning of the
text will have effect only until the first command \verb|\\| (like in a environment \verb|{tabular}|). That's why
Tikz gives a option \verb|font| to modify the font of the whole text. Nevertheless, if we use the option
\verb|tikz={font={\bfseries}}|, the default specification of \verb|\small| and \verb|\itshape| will be overwritten.
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow[~emphase#tikz={font={\bfseries}}@]{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow[tikz={font={\bfseries}}]{we expand} \\
  & = a^2 + 2a + 1 
\end{WithArrows}$

\medskip
If we want exactly the same result as previously, we have to give to the option \verb|font| the value 
\verb|{\itshape\small\bfseries}|.




\interitem 
Almost all the options can be given directly to the environment \verb|WithArrows| (between square brackets).
In this case, they apply to all the arrows of the environment.
%
\begin{Verbatim}
$\begin{WithArrows}~emphase#[tikz=blue]@
A & = \bigl((a+b)+1\bigr)^2 \Arrow{First expansion.} \\
  & = (a+b)^2 + 2(a+b) +1 \Arrow{Second expansion.} \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}[tikz=blue]
A & = \bigl((a+b)+1\bigr)^2 \Arrow{First expansion.} \\
  & = (a+b)^2 + 2(a+b) +1 \Arrow{Second expansion.} \\
  & = a^2 + 2ab + b^2 + 2a + 2b +1 
\end{WithArrows}$


\interitem
The environment \verb|{WithArrows}| has an option \verb|displaystyle|. With this option, all the elements are
composed in \verb|\displaystyle| (like in an environment \verb|{aligned}| of \verb|amsmath|). 

\medskip
Without the option \verb|displaystyle| :
%
\begin{Verbatim}
$\begin{WithArrows}
\int_0^1 (x+1)^2 dx 
& = \int_0^1 (x^2+2x+1) dx
\Arrow{linearity of integration}     \\
& = \int_0^1 x^2 dx + 2 \int_0^1 x dx + \int_0^1 dx \\
& = \frac13 + 2\frac12 + 1 \\
& = \frac73
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
\int_0^1 (x+1)^2 dx 
& = \int_0^1 (x^2+2x+1) dx
\Arrow{linearity of integration}     \\
& = \int_0^1 x^2 dx + 2 \int_0^1 x dx + \int_0^1 dx \\
& = \frac13 + 2\frac12 + 1 \\
& = \frac73
\end{WithArrows}$


\medskip
The same example with the option \verb|displaystyle| :\par\nobreak

$\begin{WithArrows}[displaystyle]
\int_0^1 (x+1)^2 dx 
& = \int_0^1 (x^2+2x+1) dx
\Arrow{linearity of integration}     \\
& = \int_0^1 x^2 dx + 2 \int_0^1 x dx + \int_0^1 dx \\
& = \frac13 + 2\frac12 + 1 \\
& = \frac73
\end{WithArrows}$


\interitem 
Almost all the options can also be set at the document level with the command \verb|\WithArrowsOptions|. 
In this case, the scope of the declarations is the current TeX group (these declarations are ``semi-global'').
For example, if we want all the environments \verb|{WithArrows}| composed in \verb|\displaystyle| with blue
arrows, we can write \verb|\WithArrowsOptions{displaystyle,tikz=blue}|.\footnote{It's also possible to give the
  options directly when loading the package, \emph{i.e.} with the command \texttt{\string\usepackage} in the preamble.}
%
\begin{Verbatim}
~emphase#\WithArrowsOptions{displaystyle,tikz=blue}@
$\begin{WithArrows}
\sum_{i=1}^n (x_i+1)^2 
& = \sum_{i=1}^n (x_i^2+2x_i+1) \Arrow{by linearity}\\
& = \sum_{i=1}^n x_i^2 + 2\sum_{i=1}^nx_i+ n
\end{WithArrows}$
\end{Verbatim}

\begin{group}
\WithArrowsOptions{displaystyle,tikz=blue}
$\begin{WithArrows}
\sum_{i=1}^n (x_i+1)^2 
& = \sum_{i=1}^n (x_i^2+2x_i+1) \Arrow{by linearity}\\
& = \sum_{i=1}^n x_i^2 + 2\sum_{i=1}^nx_i+ n
\end{WithArrows}$
\end{group}


\interitem
The command \verb|\Arrow| is recognized only in the environments \verb|{WithArrows}|. If we have a command 
\verb|\Arrow| previously defined, it's possible to go on using it outside the environments \verb|{WithArrows}|.

However, a previouly defined command \verb|\Arrow| may still be useful in a environment \verb|{WithArrows}|. If we
want to use it in such an environment, it's possible to change the name of the command \verb|\Arrow| of the package
\verb|witharrows| : there is an option \verb|CommandName| for this purpose. The new name of the command must be
given to the option \emph{without} the leading backslash.
%
\begin{Verbatim}
\def\Arrow{\longmapsto}
$\begin{WithArrows}~emphase#[CommandName=Explanation]@
f & = \bigl(x \Arrow (x+1)^2\bigr)
~emphase#\Explanation{we work directly on fonctions}@\\
& = \bigl(x \Arrow x^2+2x+1\bigr)
\end{WithArrows}$
\end{Verbatim}
%
\begin{group}
\def\Arrow{\longmapsto}
$\begin{WithArrows}[CommandName=Explanation]
f & = \bigl(x \Arrow (x+1)^2\bigr)
\Explanation{we work directly on fonctions}\\
& = \bigl(x \Arrow x^2+2x+1\bigr)
\end{WithArrows}$
\end{group}


\interitem 
It's possible to use directly the nodes created by \verb|{WithArrows}| (see below) with explicit Tikz instructions
(in order, for example, to draw something that can't be drawn with the command \verb|\Arrow|). That's why a style
for the tips of the arrows has be created : \verb|TipsOfWithArrows|. By using this style, we will have homogeneous
tips for the arrows of the document.

Therefore, if we want to  modify the tips of the arrows of \verb|{WithArrows}|, we have to modify the style
\verb|TipsOfWithArrows|. 
%
\begin{Verbatim}
\tikzset{TipsOfWithArrows/.style= { > = {Latex[scale=1.2,bend]}} }
\end{Verbatim}




\section{Precise positioning of the arrows}


The environment \verb|{WithArrows}| defines, during the composition of the array, two series of nodes materialized in
red in the following example.\footnote{The option \texttt{shownodes} can be used to materialize the nodes.}

\smallskip
$\begin{WithArrows}[displaystyle,shownodes]
I
& = \int_{\frac{\pi}4}^0 \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)(-d u) \\
& = \int_0^{\frac{\pi}4} \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)d u \\
& = \int_0^{\frac{\pi}4}\ln\left(1+\frac{1-\tan u}{1+\tan u}\right)\, d u \\
& =\int_0^{\frac{\pi}4}\ln\left(\frac{1+\tan u+1-\tan u}{1+\tan u}\right) d u \\
& =\int_0^{\frac{\pi}4} \ln\left(\frac2{1+\tan u}\right)\, d u\\
& =\int_0^{\frac{\pi}4}\bigl(\ln2-\ln(1+\tan u)\bigr)\, d u \\
& =\frac{\pi}4\ln2-\int_0^{\frac{\pi}4}\ln(1+\tan u)\, d u  \\
& =\frac{\pi}4\ln2-I 
\end{WithArrows}$

\bigskip
The nodes of the left are at the end of each line of text. These nodes will be called \emph{left nodes}.
The nodes of the right side are aligned vertically on the right side of the array. These nodes will be called
\emph{right nodes}.\footnote{The names of the Tikz nodes created by \texttt{\{WithArrows\}} are \texttt{wa-}$n$\texttt{-l} and
  \texttt{wa-}$n$\texttt{-r} where $n$~is the number of the line. It's possible to refer to these Tikz nodes after the
  environment (one should use the options \texttt{remember picture} and \texttt{overlay} and also
  \texttt{TipsOfWithArrows} and \texttt{->} in order to have the same arrowheads).}

By default, the arrows use the right nodes. We will say that they are in \verb|rr| mode ($r$ for \emph{right}).
These arrows are \verb|vertical| (we will say that an arrow is \emph{vertical} when its two ends have the
same abscissa).


\smallskip
However, it's possible to use the left nodes, or a combination of left and right nodes, with one of the options
\verb|lr|, \verb|rl| and \verb|ll| ($l$ for \emph{left}). Those arrows are, usually, not vertical.


Therefore
$\begin{WithArrows}[displaystyle]
I
& = \int_{\frac{\pi}4}^0 \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)(-d u) 
\Arrow[lr]{This arrow uses the \texttt{lr} option.}\\
& = \int_0^{\frac{\pi}4} \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)d u \\
& = \int_0^{\frac{\pi}4}\ln\left(1+\frac{1-\tan u}{1+\tan u}\right)\, d u \\
& =\int_0^{\frac{\pi}4}\ln\left(\frac{1+\tan u+1-\tan u}{1+\tan u}\right) d u 
\Arrow[ll,jump=2,tikz={text width = 5cm}]{This arrow uses a \texttt{ll} option and a \texttt{jump} equal to $2$}\\
& =\int_0^{\frac{\pi}4} \ln\left(\frac2{1+\tan u}\right)\, d u\\
& =\int_0^{\frac{\pi}4}\bigl(\ln2-\ln(1+\tan u)\bigr)\, d u \\
& =\frac{\pi}4\ln2-\int_0^{\frac{\pi}4}\ln(1+\tan u)\, d u  \\
& =\frac{\pi}4\ln2-I 
\end{WithArrows}$



\interitem
There is also an option called \texttt{i} ($i$ for \emph{intermediate}). With this option, the arrow is vertical
and at the leftmost position.

%
\begin{Verbatim}
$\begin{WithArrows}
(a+b)(a+ib)(a-b)(a-ib) 
& = (a+b)(a-b)\cdot(a+ib)(a-ib) \\
& = (a^2-b^2)(a^2+b^2) \Arrow~emphase#[i]@{because $(x-y)(x+y)=x^2-y^2$}\\
& = a^4-b^4 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
(a+b)(a+ib)(a-b)(a-ib) 
& = (a+b)(a-b)\cdot(a+ib)(a-ib) \\
& = (a^2-b^2)(a^2+b^2) \Arrow[i]{because $(x-y)(x+y)=x^2-y^2$}\\
& = a^4-b^4 
\end{WithArrows}$


\interitem 
The environment \verb|{WithArrows}| gives also a \verb|group| option. With this option, \emph{all} the
arrows of the environment are grouped on a same vertical line and at a leftmost position.
%
\begin{Verbatim}[formatcom=\small\color{gray}]
$\begin{WithArrows}~emphase#[displaystyle,group]@
2xy'-3y=\sqrt x
& \Longleftrightarrow 2x(K'y_0+Ky_0')-3Ky_0 = \sqrt x \\
& \Longleftrightarrow 2xK'y_0 + K(2xy_0'-3y_0) = \sqrt x \\
& \Longleftrightarrow 2x K'y_0 = \sqrt x \Arrow{...}\\
...
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}[displaystyle,group]
2xy'-3y=\sqrt x
& \Longleftrightarrow 2x(K'y_0+Ky_0')-3Ky_0 = \sqrt x \\
& \Longleftrightarrow 2xK'y_0 + K(2xy_0'-3y_0) = \sqrt x \\
& \Longleftrightarrow 2x K'y_0 = \sqrt x \Arrow{We remplace $y_0$ by its value.}\\
& \Longleftrightarrow 2xK'x^{\frac32} = x^{\frac12} \Arrow{simplification of the $x$}\\
& \Longleftrightarrow K' = \tfrac1{2x²} \Arrow{antiderivation}\\
& \Longleftrightarrow K = -\tfrac1{2x} 
\end{WithArrows}$


\bigskip
If desired, the option \verb|group| can be given to the command \verb|WithArrowsOptions| so that it will become the
default value.


\section{Comparison with the environment \{aligned\}}



\verb|{WithArrows}| bears similarities with the environment \verb|{aligned}| of the extension
\verb|amsmath|. These are only similarities because \verb|{WithArrows}| has not been written upon the environment
\verb|{aligned}|. 

In paticular, the command \verb|\\| of the end of line has no option to change the row spacings. In fact, this
command \verb|\\| can be replaced, in a environment \verb|{WithArrows}| by a \verb|\cr| of TeX. That's what we will 
do in the balance of this document.




\interitem
If desired, it's possible to change the spacing between two given lines by putting a command
\verb|\vspace| in a \verb|\noalign| (which is a low level command of TeX to insert extraordinary elements between
the lines of an array).
%
\begin{Verbatim}
$\begin{WithArrows}
A & = (a+1)^2 \Arrow{we expand} \cr
~emphase#\noalign{\vspace{3mm}}@
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
A & = (a+1)^2 \Arrow{we expand} \cr
\noalign{\vspace{3mm}}
  & = a^2 + 2a + 1 
\end{WithArrows}$


\interitem 
In the  environments of \verb|amsmath|, the spacing between lines is fixed by a parameter called
\verb|\jot| and that's also the case for the environment \verb|{WithArrows}|. An option \verb|jot| has been given
to the environment \verb|{WithArrows}| in order to change the value of this parameter \verb|\jot| for an given environment.
%
\begin{Verbatim}
$\begin{WithArrows}[displaystyle,~emphase#jot=2mm@]
F & = \frac12G     \Arrow{we expand}\cr
  & = H + \frac12K \Arrow{we go on}\cr
  & = K 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}[displaystyle,jot=2mm]
F & = \frac12G     \Arrow{we expand}\cr
  & = H + \frac12K \Arrow{we go on}\cr
  & = K 
\end{WithArrows}$


\interitem
Like the environment \verb|{aligned}|, \verb|{WithArrows}| has an option of placement which can assume the values
\verb|t|, \verb|c| or \verb|b|. However, the default value is not \verb|c| but \verb|t|. If desired, it's possible
to have the \verb|c| value as the default with the command \verb|WithArrowsOptions{c}| at the beginning of the document.
%
\begin{Verbatim}
~emphase#Et donc\enskip@
$\begin{WithArrows}
A & = (a+1)^2 \Arrow{we expand} \cr
  & = a^2 + 2a + 1 
\end{WithArrows}$
\end{Verbatim}

Et donc\enskip 
$\begin{WithArrows}
A & = (a+1)^2 \Arrow{we expand} \cr
  & = a^2 + 2a + 1 
\end{WithArrows}$

\bigskip
The value \verb|c| may be useful, for example, if we want to add curly braces :

\smallskip
\begin{Verbatim}
On pose\enskip $~emphase#\left\{@
\begin{WithArrows}~emphase#[c]@
f(x) & = 3x^3+2x^2-x+4 
\Arrow[tikz=-]{both are polynoms}\cr
g(x) & = 5x^2-5x+6
\end{WithArrows}
~emphase#\right.@$
\end{Verbatim}




On pose\enskip $\left\{
\begin{WithArrows}[c]
f(x) & = 3x^3+2x^2-x+4 
\Arrow[tikz=-]{both are polynoms}\cr
g(x) & = 5x^2-5x+6
\end{WithArrows}
\right.$


\interitem
Unlike \verb|{aligned}|, the environment \verb|{WithArrows}| uses \verb|\textstyle| by default.

Once again, it's possible to change this behaviour with \verb|WithArrowsOptions| :

\quad \verb|WithArrowsOptions{displaystyle}|.


\smallskip
The following example is composed with \verb|{aligned}| :\par\nobreak

\smallskip
$\left\{
\begin{aligned}
\sum_{i=1}^n (x_i+1)^2  
& = \sum_{i=1}^n (x_i^2 + 2x_i+1) \\
& = \sum_{i=1}^n x_i^2 + 2 \sum_{i=1}^nx_i + n 
\end{aligned}
\right.$%


\medskip
The following is composed with \verb|{WithArrows}[c,displaystyle]|. The results are stricly identical.\par\nobreak

\smallskip
$\left\{
\begin{WithArrows}[c,displaystyle]
\sum_{i=1}^n (x_i+1)^2 
& = \sum_{i=1}^n (x_i^2 + 2x_i+1) \\
& = \sum_{i=1}^n x_i^2 + 2 \sum_{i=1}^nx_i + n 
\end{WithArrows}
\right.$%




\section{Examples}

It's possible to use the environment \verb|{WithArrows}| with making use of the left column only, or the right
column only. 
%
\begin{Verbatim}
$\begin{WithArrows}
&f(x) \ge g(x) \Arrow{by squaring both sides} \cr
& f(x)^2 \ge g(x)^2 \Arrow{by moving to left side} \cr
& f(x)^2 - g(x)^2 \ge 0 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}
&f(x) \ge g(x) \Arrow{by squaring both sides} \cr
& f(x)^2 \ge g(x)^2 \Arrow{by moving to left side} \cr
& f(x)^2 - g(x)^2 \ge 0 
\end{WithArrows}$


\interitem
Here is an example with a loop flow.
%
\begin{Verbatim}[formatcom=\small\color{gray}]
$\begin{WithArrows}[tikz={font={\tiny}}]
a.\;& f \text{ est continuous on } E 
\Arrow{(1)}\Arrow[tikz=<-,jump=4,xoffset=1cm]{(5)}\cr
b.\;& f \text{ est continuous in } 0 
\Arrow{(2)}\cr
c.\;& f \text{ is bounded on the unit sphere} 
\Arrow{(3)}\cr
d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\| 
\Arrow{(4)}\cr
e.\;& f \text{ is lipschitzian} 
\end{WithArrows}$
\end{Verbatim}

$\begin{WithArrows}[tikz={font={\tiny}}]
a.\;& f \text{ est continuous on } E 
\Arrow{(1)}\Arrow[tikz=<-,jump=4,xoffset=1cm]{(5)}\cr
b.\;& f \text{ est continuous in } 0 
\Arrow{(2)}\cr
c.\;& f \text{ is bounded on the unit sphere} 
\Arrow{(3)}\cr
d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\| 
\Arrow{(4)}\cr
e.\;& f \text{ is lipschitzian} 
\end{WithArrows}$

\interitem
The option \verb|font| of Tikz contains in fact a list of tokens which will be placed at the beginning of the text.

These tokens can be true commands for a changement of font (like \verb|\bfseries| or \verb|\sffamily|) but can also
be, in fact, any TeX command.

In the following example, the argument of \verb|font| is the token list \verb|\tiny\counter| where
\verb|\counter| is a command which increment a counter previously defined and display its new value. Thus, the
arrows are automatically numbered.
%
\begin{Verbatim}[formatcom=\small\color{gray}]
\newcounter{MyCounter}
\newcommand{\counter}{\stepcounter{MyCounter}\theMyCounter.}
$\begin{WithArrows}[tikz={~emphase#font={\tiny\counter}@}]
A(x) 
& = B(x) \Arrow{} \cr
& = C(x) \Arrow{} \cr
& = C(x) \Arrow{} \cr
& = E(x) \Arrow{} \cr
& = F(x) \Arrow{} \cr
& = G(x)   
\end{WithArrows}$
\end{Verbatim}

\begin{group}
\newcounter{MyCounter}
\newcommand{\counter}{\stepcounter{MyCounter}\theMyCounter.}
$\begin{WithArrows}[tikz={font={\tiny\counter}}]
A(x) 
& = B(x) \Arrow{} \cr
& = C(x) \Arrow{} \cr
& = C(x) \Arrow{} \cr
& = E(x) \Arrow{} \cr
& = F(x) \Arrow{} \cr
& = G(x)   
\end{WithArrows}$
\end{group}



\end{document}