-
Notifications
You must be signed in to change notification settings - Fork 9
/
sphinx.sty
1858 lines (1768 loc) · 75.8 KB
/
sphinx.sty
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
%
% sphinx.sty
%
% Adapted from the old python.sty, mostly written by Fred Drake,
% by Georg Brandl.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2019/06/04 v2.1.1 LaTeX package (Sphinx markup)]
% provides \ltx@ifundefined
% (many packages load ltxcmds: graphicx does for pdftex and lualatex but
% not xelatex, and anyhow kvoptions does, but it may be needed in future to
% use \sphinxdeprecationwarning earlier, and it needs \ltx@ifundefined)
\RequirePackage{ltxcmds}
%% for deprecation warnings
\newcommand\sphinxdeprecationwarning[4]{% #1 the deprecated macro or name,
% #2 = when deprecated, #3 = when removed, #4 = additional info
\edef\spx@tempa{\detokenize{#1}}%
\ltx@ifundefined{sphinx_depr_\spx@tempa}{%
\global\expandafter\let\csname sphinx_depr_\spx@tempa\endcsname\spx@tempa
\expandafter\AtEndDocument\expandafter{\expandafter\let\expandafter
\sphinxdeprecatedmacro\csname sphinx_depr_\spx@tempa\endcsname
\PackageWarningNoLine{sphinx}{^^J**** SPHINX DEPRECATION WARNING:^^J
\sphinxdeprecatedmacro^^J
\@spaces- is deprecated at Sphinx #2^^J
\@spaces- and removed at Sphinx #3.^^J
#4^^J****}}%
}{% warning already emitted (at end of latex log), don't repeat
}}
%% PACKAGES
%
% we delay handling of options to after having loaded packages, because
% of the need to use \definecolor.
\RequirePackage{graphicx}
\@ifclassloaded{memoir}{}{\RequirePackage{fancyhdr}}
% for \text macro and \iffirstchoice@ conditional even if amsmath not loaded
\RequirePackage{amstext}
\RequirePackage{textcomp}% "warn" option issued from template
\RequirePackage[nobottomtitles*]{titlesec}
\@ifpackagelater{titlesec}{2016/03/15}%
{\@ifpackagelater{titlesec}{2016/03/21}%
{}%
{\newif\ifsphinx@ttlpatch@ok
\IfFileExists{etoolbox.sty}{%
\RequirePackage{etoolbox}%
\patchcmd{\ttlh@hang}{\parindent\z@}{\parindent\z@\leavevmode}%
{\sphinx@ttlpatch@oktrue}{}%
\ifsphinx@ttlpatch@ok
\patchcmd{\ttlh@hang}{\noindent}{}{}{\sphinx@ttlpatch@okfalse}%
\fi
}{}%
\ifsphinx@ttlpatch@ok
\typeout{^^J Package Sphinx Info: ^^J
**** titlesec 2.10.1 successfully patched for bugfix ****^^J}%
\else
\AtEndDocument{\PackageWarningNoLine{sphinx}{^^J%
******** titlesec 2.10.1 has a bug, (section numbers disappear) ......|^^J%
******** and Sphinx could not patch it, perhaps because your local ...|^^J%
******** copy is already fixed without a changed release date. .......|^^J%
******** If not, you must update titlesec! ...........................|}}%
\fi
}%
}{}
\RequirePackage{tabulary}
% tabulary has a bug with its re-definition of \multicolumn in its first pass
% which is not \long. But now Sphinx does not use LaTeX's \multicolumn but its
% own macro. Hence we don't even need to patch tabulary. See sphinxmulticell.sty
% X or S (Sphinx) may have meanings if some table package is loaded hence
% \X was chosen to avoid possibility of conflict
\newcolumntype{\X}[2]{p{\dimexpr
(\linewidth-\arrayrulewidth)*#1/#2-\tw@\tabcolsep-\arrayrulewidth\relax}}
\newcolumntype{\Y}[1]{p{\dimexpr
#1\dimexpr\linewidth-\arrayrulewidth\relax-\tw@\tabcolsep-\arrayrulewidth\relax}}
% using here T (for Tabulary) feels less of a problem than the X could be
\newcolumntype{T}{J}%
% For tables allowing pagebreaks
\RequirePackage{longtable}
% User interface to set-up whitespace before and after tables:
\newcommand*\sphinxtablepre {0pt}%
\newcommand*\sphinxtablepost{\medskipamount}%
% Space from caption baseline to top of table or frame of literal-block
\newcommand*\sphinxbelowcaptionspace{.5\sphinxbaselineskip}%
% as one can not use \baselineskip from inside longtable (it is zero there)
% we need \sphinxbaselineskip, which defaults to \baselineskip
\def\sphinxbaselineskip{\baselineskip}%
% The following is to ensure that, whether tabular(y) or longtable:
% - if a caption is on top of table:
% a) the space between its last baseline and the top rule of table is
% exactly \sphinxbelowcaptionspace
% b) the space from last baseline of previous text to first baseline of
% caption is exactly \parskip+\baselineskip+ height of a strut.
% c) the caption text will wrap at width \LTcapwidth (4in)
% - make sure this works also if "caption" package is loaded by user
% (with its width or margin option taking place of \LTcapwidth role)
% TODO: obtain same for caption of literal block: a) & c) DONE, b) TO BE DONE
%
% To modify space below such top caption, adjust \sphinxbelowcaptionspace
% To add or remove space above such top caption, adjust \sphinxtablepre:
% notice that \abovecaptionskip, \belowcaptionskip, \LTpre are **ignored**
% A. Table with longtable
\def\sphinxatlongtablestart
{\par
\vskip\parskip
\vskip\dimexpr\sphinxtablepre\relax % adjust vertical position
\vbox{}% get correct baseline from above
\LTpre\z@skip\LTpost\z@skip % set to zero longtable's own skips
\edef\sphinxbaselineskip{\dimexpr\the\dimexpr\baselineskip\relax\relax}%
}%
% Compatibility with caption package
\def\sphinxthelongtablecaptionisattop{%
\spx@ifcaptionpackage{\noalign{\vskip-\belowcaptionskip}}{}%
}%
% Achieves exactly \sphinxbelowcaptionspace below longtable caption
\def\sphinxlongtablecapskipadjust
{\dimexpr-\dp\strutbox
-\spx@ifcaptionpackage{\abovecaptionskip}{\sphinxbaselineskip}%
+\sphinxbelowcaptionspace\relax}%
\def\sphinxatlongtableend{\prevdepth\z@\vskip\sphinxtablepost\relax}%
% B. Table with tabular or tabulary
\def\sphinxattablestart{\par\vskip\dimexpr\sphinxtablepre\relax}%
\let\sphinxattableend\sphinxatlongtableend
% This is used by tabular and tabulary templates
\newcommand*\sphinxcapstartof[1]{%
\vskip\parskip
\vbox{}% force baselineskip for good positioning by capstart of hyperanchor
% hyperref puts the anchor 6pt above this baseline; in case of caption
% this baseline will be \ht\strutbox above first baseline of caption
\def\@captype{#1}%
\capstart
% move back vertically, as tabular (or its caption) will compensate
\vskip-\baselineskip\vskip-\parskip
}%
\def\sphinxthecaptionisattop{% locate it after \sphinxcapstartof
\spx@ifcaptionpackage
{\caption@setposition{t}%
\vskip\baselineskip\vskip\parskip % undo those from \sphinxcapstartof
\vskip-\belowcaptionskip % anticipate caption package skip
% caption package uses a \vbox, not a \vtop, so "single line" case
% gives different result from "multi-line" without this:
\nointerlineskip
}%
{}%
}%
\def\sphinxthecaptionisatbottom{% (not finalized; for template usage)
\spx@ifcaptionpackage{\caption@setposition{b}}{}%
}%
% The aim of \sphinxcaption is to apply to tabular(y) the maximal width
% of caption as done by longtable
\def\sphinxtablecapwidth{\LTcapwidth}%
\newcommand\sphinxcaption{\@dblarg\spx@caption}%
\long\def\spx@caption[#1]#2{%
\noindent\hb@xt@\linewidth{\hss
\vtop{\@tempdima\dimexpr\sphinxtablecapwidth\relax
% don't exceed linewidth for the caption width
\ifdim\@tempdima>\linewidth\hsize\linewidth\else\hsize\@tempdima\fi
% longtable ignores \abovecaptionskip/\belowcaptionskip, so do the same here
\abovecaptionskip\sphinxabovecaptionskip % \z@skip
\belowcaptionskip\sphinxbelowcaptionskip % \z@skip
\caption[{#1}]%
{\strut\ignorespaces#2\ifhmode\unskip\@finalstrut\strutbox\fi}%
}\hss}%
\par\prevdepth\dp\strutbox
}%
\def\sphinxabovecaptionskip{\z@skip}% Do not use! Flagged for removal
\def\sphinxbelowcaptionskip{\z@skip}% Do not use! Flagged for removal
% This wrapper of \abovecaptionskip is used in sphinxVerbatim for top
% caption, and with another value in sphinxVerbatimintable
% TODO: To unify space above caption of a code-block with the one above
% caption of a table/longtable, \abovecaptionskip must not be used
% This auxiliary will get renamed and receive a different meaning
% in future.
\def\spx@abovecaptionskip{\abovecaptionskip}%
% Achieve \sphinxbelowcaptionspace below a caption located above a tabular
% or a tabulary
\newcommand\sphinxaftertopcaption
{%
\spx@ifcaptionpackage
{\par\prevdepth\dp\strutbox\nobreak\vskip-\abovecaptionskip}{\nobreak}%
\vskip\dimexpr\sphinxbelowcaptionspace\relax
\vskip-\baselineskip\vskip-\parskip
}%
% varwidth is crucial for our handling of general contents in merged cells
\RequirePackage{varwidth}
% but addition of a compatibility patch with hyperref is needed
% (tested with varwidth v 0.92 Mar 2009)
\AtBeginDocument {%
\let\@@vwid@Hy@raisedlink\Hy@raisedlink
\long\def\@vwid@Hy@raisedlink#1{\@vwid@wrap{\@@vwid@Hy@raisedlink{#1}}}%
\edef\@vwid@setup{%
\let\noexpand\Hy@raisedlink\noexpand\@vwid@Hy@raisedlink % HYPERREF !
\unexpanded\expandafter{\@vwid@setup}}%
}%
% Homemade package to handle merged cells
%\RequirePackage{sphinxmulticell}
\RequirePackage{makeidx}
% For framing code-blocks and warning type notices, and shadowing topics
\RequirePackage{framed}
% The xcolor package draws better fcolorboxes around verbatim code
\IfFileExists{xcolor.sty}{
\RequirePackage{xcolor}
}{
\RequirePackage{color}
}
% For highlighted code.
\RequirePackage{fancyvrb}
\define@key{FV}{hllines}{\def\sphinx@verbatim@checkifhl##1{\in@{, ##1,}{#1}}}
% sphinxVerbatim must be usable by third party without requiring hllines set-up
\def\sphinxresetverbatimhllines{\def\sphinx@verbatim@checkifhl##1{\in@false}}
\sphinxresetverbatimhllines
% For hyperlinked footnotes in tables; also for gathering footnotes from
% topic and warning blocks. Also to allow code-blocks in footnotes.
%\RequirePackage{footnotehyper-sphinx}
% For the H specifier. Do not \restylefloat{figure}, it breaks Sphinx code
% for allowing figures in tables.
\RequirePackage{float}
% For floating figures in the text. Better to load after float.
\RequirePackage{wrapfig}
% Separate paragraphs by space by default.
\IfFileExists{parskip-2001-04-09.sty}% since September 2018 TeXLive update
% new parskip.sty, but let it rollback to old one.
% hopefully TeX installation not broken and LaTeX kernel not too old
{\RequirePackage{parskip}[=v1]}
% standard one from 1989. Admittedly \section of article/book gives possibly
% anomalous spacing, but we can't require September 2018 release for some time.
{\RequirePackage{parskip}}
% For parsed-literal blocks.
\RequirePackage{alltt}
% Display "real" single quotes in literal blocks.
\RequirePackage{upquote}
% control caption around literal-block
\RequirePackage{capt-of}
\RequirePackage{needspace}
% LaTeX 2018-04-01 and later provides \@removefromreset
\ltx@ifundefined{@removefromreset}
{\RequirePackage{remreset}}
{}% avoid warning
% to make pdf with correct encoded bookmarks in Japanese
% this should precede the hyperref package
\ifx\kanjiskip\@undefined
% for non-Japanese: make sure bookmarks are ok also with lualatex
\PassOptionsToPackage{pdfencoding=unicode}{hyperref}
\else
\RequirePackage{atbegshi}
\ifx\ucs\@undefined
\ifnum 42146=\euc"A4A2
\AtBeginShipoutFirst{\special{pdf:tounicode EUC-UCS2}}
\else
\AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
\fi
\else
\AtBeginShipoutFirst{\special{pdf:tounicode UTF8-UCS2}}
\fi
\fi
\ifx\@jsc@uplatextrue\@undefined\else
\PassOptionsToPackage{setpagesize=false}{hyperref}
\fi
% These options can be overriden inside 'hyperref' key
% or by later use of \hypersetup.
\PassOptionsToPackage{colorlinks,breaklinks,%
linkcolor=InnerLinkColor,filecolor=OuterLinkColor,%
menucolor=OuterLinkColor,urlcolor=OuterLinkColor,%
citecolor=InnerLinkColor}{hyperref}
% stylesheet for highlighting with pygments
%\RequirePackage{sphinxhighlight}
% fix baseline increase from Pygments latex formatter in case of error tokens
% and keep \fboxsep's scope local via added braces
\def\PYG@tok@err{%
\def\PYG@bc##1{{\setlength{\fboxsep}{-\fboxrule}%
\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}%
}
\def\PYG@tok@cs{%
\def\PYG@tc##1{\textcolor[rgb]{0.25,0.50,0.56}{##1}}%
\def\PYG@bc##1{{\setlength{\fboxsep}{0pt}%
\colorbox[rgb]{1.00,0.94,0.94}{\strut ##1}}}%
}%
%% OPTIONS
%
% Handle options via "kvoptions" (later loaded by hyperref anyhow)
\RequirePackage{kvoptions}
\SetupKeyvalOptions{prefix=spx@opt@} % use \spx@opt@ prefix
% Sphinx legacy text layout: 1in margins on all four sides
\ifx\@jsc@uplatextrue\@undefined
\DeclareStringOption[1in]{hmargin}
\DeclareStringOption[1in]{vmargin}
\DeclareStringOption[.5in]{marginpar}
\else
% Japanese standard document classes handle \mag in a special way
\DeclareStringOption[\inv@mag in]{hmargin}
\DeclareStringOption[\inv@mag in]{vmargin}
\DeclareStringOption[.5\dimexpr\inv@mag in\relax]{marginpar}
\fi
\DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
\DeclareStringOption[-1]{numfigreset}
\DeclareBoolOption[false]{nonumfigreset}
\DeclareBoolOption[false]{mathnumfig}
% \DeclareBoolOption[false]{usespart}% not used
% dimensions, we declare the \dimen registers here.
\newdimen\sphinxverbatimsep
\newdimen\sphinxverbatimborder
\newdimen\sphinxshadowsep
\newdimen\sphinxshadowsize
\newdimen\sphinxshadowrule
% \DeclareStringOption is not convenient for the handling of these dimensions
% because we want to assign the values to the corresponding registers. Even if
% we added the code to the key handler it would be too late for the initial
% set-up and we would need to do initial assignments explicitely. We end up
% using \define@key directly.
% verbatim
\sphinxverbatimsep=\fboxsep
\define@key{sphinx}{verbatimsep}{\sphinxverbatimsep\dimexpr #1\relax}
\sphinxverbatimborder=\fboxrule
\define@key{sphinx}{verbatimborder}{\sphinxverbatimborder\dimexpr #1\relax}
% topic boxes
\sphinxshadowsep =5pt
\define@key{sphinx}{shadowsep}{\sphinxshadowsep\dimexpr #1\relax}
\sphinxshadowsize=4pt
\define@key{sphinx}{shadowsize}{\sphinxshadowsize\dimexpr #1\relax}
\sphinxshadowrule=\fboxrule
\define@key{sphinx}{shadowrule}{\sphinxshadowrule\dimexpr #1\relax}
% verbatim
\DeclareBoolOption[true]{verbatimwithframe}
\DeclareBoolOption[true]{verbatimwrapslines}
\DeclareBoolOption[true]{verbatimhintsturnover}
\DeclareBoolOption[true]{inlineliteralwraps}
\DeclareStringOption[t]{literalblockcappos}
\DeclareStringOption[r]{verbatimcontinuedalign}
\DeclareStringOption[r]{verbatimcontinuesalign}
% parsed literal
\DeclareBoolOption[true]{parsedliteralwraps}
% \textvisiblespace for compatibility with fontspec+XeTeX/LuaTeX
\DeclareStringOption[\textcolor{red}{\textvisiblespace}]{verbatimvisiblespace}
\DeclareStringOption % must use braces to hide the brackets
[{\makebox[2\fontcharwd\font`\x][r]{\textcolor{red}{\tiny$\m@th\hookrightarrow$}}}]%
{verbatimcontinued}
% notices/admonitions
% the dimensions for notices/admonitions are kept as macros and assigned to
% \spx@notice@border at time of use, hence \DeclareStringOption is ok for this
\newdimen\spx@notice@border
\DeclareStringOption[0.5pt]{noteborder}
\DeclareStringOption[0.5pt]{hintborder}
\DeclareStringOption[0.5pt]{importantborder}
\DeclareStringOption[0.5pt]{tipborder}
\DeclareStringOption[1pt]{warningborder}
\DeclareStringOption[1pt]{cautionborder}
\DeclareStringOption[1pt]{attentionborder}
\DeclareStringOption[1pt]{dangerborder}
\DeclareStringOption[1pt]{errorborder}
% footnotes
\DeclareStringOption[\mbox{ }]{AtStartFootnote}
% we need a public macro name for direct use in latex file
\newcommand*{\sphinxAtStartFootnote}{\spx@opt@AtStartFootnote}
% no such need for this one, as it is used inside other macros
\DeclareStringOption[\leavevmode\unskip]{BeforeFootnote}
% some font styling.
\DeclareStringOption[\sffamily\bfseries]{HeaderFamily}
% colours
% same problems as for dimensions: we want the key handler to use \definecolor.
% first, some colours with no prefix, for backwards compatibility
\newcommand*{\sphinxDeclareColorOption}[2]{%
\definecolor{#1}#2%
\define@key{sphinx}{#1}{\definecolor{#1}##1}%
}%
\sphinxDeclareColorOption{TitleColor}{{rgb}{0.126,0.263,0.361}}
\sphinxDeclareColorOption{InnerLinkColor}{{rgb}{0.208,0.374,0.486}}
\sphinxDeclareColorOption{OuterLinkColor}{{rgb}{0.216,0.439,0.388}}
\sphinxDeclareColorOption{VerbatimColor}{{rgb}{1,1,1}}
\sphinxDeclareColorOption{VerbatimBorderColor}{{rgb}{0,0,0}}
% now the colours defined with "sphinx" prefix in their names
\newcommand*{\sphinxDeclareSphinxColorOption}[2]{%
% set the initial default
\definecolor{sphinx#1}#2%
% set the key handler. The "value" ##1 must be acceptable by \definecolor.
\define@key{sphinx}{#1}{\definecolor{sphinx#1}##1}%
}%
% Default color chosen to be as in minted.sty LaTeX package!
\sphinxDeclareSphinxColorOption{VerbatimHighlightColor}{{rgb}{0.878,1,1}}
% admonition boxes, "light" style
\sphinxDeclareSphinxColorOption{noteBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{hintBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{importantBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{tipBorderColor}{{rgb}{0,0,0}}
% admonition boxes, "heavy" style
\sphinxDeclareSphinxColorOption{warningBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{cautionBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{attentionBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{dangerBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{errorBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{warningBgColor}{{rgb}{1,1,1}}
\sphinxDeclareSphinxColorOption{cautionBgColor}{{rgb}{1,1,1}}
\sphinxDeclareSphinxColorOption{attentionBgColor}{{rgb}{1,1,1}}
\sphinxDeclareSphinxColorOption{dangerBgColor}{{rgb}{1,1,1}}
\sphinxDeclareSphinxColorOption{errorBgColor}{{rgb}{1,1,1}}
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
% don't allow use of maxlistdepth via \sphinxsetup.
\DisableKeyvalOption{sphinx}{maxlistdepth}
\DisableKeyvalOption{sphinx}{numfigreset}
\DisableKeyvalOption{sphinx}{nonumfigreset}
\DisableKeyvalOption{sphinx}{mathnumfig}
% user interface: options can be changed midway in a document!
\newcommand\sphinxsetup[1]{\setkeys{sphinx}{#1}}
%% ALPHANUMERIC LIST ITEMS
\newcommand\sphinxsetlistlabels[5]
{% #1 = style, #2 = enum, #3 = enumnext, #4 = prefix, #5 = suffix
% #2 and #3 are counters used by enumerate environement e.g. enumi, enumii.
% #1 is a macro such as \arabic or \alph
% prefix and suffix are strings (by default empty and a dot).
\@namedef{the#2}{#1{#2}}%
\@namedef{label#2}{#4\@nameuse{the#2}#5}%
\@namedef{p@#3}{\@nameuse{p@#2}#4\@nameuse{the#2}#5}%
}%
%% MAXLISTDEPTH
%
% remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.
% This is a hack, which works with the standard classes: it assumes \@toodeep
% is always used in "true" branches: "\if ... \@toodeep \else .. \fi."
% will force use the "false" branch (if there is one)
\def\spx@toodeep@hack{\fi\iffalse}
% do nothing if 'maxlistdepth' key not used or if package enumitem loaded.
\ifnum\spx@opt@maxlistdepth=\z@\expandafter\@gobbletwo\fi
\AtBeginDocument{%
\@ifpackageloaded{enumitem}{\remove@to@nnil}{}%
\let\spx@toodeepORI\@toodeep
\def\@toodeep{%
\ifnum\@listdepth<\spx@opt@maxlistdepth\relax
\expandafter\spx@toodeep@hack
\else
\expandafter\spx@toodeepORI
\fi}%
% define all missing \@list... macros
\count@\@ne
\loop
\ltx@ifundefined{@list\romannumeral\the\count@}
{\iffalse}{\iftrue\advance\count@\@ne}%
\repeat
\loop
\ifnum\count@>\spx@opt@maxlistdepth\relax\else
\expandafter\let
\csname @list\romannumeral\the\count@\expandafter\endcsname
\csname @list\romannumeral\the\numexpr\count@-\@ne\endcsname
% workaround 2.6--3.2d babel-french issue (fixed in 3.2e; no change needed)
\ltx@ifundefined{leftmargin\romannumeral\the\count@}
{\expandafter\let
\csname leftmargin\romannumeral\the\count@\expandafter\endcsname
\csname leftmargin\romannumeral\the\numexpr\count@-\@ne\endcsname}{}%
\advance\count@\@ne
\repeat
% define all missing enum... counters and \labelenum... macros and \p@enum..
\count@\@ne
\loop
\ltx@ifundefined{c@enum\romannumeral\the\count@}
{\iffalse}{\iftrue\advance\count@\@ne}%
\repeat
\loop
\ifnum\count@>\spx@opt@maxlistdepth\relax\else
\newcounter{enum\romannumeral\the\count@}%
\expandafter\def
\csname labelenum\romannumeral\the\count@\expandafter\endcsname
\expandafter
{\csname theenum\romannumeral\the\numexpr\count@\endcsname.}%
\expandafter\def
\csname p@enum\romannumeral\the\count@\expandafter\endcsname
\expandafter
{\csname p@enum\romannumeral\the\numexpr\count@-\@ne\expandafter
\endcsname\csname theenum\romannumeral\the\numexpr\count@-\@ne\endcsname.}%
\advance\count@\@ne
\repeat
% define all missing labelitem... macros
\count@\@ne
\loop
\ltx@ifundefined{labelitem\romannumeral\the\count@}
{\iffalse}{\iftrue\advance\count@\@ne}%
\repeat
\loop
\ifnum\count@>\spx@opt@maxlistdepth\relax\else
\expandafter\let
\csname labelitem\romannumeral\the\count@\expandafter\endcsname
\csname labelitem\romannumeral\the\numexpr\count@-\@ne\endcsname
\advance\count@\@ne
\repeat
\PackageInfo{sphinx}{maximal list depth extended to \spx@opt@maxlistdepth}%
\@gobble\@nnil
}
%% INDEX, BIBLIOGRAPHY, APPENDIX, TABLE OF CONTENTS
%
% fix the double index and bibliography on the table of contents
% in jsclasses (Japanese standard document classes)
\ifx\@jsc@uplatextrue\@undefined\else
\renewenvironment{sphinxtheindex}
{\cleardoublepage\phantomsection
\begin{theindex}}
{\end{theindex}}
\renewenvironment{sphinxthebibliography}[1]
{\cleardoublepage% \phantomsection % not needed here since TeXLive 2010's hyperref
\begin{thebibliography}{#1}}
{\end{thebibliography}}
\fi
% disable \@chappos in Appendix in pTeX
\ifx\kanjiskip\@undefined\else
\let\py@OldAppendix=\appendix
\renewcommand{\appendix}{
\py@OldAppendix
\gdef\@chappos{}
}
\fi
% make commands known to non-Sphinx document classes
\providecommand*{\sphinxtableofcontents}{\tableofcontents}
\ltx@ifundefined{sphinxthebibliography}
{\newenvironment
{sphinxthebibliography}{\begin{thebibliography}}{\end{thebibliography}}%
}
{}% else clause of \ltx@ifundefined
\ltx@ifundefined{sphinxtheindex}
{\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}%
{}% else clause of \ltx@ifundefined
% for usage with xindy: this string gets internationalized in preamble
\newcommand*{\sphinxnonalphabeticalgroupname}{}
% redefined in preamble, headings for makeindex produced index
\newcommand*{\sphinxsymbolsname}{}
\newcommand*{\sphinxnumbersname}{}
%% COLOR (general)
%
% FIXME: \normalcolor should probably be used in place of \py@NormalColor
% elsewhere, and \py@NormalColor should never be defined. \normalcolor
% switches to the colour from last \color call in preamble.
\def\py@NormalColor{\color{black}}
% FIXME: it is probably better to use \color{TitleColor}, as TitleColor
% can be customized from 'sphinxsetup', and drop usage of \py@TitleColor
\def\py@TitleColor{\color{TitleColor}}
% FIXME: this line should be dropped, as "9" is default anyhow.
\ifdefined\pdfcompresslevel\pdfcompresslevel = 9 \fi
%% PAGE STYLING
%
% Style parameters and macros used by most documents here
\raggedbottom
\sloppy
\hbadness = 5000 % don't print trivial gripes
% Use \pagestyle{normal} as the primary pagestyle for text.
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
\@ifpackageloaded{fancyhdr}{%
\ltx@ifundefined{c@chapter}
{% no \chapter, "howto" (non-Japanese) docclass
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[C]{{\py@HeaderFamily\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
% Same as 'plain', this way we can use it in template
% FIXME: shouldn't this have a running header with Name and Release like 'manual'?
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[C]{{\py@HeaderFamily\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
}%
{% classes with \chapter command
\fancypagestyle{normal}{
\fancyhf{}
% FIXME: this presupposes "twoside".
% If "oneside" class option, there are warnings in LaTeX log.
\fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
\fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py@HeaderFamily \@title\sphinxheadercomma\py@release}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% define chaptermark with \@chappos when \@chappos is available for Japanese
\ltx@ifundefined{@chappos}{}
{\def\chaptermark##1{\markboth{\@chapapp\space\thechapter\space\@chappos\space ##1}{}}}
}
% Update the plain style so we get the page number & footer line,
% but not a chapter or section title. This is to keep the first
% page of a chapter `clean.'
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
}
}
}
{% no fancyhdr: memoir class
% Provide default for 'normal' style simply as an alias of 'plain' style
% This way we can use \pagestyle{normal} in LaTeX template
\def\ps@normal{\ps@plain}
% Users of memoir class are invited to redefine 'normal' style in preamble
}
% geometry
\ifx\kanjiskip\@undefined
\PassOptionsToPackage{%
hmargin={\unexpanded{\spx@opt@hmargin}},%
vmargin={\unexpanded{\spx@opt@vmargin}},%
marginpar=\unexpanded{\spx@opt@marginpar}}
{geometry}
\else
% set text width for Japanese documents to be integer multiple of 1zw
% and text height to be integer multiple of \baselineskip
% the execution is delayed to \sphinxsetup then geometry.sty
\normalsize\normalfont
\newcommand*\sphinxtextwidthja[1]{%
\if@twocolumn\tw@\fi
\dimexpr
\numexpr\dimexpr\paperwidth-\tw@\dimexpr#1\relax\relax/
\dimexpr\if@twocolumn\tw@\else\@ne\fi zw\relax
zw\relax}%
\newcommand*\sphinxmarginparwidthja[1]{%
\dimexpr\numexpr\dimexpr#1\relax/\dimexpr1zw\relax zw\relax}%
\newcommand*\sphinxtextlinesja[1]{%
\numexpr\@ne+\dimexpr\paperheight-\topskip-\tw@\dimexpr#1\relax\relax/
\baselineskip\relax}%
\ifx\@jsc@uplatextrue\@undefined\else
% the way we found in order for the papersize special written by
% geometry in the dvi file to be correct in case of jsbook class
\ifnum\mag=\@m\else % do nothing special if nomag class option or 10pt
\PassOptionsToPackage{truedimen}{geometry}%
\fi
\fi
\PassOptionsToPackage{%
hmarginratio={1:1},%
textwidth=\unexpanded{\sphinxtextwidthja{\spx@opt@hmargin}},%
vmarginratio={1:1},%
lines=\unexpanded{\sphinxtextlinesja{\spx@opt@vmargin}},%
marginpar=\unexpanded{\sphinxmarginparwidthja{\spx@opt@marginpar}},%
footskip=2\baselineskip,%
}{geometry}%
\AtBeginDocument
{% update a dimension used by the jsclasses
\ifx\@jsc@uplatextrue\@undefined\else\fullwidth\textwidth\fi
% for some reason, jreport normalizes all dimensions with \@settopoint
\@ifclassloaded{jreport}
{\@settopoint\textwidth\@settopoint\textheight\@settopoint\marginparwidth}
{}% <-- "false" clause of \@ifclassloaded
}%
\fi
% fix fncychap's bug which uses prematurely the \textwidth value
\@ifpackagewith{fncychap}{Bjornstrup}
{\AtBeginDocument{\mylen\textwidth\advance\mylen-2\myhi}}%
{}% <-- "false" clause of \@ifpackagewith
%% TITLES
%
% Since Sphinx 1.5, users should use HeaderFamily key to 'sphinxsetup' rather
% than defining their own \py@HeaderFamily command (which is still possible).
% Memo: \py@HeaderFamily is also used by \maketitle as defined in
% sphinxmanual.cls/sphinxhowto.cls
\newcommand{\py@HeaderFamily}{\spx@opt@HeaderFamily}
% This sets up the fancy chapter headings that make the documents look
% at least a little better than the usual LaTeX output.
\@ifpackagewith{fncychap}{Bjarne}{
\ChNameVar {\raggedleft\normalsize \py@HeaderFamily}
\ChNumVar {\raggedleft\Large \py@HeaderFamily}
\ChTitleVar{\raggedleft\Large \py@HeaderFamily}
% This creates (numbered) chapter heads without the leading \vspace*{}:
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\DOCH
\fi
\fi
\interlinepenalty\@M
\if@mainmatter
\DOTI{#1}%
\else%
\DOTIS{#1}%
\fi
}}
}{}% <-- "false" clause of \@ifpackagewith
% Augment the sectioning commands used to get our own font family in place,
% and reset some internal data items (\titleformat from titlesec package)
\titleformat{\section}{\Large\py@HeaderFamily}%
{\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor}
\titleformat{\subsection}{\large\py@HeaderFamily}%
{\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
\titleformat{\subsubsection}{\py@HeaderFamily}%
{\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
% By default paragraphs (and subsubsections) will not be numbered because
% sphinxmanual.cls and sphinxhowto.cls set secnumdepth to 2
\titleformat{\paragraph}{\py@HeaderFamily}%
{\py@TitleColor\theparagraph}{0.5em}{\py@TitleColor}{\py@NormalColor}
\titleformat{\subparagraph}{\py@HeaderFamily}%
{\py@TitleColor\thesubparagraph}{0.5em}{\py@TitleColor}{\py@NormalColor}
%% GRAPHICS
%
% \sphinxincludegraphics resizes images larger than the TeX \linewidth (which
% is adjusted in indented environments), or taller than a certain maximal
% height (usually \textheight and this is reduced in the environments which use
% framed.sty to avoid infinite loop if image too tall).
%
% In case height or width options are present the rescaling is done
% (since 2.0), in a way keeping the width:height ratio either native from
% image or from the width and height options if both were present.
%
\newdimen\spx@image@maxheight
\AtBeginDocument{\spx@image@maxheight\textheight}
% box scratch register
\newdimen\spx@image@box
\newcommand*{\sphinxsafeincludegraphics}[2][]{%
% #1 contains possibly width=, height=, but no scale= since 1.8.4
\setbox\spx@image@box\hbox{\includegraphics[#1,draft]{#2}}%
\in@false % use some handy boolean flag
\ifdim \wd\spx@image@box>\linewidth
\in@true % flag to remember to adjust options and set box dimensions
% compute height which results from rescaling width to \linewidth
% and keep current aspect ratio. multiply-divide in \numexpr uses
% temporarily doubled precision, hence no overflow. (of course we
% assume \ht is not a few sp's below \maxdimen...(about 16384pt).
\edef\spx@image@rescaledheight % with sp units
{\the\numexpr\ht\spx@image@box
*\linewidth/\wd\spx@image@box sp}%
\ifdim\spx@image@rescaledheight>\spx@image@maxheight
% the rescaled height will be too big, so it is height which decides
% the rescaling factor
\def\spx@image@requiredheight{\spx@image@maxheight}% dimen register
\edef\spx@image@requiredwidth % with sp units
{\the\numexpr\wd\spx@image@box
*\spx@image@maxheight/\ht\spx@image@box sp}%
% TODO: decide if this commented-out block could be needed due to
% rounding in numexpr operations going up
% \ifdim\spx@image@requiredwidth>\linewidth
% \def\spx@image@requiredwidth{\linewidth}% dimen register
% \fi
\else
\def\spx@image@requiredwidth{\linewidth}% dimen register
\let\spx@image@requiredheight\spx@image@rescaledheight% sp units
\fi
\else
% width is ok, let's check height
\ifdim\ht\spx@image@box>\spx@image@maxheight
\in@true
\edef\spx@image@requiredwidth % with sp units
{\the\numexpr\wd\spx@image@box
*\spx@image@maxheight/\ht\spx@image@box sp}%
\def\spx@image@requiredheight{\spx@image@maxheight}% dimen register
\fi
\fi % end of check of width and height
\ifin@
\setbox\spx@image@box
\hbox{\includegraphics
[%#1,% contained only width and/or height and overruled anyhow
width=\spx@image@requiredwidth,height=\spx@image@requiredheight]%
{#2}}%
% \includegraphics does not set box dimensions to the exactly
% requested ones, see https://github.com/latex3/latex2e/issues/112
\wd\spx@image@box\spx@image@requiredwidth
\ht\spx@image@box\spx@image@requiredheight
\leavevmode\box\spx@image@box
\else
% here we do not modify the options, no need to adjust width and height
% on output, they will be computed exactly as with "draft" option
\setbox\spx@image@box\box\voidb@x % clear memory
\includegraphics[#1]{#2}%
\fi
}%
% Use the "safe" one by default (2.0)
\def\sphinxincludegraphics{\sphinxsafeincludegraphics}
%% FIGURE IN TABLE
%
\newenvironment{sphinxfigure-in-table}[1][\linewidth]{%
\def\@captype{figure}%
\sphinxsetvskipsforfigintablecaption
\begin{minipage}{#1}%
}{\end{minipage}}
% store the original \caption macro for usage with figures inside longtable
% and tabulary cells. Make sure we get the final \caption in presence of
% caption package, whether the latter was loaded before or after sphinx.
\AtBeginDocument{%
\let\spx@originalcaption\caption
\@ifpackageloaded{caption}
{\let\spx@ifcaptionpackage\@firstoftwo
\caption@AtBeginDocument*{\let\spx@originalcaption\caption}%
% in presence of caption package, drop our own \sphinxcaption whose aim was to
% ensure same width of caption to all kinds of tables (tabular(y), longtable),
% because caption package has its own width (or margin) option
\def\sphinxcaption{\caption}%
}%
{\let\spx@ifcaptionpackage\@secondoftwo}%
}
% tabulary expands twice contents, we need to prevent double counter stepping
\newcommand*\sphinxfigcaption
{\ifx\equation$%$% this is trick to identify tabulary first pass
\firstchoice@false\else\firstchoice@true\fi
\spx@originalcaption }
\newcommand*\sphinxsetvskipsforfigintablecaption
{\abovecaptionskip\smallskipamount
\belowcaptionskip\smallskipamount}
%% CITATIONS
%
\protected\def\sphinxcite{\cite}
%% FOOTNOTES
%
% Support large numbered footnotes in minipage
% But now obsolete due to systematic use of \savenotes/\spewnotes
% when minipages are in use in the various macro definitions next.
\def\thempfootnote{\arabic{mpfootnote}}
%% NUMBERING OF FIGURES, TABLES, AND LITERAL BLOCKS
\ltx@ifundefined{c@chapter}
{\newcounter{literalblock}}%
{\newcounter{literalblock}[chapter]%
\def\theliteralblock{\ifnum\c@chapter>\z@\arabic{chapter}.\fi
\arabic{literalblock}}%
}%
\ifspx@opt@nonumfigreset
\ltx@ifundefined{c@chapter}{}{%
\@removefromreset{figure}{chapter}%
\@removefromreset{table}{chapter}%
\@removefromreset{literalblock}{chapter}%
\ifspx@opt@mathnumfig
\@removefromreset{equation}{chapter}%
\fi
}%
\def\thefigure{\arabic{figure}}%
\def\thetable {\arabic{table}}%
\def\theliteralblock{\arabic{literalblock}}%
\ifspx@opt@mathnumfig
\def\theequation{\arabic{equation}}%
\fi
\else
\let\spx@preAthefigure\@empty
\let\spx@preBthefigure\@empty
% \ifspx@opt@usespart % <-- LaTeX writer could pass such a 'usespart' boolean
% % as sphinx.sty package option
% If document uses \part, (triggered in Sphinx by latex_toplevel_sectioning)
% LaTeX core per default does not reset chapter or section
% counters at each part.
% But if we modify this, we need to redefine \thechapter, \thesection to
% include the part number and this will cause problems in table of contents
% because of too wide numbering. Simplest is to do nothing.
% \fi
\ifnum\spx@opt@numfigreset>0
\ltx@ifundefined{c@chapter}
{}
{\g@addto@macro\spx@preAthefigure{\ifnum\c@chapter>\z@\arabic{chapter}.}%
\g@addto@macro\spx@preBthefigure{\fi}}%
\fi
\ifnum\spx@opt@numfigreset>1
\@addtoreset{figure}{section}%
\@addtoreset{table}{section}%
\@addtoreset{literalblock}{section}%
\ifspx@opt@mathnumfig
\@addtoreset{equation}{section}%
\fi
\g@addto@macro\spx@preAthefigure{\ifnum\c@section>\z@\arabic{section}.}%
\g@addto@macro\spx@preBthefigure{\fi}%
\fi
\ifnum\spx@opt@numfigreset>2
\@addtoreset{figure}{subsection}%
\@addtoreset{table}{subsection}%
\@addtoreset{literalblock}{subsection}%
\ifspx@opt@mathnumfig
\@addtoreset{equation}{subsection}%
\fi
\g@addto@macro\spx@preAthefigure{\ifnum\c@subsection>\z@\arabic{subsection}.}%
\g@addto@macro\spx@preBthefigure{\fi}%
\fi
\ifnum\spx@opt@numfigreset>3
\@addtoreset{figure}{subsubsection}%
\@addtoreset{table}{subsubsection}%
\@addtoreset{literalblock}{subsubsection}%
\ifspx@opt@mathnumfig
\@addtoreset{equation}{subsubsection}%
\fi
\g@addto@macro\spx@preAthefigure{\ifnum\c@subsubsection>\z@\arabic{subsubsection}.}%
\g@addto@macro\spx@preBthefigure{\fi}%
\fi
\ifnum\spx@opt@numfigreset>4
\@addtoreset{figure}{paragraph}%
\@addtoreset{table}{paragraph}%
\@addtoreset{literalblock}{paragraph}%
\ifspx@opt@mathnumfig
\@addtoreset{equation}{paragraph}%
\fi
\g@addto@macro\spx@preAthefigure{\ifnum\c@subparagraph>\z@\arabic{subparagraph}.}%
\g@addto@macro\spx@preBthefigure{\fi}%
\fi
\ifnum\spx@opt@numfigreset>5
\@addtoreset{figure}{subparagraph}%
\@addtoreset{table}{subparagraph}%
\@addtoreset{literalblock}{subparagraph}%
\ifspx@opt@mathnumfig
\@addtoreset{equation}{subparagraph}%
\fi
\g@addto@macro\spx@preAthefigure{\ifnum\c@subsubparagraph>\z@\arabic{subsubparagraph}.}%
\g@addto@macro\spx@preBthefigure{\fi}%
\fi
\expandafter\g@addto@macro
\expandafter\spx@preAthefigure\expandafter{\spx@preBthefigure}%
\let\thefigure\spx@preAthefigure
\let\thetable\spx@preAthefigure
\let\theliteralblock\spx@preAthefigure
\g@addto@macro\thefigure{\arabic{figure}}%
\g@addto@macro\thetable{\arabic{table}}%
\g@addto@macro\theliteralblock{\arabic{literalblock}}%
\ifspx@opt@mathnumfig
\let\theequation\spx@preAthefigure
\g@addto@macro\theequation{\arabic{equation}}%
\fi
\fi
%% LITERAL BLOCKS
%
% Based on use of "fancyvrb.sty"'s Verbatim.
% - with framing allowing page breaks ("framed.sty")
% - with breaking of long lines (exploits Pygments mark-up),
% - with possibly of a top caption, non-separable by pagebreak.
% - and usable inside tables or footnotes ("footnotehyper-sphinx").
% For extensions which use \OriginalVerbatim and compatibility with Sphinx <
% 1.5, we define and use these when (unmodified) Verbatim will be needed. But
% Sphinx >= 1.5 does not modify the \Verbatim macro anymore.
\let\OriginalVerbatim \Verbatim
\let\endOriginalVerbatim\endVerbatim
% for captions of literal blocks
% at start of caption title
\newcommand*{\fnum@literalblock}{\literalblockname\nobreakspace\theliteralblock}
% this will be overwritten in document preamble by Babel translation
\newcommand*{\literalblockname}{Listing }
% file extension needed for \caption's good functioning, the file is created
% only if a \listof{literalblock}{foo} command is encountered, which is
% analogous to \listoffigures, but for the code listings (foo = chosen title.)
\newcommand*{\ext@literalblock}{lol}
\newif\ifspx@inframed % flag set if we are already in a framed environment
% if forced use of minipage encapsulation is needed (e.g. table cells)
\newif\ifsphinxverbatimwithminipage \sphinxverbatimwithminipagefalse
% Framing macro for use with framed.sty's \FrameCommand
% - it obeys current indentation,
% - frame is \fboxsep separated from the contents,
% - the contents use the full available text width,
% - #1 = color of frame, #2 = color of background,
% - #3 = above frame, #4 = below frame, #5 = within frame,
% - #3 and #4 must be already typeset boxes; they must issue \normalcolor
% or similar, else, they are under scope of color #1
\long\def\spx@fcolorbox #1#2#3#4#5{%
\hskip\@totalleftmargin
\hskip-\fboxsep\hskip-\fboxrule
% use of \color@b@x here is compatible with both xcolor.sty and color.sty
\color@b@x {\color{#1}\spx@CustomFBox{#3}{#4}}{\color{#2}}{#5}%
\hskip-\fboxsep\hskip-\fboxrule
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
}%
% #1 = for material above frame, such as a caption or a "continued" hint
% #2 = for material below frame, such as a caption or "continues on next page"
% #3 = actual contents, which will be typeset with a background color
\long\def\spx@CustomFBox#1#2#3{%
\begingroup
\setbox\@tempboxa\hbox{{#3}}% inner braces to avoid color leaks
\vbox{#1% above frame
% draw frame border _latest_ to avoid pdf viewer issue
\kern\fboxrule
\hbox{\kern\fboxrule
\copy\@tempboxa