-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatexgit.dtx
executable file
·1243 lines (1242 loc) · 55.5 KB
/
latexgit.dtx
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
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% Copyright (C) 2023--2024 by Thomas Weise <http://iao.hfuu.edu.cn/5>
%
% This file may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, either version 1.3 of this license or
% (at your option) any later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt.
% The license can be found at
% https://thomasweise.github.io/latexgit_tex/LICENSE.html.
% This work is author-maintained, i.e., it can only be maintained by
% Thomas Weise.
%
% \fi
%
% \iffalse
%
%<*driver>
\ProvidesFile{latexgit.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]%
%<package>\ProvidesPackage{latexgit}[2024/09/20 0.8.6 Documentation for the Case of Virtual Environments.]%
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{latexgit}[2024/09/20]
%
\usepackage{xcolor}%
\usepackage[%
colorlinks,%
breaklinks=true,%
urlcolor={blue!80!black},%
menucolor=black,%
linkcolor={red!50!black},%
bookmarks=true,%
bookmarksopen=false,%
hyperfootnotes=true,%
citecolor={blue!50!black},%
filecolor=black,%
pdfkeywords={LaTeX, package, latexgit}
]{hyperref}%
\usepackage{breakurl}%
\usepackage[square,numbers,comma,sort&compress]{natbib}%
%
\newcommand{\exampleautorefname}{Example}%
\renewcommand{\sectionautorefname}{Section}%
\renewcommand{\subsectionautorefname}{Section}%
\renewcommand{\subsubsectionautorefname}{Section}%
\usepackage{verbatim}%
\usepackage{graphicx}%
\usepackage{subcaption}%
\usepackage{afterpage}%
%
\usepackage{listings}%
\lstset{%
language=[LaTeX]TeX,%
basicstyle=\small,%
keywordstyle=\ttfamily\color{teal!90!black}\bfseries,%
morekeywords={url,verbatiminput,lstset,lstinputlisting},
classoffset=1,morekeywords={gitLoad,gitFile,gitUrl},keywordstyle=\ttfamily\bfseries\color{red!70!black},classoffset=0,%
identifierstyle=,%
commentstyle=\color{gray}\footnotesize,%
stringstyle=\ttfamily\color{red!90!black}, % typewriter type for string
numbers=left,%
numberstyle=\tiny,%
columns=fullflexible,%
frame=shadowbox,%
frameround=tttt,%
backgroundcolor=\color{black!10!yellow!5!white},%
literate=%
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1%
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1%
{à}{{\`a}}1 {è}{{\'e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1%
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1%
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1%
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1%
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1%
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1%
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1%
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1%
{€}{{\EUR}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1%
{»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1%
{…}{{\ldots}}1 {≥}{{>=}}1 {≤}{{<=}}1 {„}{{\glqq}}1 {“}{{\grqq}}1%
{”}{{''}}1%
{α}{{$\alpha$}}1 {β}{{$\beta$}}1 {γ}{{$\gamma$}}1 {δ}{{$\delta$}}1%
{ε}{{$\epsilon$}}1 {ζ}{{$\zeta$}}1 {η}{{$\eta$}}1 {θ}{{$\theta$}}1%
{ι}{{$\iota$}}1 {κ}{{$\kappa$}}1 {λ}{{$\lambda$}}1 {μ}{{$\mu$}}1%
{ν}{{$\nu$}}1 {ξ}{{$\xi$}}1 {ο}{{o}}1 {π}{{$\pi$}}1 {ρ}{{$\rho$}}1%
{σ}{{$\sigma$}}1 {τ}{{$\tau$}}1 {υ}{{$\upsilon$}}1 {φ}{{$\phi$}}1%
{χ}{{$\chi$}}1 {ψ}{{$\psi$}}1 {ω}{{$\omega$}}1 {Α}{{A}}1 {Β}{{B}}1%
{Γ}{{$\Gamma$}}1 {Δ}{{$\Delta$}}1 {Ε}{{E}}1 {Ζ}{{Z}}1 {Η}{{H}}1%
{Θ}{{$\Theta$}}1 {Ι}{{I}}1 {Κ}{{K}}1 {Λ}{{$\Lambda$}}1 {Μ}{{M}}1%
{Ν}{{N}}1 {Ξ}{{$\Xi$}}1 {Ο}{{O}}1 {Π}{{$\Pi$}}1 {Ρ}{{P}}1%
{Σ}{{$\Sigma$}}1 {Τ}{{T}}1 {Υ}{{Y}}1 {Φ}{{$\Phi$}}1 {Χ}{{X}}1%
{Ψ}{{$\Psi$}}1 {Ω}{{$\Omega$}}1%
{∖}{{$\setminus$}}1 {∪}{{$\cup$}}1 {∩}{{$\cap$}}1%
{≈}{{$\approx$}}1 {∈}{{$\in$}}1 {∉}{{$\notin$}}1%
}%
%
%
\gdef\tindex#1{\expandafter\index{#1}}%
\gdef\tbindex#1{\expandafter\index{\textbackslash#1}}%
%
\usepackage{placeins}%
%
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%
%
\begin{document}
\DocInput{latexgit.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \changes{0.8.0}{2023/12/04}{the initial draft version}
% \changes{0.8.1}{2023/12/05}{slightly improved documentation}
% \changes{0.8.2}{2023/12/05}{improved latexgit.tds.zip}
% \changes{0.8.3}{2024/08/01}{supporting arbitrary commands via the new latexgit\_py version}
% \changes{0.8.4}{2024/08/02}{improved build process}
% \changes{0.8.5}{2024/08/07}{improved examples: added an example with multiple git command results}
% \changes{0.8.6}{2024/09/20}{the use case of virtual environments in conjunction with the latexgit Python package of version 0.8.17 or greater is documented}
%
% \GetFileInfo{latexgit.dtx}
%
% \DoNotIndex{\def,\if,\fi}
%
% \title{The \textsf{latexgit} Package}
% \author{Thomas Weise\\%
% \resizebox{0.95\textwidth}{!}{%
% \parbox{\linewidth}{%
% \centering%
% Institute of Applied Optimization\\%
% School of Artificial Intelligence and Big Data\\%
% Hefei University, Hefei 230601, Anhui, China\\%
% \href{mailto:[email protected]}{[email protected]} $\cdot$ \href{mailto:[email protected]}{[email protected]}%
% }}}%
% \date{\today}
%
% \renewcommand{\textfraction}{0.05}%
% \renewcommand{\topfraction}{0.85}%
% \renewcommand{\bottomfraction}{0.95}%
% \renewcommand{\floatpagefraction}{0.95}%
%
% \maketitle
%
% \begin{abstract}
% This \LaTeX\ package works in combination with the Python package
% |latexgit|.
% It offers the command |\gitLoad|\tbindex{gitLoad}, which can load a file
% from a |git|\tindex{git} repository, optionally post-process it, and then
% provide a local path to the file as macro |\gitFile|\tbindex{gitFile} and
% the URL to the original file in |\gitUrl|\tbindex{gitUrl}.
% Using the |\gitFile| macro, you can then include the file in \LaTeX\
% directly or load it as source code listing.
% It also offers the command |\gitExec|\tbindex{gitExec}, which can execute
% an arbitrary command, either in the current directory or inside a directory
% of a |git|\tindex{git} repository and fetch the standard output into a
% local file, the path to which is made available to the file again as macro
% |\gitFile|\tbindex{gitFile} and the URL to the repository in which the
% command was executed becomes |\gitUrl|\tbindex{gitUrl}.
% The functionality is implemented by storing the |git| requests in the
% |aux|\tindex{aux} file of the project during the first
% |pdflatex|\tindex{pdflatex} pass.
% The |aux| file is then processed by the Python package which performs the
% actual git queries, stores the result in local files, and adds the resolved
% paths to the |aux| file.
% During the first |pdflatex|\tindex{pdflatex} run, |\gitFile| and |\gitUrl|
% offer dummy results.
% However, after the resolution via the Python package, in the second
% |pdflatex| run they then point to the right data.
% \end{abstract}
%
% \setcounter{tocdepth}{2}
% \tableofcontents
%
% \section{Introduction}%
%
% \subsection{Addressed Problem and Use Case}%
% Let's say you want to make teaching material in the field of computer
% science.
% In a wide variety of computer science fields, you may want to include source
% code examples in your lecture script or slides.
% The standard way is to either write some pseudo-code or program-like
% snippets.
% Usually these neither compile nor are they maintained well and they are
% often riddled with mistakes.
% That is not nice.
%
% What we want is to have snippets of ``real'' code.
% Code that we can compile, unit test, and run.
% Now such code naturally would not be sprinkled into our \LaTeX\ teaching
% material sources.
% That would be a mess to organize and maintain.
%
% A natural location for source code examples is a separate |git| repository.
% Maybe on GitHub, maybe somewhere else.
% If I wanted to do a lecture on, say, optimization algorithms, I would like to
% have the optimization algorithms
% \href{https://thomasweise.github.io/moptipy}{implemented in an actual useful fashion}.
% I would put them into a repository where I can build and test these real
% codes as a complete and separate piece of work.
%
% Then I want to use them in my lecture scripts (written in \LaTeX) as well.
% However, I do not want to \emph{copy} them there.
% I want that my lecture scripts directly reference the |git| repository with
% the real code.
% I want them to ``include'' the examples from there.
% If I change the code in the |git| repository and then re-compile my
% teaching material, these changes should automatically be reflected there.
%
% That is the use case we tackle here.
% We offer a solution to the question
%
% \begin{quote}
% \emph{``How can we include snippets of code from a separate, complex code basis
% (located in a |git| repository) into our \LaTeX\ documents?''}
% \end{quote}
%
% Additionally, sometimes we want to execute the code from that repository and
% capture the standard output. This output could then be displayed as listing
% next to the code. This package also provides this functionality.
%
% \subsection{Provided Functionality}%
% \label{sec:functionality}%
% It does so by offering a combination of a \LaTeX\ package (this package
% here) and a Python\index{Python} program (published at
% \url{https://pypi.org/projects/latexgit}).
% This \LaTeX\ provides the command |\gitLoad| that can load a specific file
% (its second argument) from a specific |git| repository (its first argument)
% and, optionally, pipe the file contents through a program for
% post-processing (the third argument, which can be left empty).
% It also provides the command |\gitExec|, which, too, has three arguments.
% This time, the first two arguments (the git repository URL and the path to
% a directory inside the repository in which the command should be executed)
% can be left empty. The third argument, however, is the command line to be
% executed whose standard output should be fetched.
% Both types of requests are stored in the |aux| file during the first
% |pdflatex| pass, then resolved by the Python program, and their results
% become available in the second |pdflatex| pass via the commands |\gitFile|
% and |\gitUrl|.
%
% \section{Usage}%
% Using the package requires the following steps:
% \begin{enumerate}%
%%
% \item Obviously, both the
% \href{https://thomasweise.github.io/latexgit_tex}{\LaTeX\ package}
% \emph{and} its
% \href{https://thomasweise.github.io/latexgit_py}{Python companion}
% package must be installed (see \autoref{sec:installation}).
%%
% \item In your document, you need to load the package in the preamble
% (see \autoref{sec:loadThePackage}).%
%%
% \item Then you can make |git| queries and using the paths to files holding
% their results (see \autoref{sec:gitquery}).
%%
% \item Finally, the Python package can carry them out after the first
% |pdflatex| run and in the next |pdflatex| run, |\gitFile| and |\gitUrl| are
% defined appropriately, see \autoref{sec:pythonProgram}.
% \end{enumerate}
%
% If your \LaTeX\ document is called |article.tex|, then you have at least the
% following workflow:%
% \begin{quote}
% |pdflatex article|\\
% |python3 -m latexgit.aux article|\\
% |pdflatex article|
% \end{quote}
%
% Comprehensive examples are provided in \autoref{sec:examples}.
%
% \subsection{Installation}%
% \label{sec:installation}%
%
% \subsubsection{\LaTeX\ Package}%
% First, make sure that you have the |latexgit.sty| either installed or inside
% your document's directory.
% For this, there are several options:%
% \begin{enumerate}%
% \item You can just download the file from
% \url{https://thomasweise.github.io/latexgit_tex/latexgit.sty} directly.
% You can now copy it into the folder of your document.
%%
% \item You can download |latexgit.dtx|\tindex{latexgit.dtx} and
% |latexgit.ins|\tindex{latexgit.ins} from
% \url{https://thomasweise.github.io/latexgit_tex/latexgit.dtx} and
% \url{https://thomasweise.github.io/latexgit_tex/latexgit.ins}.
% You can then execute
% \begin{quote}%
% |pdflatex latexgit.ins|\tindex{pdflatex}
% \end{quote}%
% and you should get the style file |latexgit.sty|\tindex{latexgit.sty}.
% You can now copy it into the folder of your document.
%%
% \item Or you can download the |latexgit.tds.zip| file from
% \url{https://thomasweise.github.io/latexgit_tex/latexgit.tds.zip} and
% unpack it into your \TeX\ tree.
% If you know what that is.
% \end{enumerate}%
%
% \subsubsection{Python Package}%
% \label{sec:latexgitpy}%
% The Python\index{Python} package is available at
% \url{https://github.com/thomasWeise/latexgit_py}\index{latexgit\_py},
% \url{https://thomasweise.github.io/latexgit_py}, and
% \url{https://pypi.org/project/latexgit}.
% You can most easily install it from PyPI\index{PyPI} by doing
% \begin{quote}
% |pip install latexgit|
% \end{quote}
%
% \subsection{Loading the Package}%
% \label{sec:loadThePackage}%
% Load this package using%
% \begin{quote}
% |\usepackage{latexgit}|
% \end{quote}
% \begin{sloppypar}%
% The package has no options or parameters.
% Loading it will automatically load the packages
% |alphalph|\index{alphalph} and |filecontents|\index{filecontents} as well,
% see \autoref{sec:implementation}.
% \end{sloppypar}%
%
% \subsection{Querying a File from a git Repository}%
% \label{sec:gitquery}%
% To query a file stored at path |path| inside from a |git|\tindex{git}
% repository available under URL |repositoryURL|, you would specify the
% command
% \begin{quote}
% |\gitLoad{repositoryURL}{path}{}|\tbindex{gitLoad}
% \end{quote}
% After this command is executed, a local path to the file becomes available
% in the fully-expandable command |\gitFile|\tbindex{gitFile}.
% The full URL to the file in the |git| repository, including the current
% commit id, becomes available in the fully-expandable command
% |\gitUrl|\tbindex{gitUrl}.
% Both |\gitFile| and |\gitUrl| will be overwritten every time |\gitLoad| or
% |\gitExec| (see later) are invoked.
% You can invoke |\gitLoad| any number of times.
%
% The third parameter, left empty in the above example, can specify an
% optional post-processing commend.
% If it is not left empty, this command will be executed in the
% shell\index{shell}.
% The contents of the file loaded from the |git| repository will be piped to
% the |stdin|\tindex{stdin} of the command.
% The |stdout|\tindex{stdout} of the command will be piped to a file and
% |\gitFile|\tbindex{gitFile} will then contain the path to this file
% instead.
% For example, under Linux\index{Linux}, you could use the
% \href{https://www.man7.org/linux/man-pages/man1/head.1.html}{|head|}\index{head}
% command to return only the first 5~lines of a file as follows:
% \begin{quote}
% |\gitLoad{repositoryURL}{path}{head -n 5}|\tbindex{gitLoad}
% \end{quote}
%
% \subsection{Executing a Command (optionally inside a git Repository}%
% \label{sec:gitexec}%
% Sometimes, we want to execute a program and fetch its standard output.
% \begin{quote}
% |\gitExec{repositoryURL}{path}{theCommand}|\tbindex{gitExec}
% \end{quote}
% The most common use case of our package is that you want to execute a
% program which is part of a |git| repository.
% In this case, you would put the URL of the repository in |repositoryURL|
% and the relative path to the directory inside the repository in which the
% command should be invoked as |path|.
% If you want to invoke the command in the root folder of the repository,
% put |.| as |path|.
% The |theCommand| then holds the command line to be executed.
% \emph{Notice:}~You can also leave \emph{both} |repositoryURL| and
% |path| blank.
% In this case, the command is executed in the current folder.
% (The use case for this is to fetch the output of stuff like
% |python3 --version|.)
% Anyway, after this command is executed, a local path to the file with the
% captured standard output becomes available in the fully-expandable command
% |\gitFile|\tbindex{gitFile}.
% If the command was executed in a |git| repository, then the URL to the |git|
% repository becomes available in the fully-expandable command
% |\gitUrl|\tbindex{gitUrl} (otherwise, this command expands to the empty
% string).
% Both |\gitFile| and |\gitUrl| will be overwritten every time |\gitLoad| or
% |\gitExec| are invoked.
% You can invoke |\gitLoad| any number of times.
%
% \subsection{Executing the Python Package}
% \label{sec:pythonProgram}
% \begin{sloppypar}%
% During the first |pdflatex|\tindex{pdflatex} run, |\gitFile| points to an
% empty dummy file
% (|\jobname.latexgit.dummy|)\tbindex{jobname.latexgit.dummy} and
% |\gitUrl| points to |http://example.com|\index{http://example.com}.
% Both commands will only expand to useful information if the Python package
% |latexgit| is applied to the project's |aux| file.
% This works very similar to \BibTeX.
% If the name of your \TeX\ file is |myfile.tex|, then you would execute
% \end{sloppypar}%
% \begin{quote}
% |python3 -m latexgit.aux myfile|
% \end{quote}
% More specifically, the Python package processes the |aux| files, so for a
% specific |aux|\tindex{aux} file |myfile.aux|, you could also do:
% \begin{quote}
% |python3 -m latexgit.aux myfile.aux|
% \end{quote}
%
% After this, in the next pass of |pdflatex|, |\gitFile| and |\gitUrl| will
% contain the right paths and URLs.
%
% \subsection{A Note on Virtual Environments}%
% The following only applies if you have installed this package inside a virtual
% environment. It also only applies in conjunction with version
% \href{https://pypi.org/project/latexgit/0.8.17/}{0.8.17} or newer of the latexgit
% Python package.
%
% If you are running this package inside a virtual environment, it is important
% that you create this environment using the |--copies| setting and \emph{not} using
% the (default) |--symlinks| parameter.
% In other words, you should have created the virtual environment as follows,
% where |venvDir| is the directory inside of which the virtual environment is
% created.
%
% \begin{center}
% |python3 -m venv --copies venvDir|
% \end{center}
%
% If you create the environment like this (and activated), then our package will
% automatically pick it up and use its Python interpreter for any invocation of
% |python3| or |python3.x| (where |x| is the minor version of the interpreter).
% If you use the |--symlinks| parameter to create the environment, then invocations
% of the Python interpreter from our package may instead result in the system's
% Python interpreter.
%
% \section{Provided Macros}\label{sec:providedMacros}%
%
% Here we discuss the macros that can directly be accessed by the user to
% make use of the functionality of the |latexgit| package.
% The implementation of these macros is given in \autoref{sec:implementation}
% and several examples can be found in \autoref{sec:examples}.
%
% \DescribeMacro{\gitLoad}%
% The macro |\gitLoad|\marg{repositoryURL}\marg{path}\marg{postProcessing}
% provides a local path to a file from a |git| repository.
% \begin{itemize}%
% \item[\marg{repositoryURL}] is the URL of the |git| repository.
% It could, e.g., be \url{https://github.com/thomasWeise/latexgit\_tex} or
% \url{ssh://[email protected]/thomasWeise/latexgit\_tex} or any other valid
% repository URL.%
%
% \item[\marg{path}] is then the path to the file within the repository.
% This could be, for example, |latex/latexgit.dtx|.%
%
% \item[\marg{postProcessing}] Can either be empty, in which case the
% repository is downloaded and the the local path to the file is returned.
% It can also be shell command, e.g., |head -n 5|.
% In this case, the contents of the file are piped to |stdin|\tindex{stdin} of
% the command and the text written to the |stdout|\tindex{stdout} by the
% command is stored in a file whose path is returned.
% \end{itemize}%
%
% After invoking this command, two new commands will be defined:%
% \begin{itemize}%
% \item[\texttt{{\textbackslash}gitFile}] returns the path to the file
% that was loaded and/or post-processed.%
% \item[\texttt{{\textbackslash}gitUrl}] returns the full URL to the
% file in the |git| repository
% online.
% This command works for GitHub, but it may not provide the correct URL for
% other repository types.%
% \end{itemize}%
%
% \DescribeMacro{\gitExec}%
% The macro |\gitExec|\marg{repositoryURL}\marg{path}\marg{theCommand}
% provides a local path to a file containing the captures standard output
% of a command (that may have been executed inside a directory inside a
% |git| repository).
% \begin{itemize}%
% \item[\marg{repositoryURL}] is the URL of the |git| repository.
% It could, e.g., be \url{https://github.com/thomasWeise/latexgit\_tex} or
% \url{ssh://[email protected]/thomasWeise/latexgit\_tex} or any other valid
% repository URL.
% You can also leave this parameter empty if no |git| repository should
% be used.%
%
% \item[\marg{path}] is the path to a directory within the repository.
% This could be, for example, |latex| or |.|.
% If |path| is provided, then this will be the working directory where
% the command is executed.
% If you want to execute a command in the root directory of a |git|
% repository, you can put |.| here.
%
% \item[\marg{theCommand}] This is the command which should be executed.
% If |repositoryURL| and |path| are provided, then the repository will be
% downloaded and |path| will be resolved relative to the repository root
% directory. |theCommand| will then be executed in this directory.
% If neither |repositoryURL| nor |path| are provided, |theCommand| is
% executed in the current directory.
% Either way, its |stdout|\tindex{stdout} is captured in a file whose path
% is returned.
% \end{itemize}%
%
% After invoking this command, two new commands will be defined:%
% \begin{itemize}%
% \item[\texttt{{\textbackslash}gitFile}] returns the path to the file
% in which the standard output is stored.%
% \item[\texttt{{\textbackslash}gitUrl}] returns the full URL to the |git|
% repository, if any was specified, or the empty string otherwise.
% online.
% This command works for GitHub, but it may not provide the correct URL for
% other repository types.%
% \end{itemize}%
%
% \DescribeMacro{\gitFile}%
% The macro |\gitFile| returns the path to the file with the contents of the
% latest |\gitLoad| or |\gitExec| request.
% During the first |pdflatex| pass, this will be the path to a dummy file.
% After the Python package has been applied to the |aux| file, then |\gitFile|
% will point to the proper file during the next |pdflatex| pass.
%
%
% \DescribeMacro{\gitUrl}%
% The macro |\gitUrl| returns the URL from which the file corresponding to
% the latest |\gitLoad| request was downloaded.
% Alternatively, it returns the URL of the |git| repository of the last
% |\gitExec| invocation.
% This command is designed to work with GitHub.
% It will be the repository URL combine with the path of the file inside the
% repository and the commit has code.
% The Url thus points to the exact same version of the file that was
% downloaded (and optionally post-processed).
%
% During the first |pdflatex| pass, this will be \url{https://example.com}.
% After the Python package has been applied to the |aux| file, then
% |\gitUrl| will point to the proper file during the next |pdflatex| pass.
%
% \subsection{Examples}\label{sec:examples}%
%
% Here we provide a set of examples for the use of the package.
% Each example demonstrates another facet of the package and, at the same
% time, serves as test case.
% The first example given in \autoref{sec:example_1} is a Minimal Working
% Example, i.e., just provides the barest bones.
% It shows you how to import a single file from a |git| repository.
% The second example in \autoref{sec:example_2} shows you how to import
% multiple different files from different repositories (which equates to just
% using the same command multiple times) and how to use post-processors.
% The third example in \autoref{sec:example_3} shows how to create
% beautiful (to my standards) listings by including code from a |git|
% repository, post-processing it, and loading it as a |listing|.
% Finally, the fourth example in \autoref{sec:example_4} shows that you can
% also define macros for your favorite repository and post-processors to have
% a more convenient way to import files from |git|.
%
% \subsection{Minimal Working Example}%
% \label{sec:example_1}%
% This minimal working example shows how to load a file from a |git|
% repository and directly |\input|\expandafter\tbindex{input} its contents.
% The result can be seen in \autoref{ex:example_2:res}.
%
% \lstinputlisting[classoffset=2,morekeywords={A,B,C,D},keywordstyle=\ttfamily\bfseries\color{blue!90!black},classoffset=0,float,label=ex:example_1,caption={A minimal working example for using the \texttt{latexgit} package, rendered as \autoref{ex:example_1:res}. The contents of \texttt{dummy.tex} are shown in \autoref{ex:dummy_tex}.}]{examples/example_1.tex}%
%
% As you can see in \autoref{ex:example_1}, we first load the package
% |latexgit| in line~2.
% Inside the document, we define a |git| request via the |\gitLoad| command.
% This command takes the URL of a |git| repository as first parameter.
% in this case, this is \url{https://github.com/thomasWeise/latexgit_tex},
% which happens to be the URL where you can find the repository of this
% package on GitHub.
% The second parameter is a path to the file in this repository relative to
% the repository root.
% In this case, this is the path to the file |examples/dummy.tex|, whose
% contents you can find in \autoref{ex:dummy_tex}.
%
% \lstinputlisting[float,label=ex:dummy_tex,caption={The contents of the file \texttt{dummy.tex} included from \texttt{git} in \autoref{ex:example_1}.}]{examples/dummy.tex}%
%
% The third parameter shall be ignored for now.
%
% After defining the request, we can now use two commands, |\gitFile| and
% |\gitUrl|.
% In this Minimal Working Example, we shall only consider the first one.
% This command expands to a local path of a file with the contents downloaded
% from the |git| repository.
%
% Well, during the first \LaTeX\ or |pdflatex| run, it just points to a dummy
% file with the name |\jobname.latexgit.dummy|, where
% |\jobname|\tbindex{jobname} evaluates to the name of the main \LaTeX\
% document, say |article| for |article.tex|.
% At that point, the dummy file's content is a single space character followed
% by a newline.
%
% After the first |pdflatex| pass, you can apply the Python\index{Python}
% processor (see \autoref{sec:latexgitpy}) as follows:
% \begin{quote}%
% |python3 -m latexgit.aux jobname|
% \end{quote}%
% Where |jobname| shall be replaced with the main file name, again |article|
% for |article.tex|, for instance.
%
% This command then downloads the file from |git| and puts it into a path that
% can locally accessed by \LaTeX.
% Usually, it will create a folder |__git__|\tindex{\_\_git\_\_} in your
% project's directory and place the file there.
%
% Anyway, during the second \LaTeX\ or |pdflatex| pass, |\gitFile| points to a
% valid file path with actual contents.
% By doing |\input{\gitFile}|\tbindex{input}, we here include this file
% (remember, its contents are given in \autoref{ex:dummy_tex}) as if it was
% part of our normal \LaTeX\ project.
% The result of this pass is shown in \autoref{ex:example_1:res}.
%
% If this example was stored as |example_1.tex|, then it could be built via
% \begin{quote}
% |pdflatex example_1|\\
% |python3 -m latexgit.aux example_1|\\
% |pdflatex example_1|
% \end{quote}
%
% \begin{figure}%
% \centering%
% \fbox{\includegraphics[page=1,width=0.9\linewidth,trim=1.65in 9.3in 1.5in 1.6in,clip]{examples/example_1.pdf}}%
% \caption{The rendered result of \autoref{ex:example_1} (with trimmed page margins and bottom).}%
% \label{ex:example_1:res}%
% \end{figure}%
%
% If we look back at the \autoref{ex:example_1} of our main file, you will
% notice the four blue marks {\bfseries\color{blue!90!black}A},
% {\bfseries\color{blue!90!black}B}, {\bfseries\color{blue!90!black}C}, and
% {\bfseries\color{blue!90!black}D}.
% These are just normal letters, colored and emphasized for your convenience.
% I put them there so that you can see where the action takes place.
% |\gitLoad| produces no output, so ``ABC'' come out next to each other.
% |\input{\gitFile}| between {\bfseries\color{blue!90!black}C} and
% {\bfseries\color{blue!90!black}D} loads and directly includes the example
% file, so this is where its content appear.
%
% One small interesting thing is that, since we directly |\input| the file,
% its contents are interpreted as \LaTeX\ code.
% This means that you could construct a document by inputting files from
% different |git| repositories.
%
% However, this is not the envisioned use case.
% The envisioned use case is to include source codes and snippets from source
% codes as listings.
% We will show how this could be done in the next example.
%
% Side note: Our Python companion package |latexgit| downloads the |git|
% repositories into a folder called |__git__|\tindex{\_\_git\_\_} by default.
% If you do not delete the folder, the same repository will not be downloaded
% again but the downloaded copy will be used.
% This significantly increases speed and reduces bandwidth when applying the
% |latexgit| command several times.
% \clearpage%
%
% \subsection{The Second Example: Multiple Files and Post-Processing}%
% \label{sec:example_2}%
% \FloatBarrier%
% In \autoref{ex:example_2} we, use |latexgit| to download and present two
% different files from two different GitHub repositories.
% We also show how post-processing can work, once using the aforementioned
% simple |head -n 5| command available in the Linux shell and also by
% using the Python code formatting tool offered by the |latexgit| Python
% package.
% The result can be seen in \autoref{ex:example_2:res}.
%
% \lstinputlisting[float,label=ex:example_2,caption={An example using the latexgit package, rendered as \autoref{ex:example_2:res}.}]{examples/example_2.tex}%
% \FloatBarrier%
%
% The file |example_2.tex| shown in \autoref{ex:example_2} begins by loading
% our |latexgit| package as well as package |verbatim|, which is later used
% to display the included files.
% The document creates three sections, each of which is used to display one
% imported file.
%
% The first section loads one Python source file from our Python companion
% package \href{https://thomasweise.github.io/latexgit_py}{latexgit\_py}.
% The sources of this package are available in the GitHub repository
% \url{https://github.com/thomasWeise/latexgit\_py}.
% We download the file |latexgit/utils/console.py|, which is just a small
% utility for printing log strings to the output together with a time mark.
% The full git request contains these two components.
%
% Issuing this request will set the command |\gitFile| to the local file
% containing the downloaded contents of |latexgit/utils/console.py| from the
% repository \url{https://github.com/thomasWeise/latexgit\_py}.
% The command |\gitUrl| will expand to the URL pointing to the downloaded
% \emph{version} of the file in the original repository.
% This command, at the present time, is only really valid for GitHub.
% It builds a URL relative to the original repository based on the commit ID
% that was valid when the file was downloaded from the repository.
% Therefore, the URL then points to the \emph{exact same} contents that were
% put into the file.
% Anyway, the file contents and the generated URL are displayed in
% \autoref{ex:example_2:1}.
%
% The second section of the example document queries the same file again.
% However, this time, the third parameter of |\gitLoad| is specified.
% If the third parameter is left blank, the downloaded file will be provided
% as-is.
% However, especially if we would like to include some snippets of a more
% complex source file, we sometimes do not want to have the complete original
% contents.
% In this case, we can specify a post-processing command as third parameter.
% This command will be executed in the shell\index{shell}
% The contents of the downloaded file will then be piped into the
% |stdin|\tindex{stdin} of the command and everything that the command writes
% to its |stdout|\tindex{stdout} will be collected in a file.
% |\gitFile| then returns the path to that file.
%
% Since you can provide arbitrary commands as post-processors, this allows you
% to do, well, arbitrary post-processing.
% This could include re-formatting of code or selecting only specific lines
% from the file.
% The command can have arguments, separated by spaces, allowing you to pass
% information such as line indices or other instructions to your
% post-processing command.
%
% In the example, we use the standard Linux command |head -n 5|, which writes
% the first five lines that were written to its |stdin| to its |stdout|.
%
% The resulting output in \autoref{ex:example_2:2} looks thus similar to
% \autoref{ex:example_2:1}, but only imports ths first five lines from the
% downloaded file.
%
% If this example was stored as |example_2.tex|, then it could be built via
% \begin{quote}
% |pdflatex example_2|\\
% |python3 -m latexgit.aux example_2|\\
% |pdflatex example_2|
% \end{quote}
%
% Side note: Such post-processing steps are cached by the Python companion
% package |latexgit| in the |__git__|\tindex{\_\_git\_\_} folder as well.
%
% Finally, in the third section, of \autoref{ex:example_2}, we import a file
% from the sources of our Python package for metaheuristic optimization
% (\href{https://thomasweise.github.io/moptipy}{moptipy}).
% The sources of this package are located on GitHub at
% \url{https://github.com/thomasWeise/moptipy}.
% We download the file |moptipy/api/encoding.py|, which offers a convenient
% API for implementing an \emph{encoding} which translates from the search to
% the solution space (but that would lead too far here).
% Either way, this is a file that has lots of content.
% So we want to select certain contents while ignoring other.
% We also remove all Python type hints and all comments from the source and
% then reformat it.
%
% Luckily, our |latexgit| Python package also offers a Python code formatter,
% namely the executable module \href{https://thomasweise.github.io/latexgit_py/latexgit.formatters.html#module-latexgit.formatters.python}{latexgit.formatters.python}.
% This module takes a set of parameters such as limiting |labels| that denote
% the start and end of code snippets (in this case, the label ``|book|'') to
% include as well |args| telling the system which part of the ``omittable''
% code to preserve (in this case, preserve |doc|strings and delete everything
% else that is non-essential).
% If you are interested in such post-processing, feel invited to check out
% the \href{https://thomasweise.github.io/latexgit_py}{documentation} of the
% Python companion package at \url{https://thomasweise.github.io/latexgit_py}.
% Either way, the file is downloaded, piped through this post-processor, and
% the result is included as shown in \autoref{ex:example_2:3}.
%
% \begin{figure}%
% \centering%
% \strut\hfill\strut%
% \subcaptionbox{Page 1 of the pdf compiled from \autoref{ex:example_2}.\label{ex:example_2:1}%
% }{%
% \fbox{\includegraphics[page=1,width=0.455\linewidth,trim=1.65in 5in 1.5in 1.5in,clip]{examples/example_2.pdf}}%
% }%
% \strut\hfill\strut\hfill\strut%
% \subcaptionbox{Page 2 of the pdf compiled from \autoref{ex:example_2}.\label{ex:example_2:2}%
% }{%
% \fbox{\includegraphics[page=2,width=0.455\linewidth,trim=1.65in 5in 1.5in 1.5in,clip]{examples/example_2.pdf}}%
% }%
% \strut\hfill\strut%
% \\%
% \strut\hfill\strut%
% \subcaptionbox{Page 3 of the pdf compiled from \autoref{ex:example_2}.\label{ex:example_2:3}%
% }{\parbox{\linewidth}{\centering%
% \fbox{\includegraphics[page=3,width=0.455\linewidth,trim=1.65in 5in 1.5in 1.5in,clip]{examples/example_2.pdf}}%
% }}%
% \strut\hfill\strut%
%
% \caption{The rendered result of \autoref{ex:example_2} (with trimmed page margins and bottoms).}%
% \label{ex:example_2:res}%
% \end{figure}%
%
% \FloatBarrier%
% \subsection{The Third Example: Using the \texttt{listings} Package}%
% \label{sec:example_3}%
% \FloatBarrier%
% Finally, as third example, let us show the interaction with the package
% |listings|.
% This is not much different from using the package |verbatim| in the second
% example above.
% I just wanted to show you how it looks like.
% Also, I wanted to show the intended use of |\gitUrl|:
% You can use it to put some small ``(src)'' link in the listing's caption.
% This way, you can create teaching material where every listing is linked to
% the correct version of source code online without splattering long URLs into
% your text.
% Anyway.
% The source code of the third example is given in \autoref{ex:example_3} and
% the compiled result as \autoref{ex:example_3:res}.
%
% \lstinputlisting[float,label=ex:example_3,caption={An example using the \texttt{listings} package, rendered as \autoref{ex:example_3:res}.}]{examples/example_3.tex}%
%
% \begin{figure}%
% \centering%
% \fbox{\includegraphics[page=1,width=0.9\linewidth,trim=1.4in 5.6in 1.5in 1.6in,clip]{examples/example_3.pdf}}%
% \caption{The rendered result of \autoref{ex:example_3} (with trimmed page margins and bottom).}%
% \label{ex:example_3:res}%
% \end{figure}%
%
% If this example was stored as |example_3.tex|, then it could be built via
% \begin{quote}
% |pdflatex example_3|\\
% |python3 -m latexgit.aux example_3|\\
% |pdflatex example_3|
% \end{quote}
%
% Side note: If you actually check the \href{https://thomasweise.github.io/moptipy/_modules/moptipy/algorithms/so/rls.html}{source code}
% of the RLS algorithm, which is linked to by the ``(\href{https://thomasweise.github.io/moptipy/_modules/moptipy/algorithms/so/rls.html}{src})''
% in the caption of the example and that is displayed in the example, you will
% find that it actually uses Python type hints.
% It also has a comprehensive doc-string and is commented well.
% In source code of a real project, we do want this.
% In a listing in a book, we do not.
% The post-processor command
% \begin{quote}
% |python3 -m latexgit.formatters.python --labels book|
% \end{quote}%
% only keeps the code between the labels ``|# start book|'' and
% ``|# end book|.''
% It also removes all non-essential stuff such as type hints, comments, and
% the doc-string.
% Then it re-formats the code to save space.
% Again, check out the documentation of our |latexgit| Python companion
% package at \url{https://thomasweise.github.io/latexgit_py}.
% This is the main intended use case of our package:
% Be able to have nicely documented ``real'' code and to use parts of it
% in teaching materials.
%
% \FloatBarrier%
% \subsection{The Fourth Example: Using Git Commands in Macros}%
% \label{sec:example_4}%
% \FloatBarrier%
%
% \lstinputlisting[float,label=ex:example_4,caption={An example using commands from the latexgit package in macros, rendered as \autoref{ex:example_4:res}.}]{examples/example_4.tex}%
%
% The goal of the fourth example is to show that we can also put the commands
% from our |latexgit| package into \LaTeX\ macros.
% We define a new command |\moptipySrc| with three parameters.
% \href{https://thomasweise.github.io/moptpiy}{moptipy} is a Python package
% that implements lots of metaheuristic algorithms.
% We could want to load several files from such a repository
% \url{https://github.com/thomasWeise/moptipy} and post-process and display
% them all in the same way.
% Then, it would be annoying to always do |\gitLoad|, |\lstinputlisting|,
% and spell out the post-processor each time.
% So we put all of this into a single command whose first argument is the
% label to put for the listing, whose second command is the caption to use,
% and whose third command is the path relative to the folder ``moptipy'' in
% the |git| repository.
% In \autoref{ex:example_4}, we can then simply call |\moptipySrc| and it will
% do the whole process of loading a file from the right repository,
% post-processing it, putting a floating listing, and even putting a small
% ``(\href{https://thomasweise.github.io/moptpiy}{src})'' into the caption of
% the listing.
% The results are shown in \autoref{ex:example_4:res}% and can be obtained via
% \begin{quote}
% |pdflatex example_4|\\
% |python3 -m latexgit.aux example_4|\\
% |pdflatex example_4|
% \end{quote}
% (if the example code from \autoref{ex:example_4} was stored in a file called
% |example_4.tex|, that is.)
%
% \begin{figure}%
% \centering%
% \strut\hfill\strut%
% \subcaptionbox{Page 1 of the pdf compiled from \autoref{ex:example_4}.\label{ex:example_4:1}%
% }{%
% \fbox{\includegraphics[page=1,width=0.455\linewidth,trim=1.65in 6.2in 1.5in 1.8in,clip]{examples/example_4.pdf}}%
% }%
% \strut\hfill\strut\hfill\strut%
% \subcaptionbox{Page 2 of the pdf compiled from \autoref{ex:example_4}.\label{ex:example_4:2}%
% }{%
% \fbox{\includegraphics[page=2,width=0.455\linewidth,trim=1.65in 3.7in 1.5in 3.7in,clip]{examples/example_4.pdf}}%
% }%
% \strut\hfill\strut%
% \caption{The rendered result of \autoref{ex:example_4} (with trimmed page margins and bottoms).}%
% \label{ex:example_4:res}%
% \end{figure}%
%
% \FloatBarrier%
% \subsection{The Fifth Example: Capturing the Output of a Program}%
% \label{sec:example_5}%
% \FloatBarrier%
%
% \lstinputlisting[float,label=ex:example_5,caption={An example of capturing the output of a program, rendered as \autoref{ex:example_5:res}.}]{examples/example_5.tex}%
%
% The goal of the fifth example is to show that we can capture the output of
% a program.
% In \autoref{ex:example_5}, we just invoke |python3 --version| and capture
% the output in a file.
% We then load this file as listing.
% The results are shown in \autoref{ex:example_5:res}% and can be obtained via
% \begin{quote}
% |pdflatex example_5|\\
% |python3 -m latexgit.aux example_5|\\
% |pdflatex example_5|
% \end{quote}
% (if the example code from \autoref{ex:example_5} was stored in a file called
% |example_5.tex|, that is.)
%
% \begin{figure}%
% \centering%
% \fbox{\includegraphics[page=1,width=0.9\linewidth,trim=1.65in 7.9in 1.5in 1.8in,clip]{examples/example_5.pdf}}%
% \caption{The rendered result of \autoref{ex:example_5} (with trimmed page margins and bottoms).}%
% \label{ex:example_5:res}%
% \end{figure}%
%
%
% \FloatBarrier%
% \subsection{The Sixth Example: Capturing the Output of a Program Executed Inside a git Repository}%
% \label{sec:example_6}%
% \FloatBarrier%
%
% \lstinputlisting[float,label=ex:example_6,caption={An example of capturing the output of a program executed inside a git repository, rendered as \autoref{ex:example_6:res}.}]{examples/example_5.tex}%
%
% The goal of the sixth example is to show that we can capture the output of
% a program -- but this time we execute it inside a |git| repository.
% In \autoref{ex:example_6}, we invoke a program which is part of the examples
% suite of the \href{https://github.com/thomasWeise/pycommons}{pycommons}
% utility package.
% We capture its standard output in a file.
% We then load this file as listing.
% The results are shown in \autoref{ex:example_6:res}% and can be obtained via
% \begin{quote}
% |pdflatex example_6|\\
% |python3 -m latexgit.aux example_6|\\
% |pdflatex example_6|
% \end{quote}
% (if the example code from \autoref{ex:example_6} was stored in a file called
% |example_6.tex|, that is.)
%
% \begin{figure}%
% \centering%
% \fbox{\includegraphics[page=1,width=0.9\linewidth,trim=1.65in 7.5in 1.5in 1.8in,clip]{examples/example_6.pdf}}%
% \caption{The rendered result of \autoref{ex:example_6} (with trimmed page margins and bottoms).}%
% \label{ex:example_6:res}%
% \end{figure}%
%
%
% \FloatBarrier%
% \subsection{The Seventh Example: Capturing the Output of Multiple Programs Executed Inside Different git Repositories}%
% \label{sec:example_6}%
% \FloatBarrier%
%
% \lstinputlisting[float,label=ex:example_7,caption={An example of capturing the output of three programs executed inside different git repositories, rendered as \autoref{ex:example_7:res}.}]{examples/example_5.tex}%
%
% The goal of the seventh example is to show that we can capture the output of
% multiple programs from inside different |git| repositories.
% In \autoref{ex:example_7}, we invoke the same program as in \autoref{ex:example_6} and of two
% programs which are part of the examples suite of the
% \href{https://github.com/thomasWeise/programmingWithPython}{Programming with Python}
% book. The examples can be found in the repository
% \url{https://github.com/thomasWeise/programmingWithPythonCode}, whereas the book can be downloaded
% from \url{https://github.com/thomasWeise/programmingWithPython}.
% We capture the standard output of both programs in three files.
% We then load these file as listings.
% The results are shown in \autoref{ex:example_7:res} and can be obtained via
% \begin{quote}
% |pdflatex example_7|\\
% |python3 -m latexgit.aux example_7|\\
% |pdflatex example_7|
% \end{quote}
% (if the example code from \autoref{ex:example_7} was stored in a file called
% |example_7.tex|, that is.)