/
sphinx.sty
820 lines (768 loc) · 33.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
%
% sphinx.sty
%
% Adapted from the old python.sty, mostly written by Fred Drake,
% by Georg Brandl.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2023/03/07 v6.2.0 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
{% limit scope of \spx@tempa, \AtEndDocument works even if nested.
\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
}%
}% end of scope limiting group for \spx@tempa
}
%% important build warnings use an undefined reference to induce latexmk
%% into complaining (once per warning) at very end of console output
\newcommand\sphinxbuildwarning[1]{%
\ifcsname sphinx_emitted_#1\endcsname
\else
\global\expandafter\let\csname sphinx_emitted_#1\endcsname\@empty
\AtEndDocument{\hbox{% should the printing of text be made conditional on
% some boolean?
\bfseries\color{red}%
\@nameuse{sphinx_buildwarning_#1}%
% place an undefined reference deliberately
\let\nfss@text\@gobble % no ??
\ref{!!\@nameuse{sphinx_buildwarning_#1}}%
}}%
\fi
}
\@namedef{sphinx_buildwarning_coloursyntax}{%
The colours whose definition used xcolor syntax were set to white
as xcolor was not found; check the latex log warnings for details}
\@namedef{sphinx_buildwarning_colorblend}{%
Command \string\sphinxcolorblend\space seen but ignored in tables
as xcolor was not found; check the latex log warnings for details}
\@namedef{sphinx_buildwarning_nopict2e}{%
Some radii options for box corners used; they were ignored as pict2e
was not found}
\@namedef{sphinx_buildwarning_badtitlesec}{%
Your system has titlesec version 2.10.1 which causes disappearance
of section numbers; check the latex log warning for details}
\@namedef{sphinx_buildwarning_booktabs}{%
Some tables with booktabs class (check latex log) but booktabs
package not loaded; add its loading to the latex preamble}%
\@namedef{sphinx_buildwarning_badfootnotes}{%
Footnote rendering may have had problems, due to extra package or
document class; check latex log for instructions}%
%% OPTION HANDLING
%
% We generally first handle options then load packages, but we need
% \definecolor from xcolor/color to handle the options.
% MEMO: xcolor \fcolorbox coloured boxes render better in some PDF viewers
% than with color package \fcolorbox. Since 1.6.3, Sphinx uses only its own
% custom variant of \fcolorbox when handling verbatim code. Currently (last
% checked at 5.0.0) \fcolorbox is used for admonitions (sphinxheavybox)
% and appears also in Pygmentize output mark-up.
\IfFileExists{xcolor.sty}{
\RequirePackage{xcolor}
}{
\RequirePackage{color}
}
% the \colorlet of xcolor (if at all loaded) is overkill for our internal use
\newcommand{\sphinxcolorlet}[2]
{\expandafter\let\csname\@backslashchar color@#1\expandafter\endcsname
\csname\@backslashchar color@#2\endcsname }
% (5.3.0) allow colour options to use both the \definecolor and the \colorlet
% syntaxes, for example VerbatimColor={gray}{0.9} or VerbatimColor=red!10
% In the latter case we need the real \colorlet from xcolor package.
\def\spx@defineorletcolor#1{%
\def\spx@definedcolor{{#1}}%
\futurelet\spx@token\spx@defineorlet}
\def\spx@defineorlet{%
\ifx\spx@token\bgroup
\expandafter\spx@definecolor\else\expandafter\spx@colorlet\fi}
\def\spx@colorlet#1\relax{\expandafter\colorlet\spx@definedcolor{#1}}
\def\spx@definecolor{\expandafter\definecolor\spx@definedcolor}
%
\@ifpackageloaded{xcolor}%
{}%
{% xcolor not loaded because it was not found in the LaTeX installation
\def\spx@colorlet#1\relax{%
\sphinxbuildwarning{coloursyntax}%
\PackageWarning{sphinx}{%
Sorry, the #1 syntax requires package xcolor,\MessageBreak
which was not found on your TeX/LaTeX installation.\MessageBreak
\@spaces\expandafter\@firstofone\spx@definedcolor\MessageBreak
will be set to white}%
\expandafter\definecolor\spx@definedcolor{rgb}{1,1,1}%
}% end of redefinition of \spx@colorlet
}% end of xcolor not found branch
% Handle options via "kvoptions" (later loaded by hyperref anyhow)
\RequirePackage{kvoptions}
\SetupKeyvalOptions{prefix=spx@opt@} % use \spx@opt@ prefix
% Optional usage of booktabs package for tables
\DeclareBoolOption[false]{booktabs}
\DeclareBoolOption[false]{borderless}
\DeclareBoolOption[true]{booktabscolorgaps}
\DeclareVoidOption{booktabsnogaps}{%
\ifx\@nodocument\relax
% in body
\expandafter\@firstofone
\else
% in preamble, wait for at begin document
\expandafter\AtBeginDocument
\fi
{\ifdefined\abovetopsep % silently do nothing if booktabs not loaded
\abovetopsep\z@\belowrulesep\z@\aboverulesep\z@\belowbottomsep\z@
\fi
}%
}
% Coloured table rows
\DeclareBoolOption[false]{colorrows}
% 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}
\define@key{sphinx}{bookmarksdepth}{\AtBeginDocument{\hypersetup{bookmarksdepth=#1}}}
\AtBeginDocument{\define@key{sphinx}{bookmarksdepth}{\hypersetup{bookmarksdepth=#1}}}
% \DeclareBoolOption[false]{usespart}% not used
% INFO: the keys for padding and border widths were extended at 5.1.0,
% and legacy names for user interface were kept, but their definitions
% are delayed further down. The legacy dimen registers used internally
% \sphinxverbatimborder and \sphinxverbatimsep got removed at 6.2.0.
\DeclareBoolOption[true]{verbatimwithframe}
\DeclareBoolOption[true]{verbatimwrapslines}
\DeclareBoolOption[false]{verbatimforcewraps}
\DeclareStringOption[3]{verbatimmaxoverfull}
\DeclareStringOption[100]{verbatimmaxunderfull}
\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}
% topic boxes
% 5.1.0 added new keys for configuration. The legacy keys shadowsep,
% shadowsize, shadowrule are kept for backwards compatibility. See further
% down for definitions. Unfortunately this had bugs due to typos, which got
% fixed later at 6.1.2. The \sphinxshadowsep, \sphinxshadowsize,
% \sphinxshadowrule \dimen registers became at 5.1.0 either no-op or, for the
% latter, were used under an aliased name. They got removed at 6.2.0.
%
% 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}
% Compatibility layer to share for these notice types common code
% with the one for warning, danger, ..., in sphinxlatexadmonitions.sty
\def\spx@note@border {\spx@opt@noteborder}
\def\spx@hint@border {\spx@opt@hintborder}
\def\spx@important@border{\spx@opt@importantborder}
\def\spx@tip@border {\spx@opt@tipborder}
% The warning type notices are handled in the "CSS" section below.
% 6.2.0 does not define \spx@opt@warningborder etc... macros
% but only \spx@warning@border etc...
% 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]{%
% set the initial default; only \definecolor syntax for defaults!
\definecolor{#1}#2%
% set the key handler to accept both \definecolor and \colorlet syntax
\define@key{sphinx}{#1}{\spx@defineorletcolor{#1}##1\relax}%
}%
\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}{{gray}{0.95}}
\sphinxDeclareColorOption{VerbatimBorderColor}{{RGB}{32,32,32}}
% all other colours will be named with a "sphinx" prefix
\newcommand*{\sphinxDeclareSphinxColorOption}[2]{%
% set the initial default; only \definecolor syntax for defaults!
\definecolor{sphinx#1}#2%
% set the key handler to accept both \definecolor and \colorlet syntax
\define@key{sphinx}{#1}{\spx@defineorletcolor{sphinx#1}##1\relax}%
}%
% table row colors
\sphinxDeclareSphinxColorOption{TableRowColorHeader}{{gray}{0.86}}
\sphinxDeclareSphinxColorOption{TableRowColorOdd}{{gray}{0.92}}
\sphinxDeclareSphinxColorOption{TableRowColorEven}{{gray}{0.98}}
% if not set, the "Merge" colour will keep in sync with the "Row" colour
\def\sphinxTableMergeColorHeader{sphinxTableRowColorHeader}
\define@key{sphinx}{TableMergeColorHeader}{%
\spx@defineorletcolor{sphinxTableMergeColorHeader}#1\relax
\def\sphinxTableMergeColorHeader{sphinxTableMergeColorHeader}%
}%
\def\sphinxTableMergeColorOdd{sphinxTableRowColorOdd}
\define@key{sphinx}{TableMergeColorOdd}{%
\spx@defineorletcolor{sphinxTableMergeColorOdd}#1\relax
\def\sphinxTableMergeColorOdd{sphinxTableMergeColorOdd}%
}%
\def\sphinxTableMergeColorEven{sphinxTableRowColorEven}
\define@key{sphinx}{TableMergeColorEven}{%
\spx@defineorletcolor{sphinxTableMergeColorEven}#1\relax
\def\sphinxTableMergeColorEven{sphinxTableMergeColorEven}%
}%
% 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}}
%%%%%%%%
%
% Additions of CSS-like keys (in particular for rounded boxes) at 5.1.0
% --------------------------
%
% In future, an alternative user interface will perhaps be provided via
% CSS-like input in a configuration variable latex_css, and Sphinx
% will then parse it into the \sphinxsetup options described it.
%
% In the meantime we adopt already some CSS-like names. However,
% attention to not use these options as genuine CSS properties, only
% very limited syntax is supported.
%
\def\spxstring@none{none}
\def\spxstring@clone{clone}
%
% Refactoring at 6.2.0
% --------------------
%
% - Legacy \dimen registers \sphinxverbatimborder, \sphinxverbatimsep,
% \sphinxshadowsep, \sphinxshadowsize, and \sphinxshadowrule,
% which had been deprecated have finally been removed,
% - No \dimen registers used at all (at some point the \dimen's
% \spxdimen@pre@border and \spxdimen@topic@border were still defined)
% as all dimensions are stored in macros. Dimen registers are used only
% by the box macros of sphinxpackageboxes.sty, and are initialized from
% the macro storage relative to each type (code-block, topic, ...)
% at time of use.
%
% 6.2.0 batch defines in one go all auxiliaries for code blocks, topics,
% and warning-type admonitions. Some needed add-ons due to maintaining
% legacy options and specific defaults are handled in a second step.
%
% This unification facilitates adding a \sphinxbox which has full key=value
% of all options with CSS-inspired names which were added at 5.1.0 for
% extended customization possibility of code-blocks, topics and admonitions.
% Except that \sphinxbox is for boxing inline elements (no linebreak, no
% pagebreak).
%
% MEMO: the 6.2.0 refactoring induced a change that the default \fboxrule used
% by verbatimborder and shadowrule is now not expanded to its value immediately in
% preamble (no assignment to a \dimen register is done, only storage in a
% macro). In practice this changed nothing to existing projects.
%
% Border keys
%
\def\spx@tempa#1{% #1 = macro prefix
\expandafter\spx@tempb
\csname #1border\expandafter\endcsname
\csname #1border@top\expandafter\endcsname
\csname #1border@right\expandafter\endcsname
\csname #1border@bottom\expandafter\endcsname
\csname #1border@left\expandafter\endcsname
\csname if#1border@open\expandafter\endcsname
\csname #1border@opentrue\expandafter\endcsname
\csname #1border@openfalse\endcsname
}%
\def\spx@tempb #1#2#3#4#5#6#7#8#9{% #9 = option prefix
\define@key{sphinx}{#9border-top-width}{\def#2{##1}}%
\define@key{sphinx}{#9border-right-width}{\def#3{##1}}%
\define@key{sphinx}{#9border-bottom-width}{\def#4{##1}}%
\define@key{sphinx}{#9border-left-width}{\def#5{##1}}%
\define@key{sphinx}{#9border-width}{%
\def#1{##1}% MEMO: not immediately expanded, should this be changed?
\def#2{#1}\let#3#2\let#4#2\let#5#2%
}%
\newif#6%
\define@key{sphinx}{#9box-decoration-break}%
{\begingroup\edef\spx@tempa{##1}\expandafter\endgroup
\ifx\spx@tempa\spxstring@clone#8\else#7\fi}%
\spx@tempc{#9}% option prefix
}
\def\spx@tempc #1#2{% #1 = option prefix, #2 = legacy option name
% keep legacy option names as aliases to new-named options
\expandafter\let\csname KV@sphinx@#2\expandafter\endcsname
\csname KV@sphinx@#1border-width\endcsname
% init border-width (fetches next argument)
\csname KV@sphinx@#1border-width\endcsname
}
% macro prefix option prefix legacy option init value
\spx@tempa{spx@pre@} {pre_} {verbatimborder} \fboxrule
\spx@tempa{spx@topic@} {div.topic_} {shadowrule} \fboxrule
\spx@tempa{spx@warning@} {div.warning_} {warningborder} {1pt}
\spx@tempa{spx@caution@} {div.caution_} {cautionborder} {1pt}
\spx@tempa{spx@attention@}{div.attention_}{attentionborder}{1pt}
\spx@tempa{spx@danger@} {div.danger_} {dangerborder} {1pt}
\spx@tempa{spx@error@} {div.error_} {errorborder} {1pt}
% this one new at 6.2.0: (we do not create a "legacy name" for it)
\spx@tempa{spx@box@} {box_} {box_border-width}\fboxrule
% Set default box-decoration-break style for codeblocks to slice
\spx@pre@border@opentrue % new default at 6.0.0: slice, not clone
% Padding keys
%
\def\spx@tempa#1{%
\expandafter\spx@tempb
\csname #1padding\expandafter\endcsname
\csname #1padding@top\expandafter\endcsname
\csname #1padding@right\expandafter\endcsname
\csname #1padding@bottom\expandafter\endcsname
\csname #1padding@left\endcsname
}%
\def\spx@tempb #1#2#3#4#5#6{% #6 = option prefix
\define@key{sphinx}{#6padding-top}{\def#2{##1}}%
\define@key{sphinx}{#6padding-right}{\def#3{##1}}%
\define@key{sphinx}{#6padding-bottom}{\def#4{##1}}%
\define@key{sphinx}{#6padding-left}{\def#5{##1}}%
\define@key{sphinx}{#6padding}{%
\def#1{##1}%
\def#2{#1}\let#3#2\let#4#2\let#5#2%
}%
% initialization (will fetch "init" argument next):
\csname KV@sphinx@#6padding\endcsname
}
% MEMO: prior to 6.2.0 the \fboxsep value (0.4pt, a priori) was
% frozen here via a \dimen assignement. Now it remains \fboxsep
% until being used.
% #1 macro prefix #6 option prefix init value
\spx@tempa{spx@pre@} {pre_} \fboxsep
\spx@tempa{spx@topic@} {div.topic_} {5pt}
% MEMO: prior to 5.1.0 padding was not separately customizable
% from border width for warning type admonitions. The below
% keeps the legacy behavior of a constant borderwidth+padding.
% The dim expression is not evaluated yet, only at time of use.
\spx@tempa{spx@warning@} {div.warning_} {\dimexpr.6\baselineskip-\spx@warning@border\relax}
\spx@tempa{spx@caution@} {div.caution_} {\dimexpr.6\baselineskip-\spx@caution@border\relax}
\spx@tempa{spx@attention@}{div.attention_} {\dimexpr.6\baselineskip-\spx@attention@border\relax}
\spx@tempa{spx@danger@} {div.danger_} {\dimexpr.6\baselineskip-\spx@danger@border\relax}
\spx@tempa{spx@error@} {div.error_} {\dimexpr.6\baselineskip-\spx@error@border\relax}
\spx@tempa{spx@box@} {box_} \fboxsep % new at 6.2.0
% define legacy verbatimsep key as alias of pre_padding key
\expandafter\let\expandafter\KV@sphinx@verbatimsep\csname KV@sphinx@pre_padding\endcsname
% define legacy shadowsep key as alias of div.topic_padding key
\expandafter\let\expandafter\KV@sphinx@shadowsep\csname KV@sphinx@div.topic_padding\endcsname
% Corner radii keys
%
\def\spx@tempa#1{% #1 = macro prefix
\expandafter\spx@tempb
\csname #1radius@topleft\expandafter\endcsname
\csname #1radius@topright\expandafter\endcsname
\csname #1radius@bottomright\expandafter\endcsname
\csname #1radius@bottomleft\endcsname
}%
\def\spx@tempb #1#2#3#4#5{% #5 = option prefix
\define@key{sphinx}{#5border-top-left-radius}{\def#1{##1}}%
\define@key{sphinx}{#5border-top-right-radius}{\def#2{##1}}%
\define@key{sphinx}{#5border-bottom-right-radius}{\def#3{##1}}%
\define@key{sphinx}{#5border-bottom-left-radius}{\def#4{##1}}%
\define@key{sphinx}{#5border-radius}{\def#1{##1}\let#2#1\let#3#1\let#4#1}%
\csname KV@sphinx@#5border-radius\endcsname % fetches next argument
}
% macro prefix option prefix init value
\spx@tempa{spx@pre@} {pre_} {3pt}% new default at 6.0.0
\spx@tempa{spx@topic@} {div.topic_} \z@
\spx@tempa{spx@warning@} {div.warning_} \z@
\spx@tempa{spx@caution@} {div.caution_} \z@
\spx@tempa{spx@attention@}{div.attention_} \z@
\spx@tempa{spx@danger@} {div.danger_} \z@
\spx@tempa{spx@error@} {div.error_} \z@
\spx@tempa{spx@box@} {box_} {3pt}% new and tentative default at 6.2.0
% Shadow keys
%
\def\spx@tempa#1{%
\expandafter\spx@tempb
\csname if#1withshadow\expandafter\endcsname
\csname if#1insetshadow\endcsname
}%
\def\spx@tempb#1#2{\newif#1\newif#2}%
% macro prefix
\spx@tempa{spx@pre@}
\spx@tempa{spx@topic@}
\spx@tempa{spx@warning@}
\spx@tempa{spx@caution@}
\spx@tempa{spx@attention@}
\spx@tempa{spx@danger@}
\spx@tempa{spx@error@}
\spx@tempa{spx@box@}% new at 6.2.0
%
\def\spx@tempa#1{% #1 = macro prefix
\expandafter\spx@tempb
\csname #1withshadowtrue\expandafter\endcsname
\csname #1withshadowfalse\expandafter\endcsname
\csname #1insetshadowtrue\expandafter\endcsname
\csname #1insetshadowfalse\expandafter\endcsname
\csname #1shadow@setter\expandafter\endcsname
\csname #1shadow@xoffset\expandafter\endcsname
\csname #1shadow@yoffset\endcsname
}%
\def\spx@tempb#1#2#3#4#5#6#7#8{% #8 = option prefix
\define@key{sphinx}{#8box-shadow}{#5##1 {} {} \@nnil}%
\def#5##1 ##2 ##3 ##4\@nnil{%
\begingroup\edef\spx@tempa{##1}\expandafter\endgroup
\ifx\spx@tempa\spxstring@none
#2%
% MEMO: here the code uses an \edef+\number so dimensions
% are evaluated at time of use of option, they are not
% delayed (this is in contrast with other dimension specs,
% the delay being only strictly required by padding key of
% warning type notices, for backward legacy behavior).
% These things probably do not matter at all, as users
% will mainly use explicit dimension denotations like "4pt".
\else #1\edef#6{\number\dimexpr##1\relax sp}%
\edef#7{\number\dimexpr##2+\z@\relax sp}%
\if\relax\detokenize{##3}\relax#4\else#3\fi
\fi
}%
#5none {} {} \@nnil % no shadow by default (except for topic, see below)
}
\spx@tempa{spx@pre@} {pre_}
\spx@tempa{spx@topic@} {div.topic_}
% This corresponds to the legacy parameters of ShadowBox
\spx@topic@shadow@setter 4pt 4pt {} \@nnil
\spx@tempa{spx@warning@} {div.warning_}
\spx@tempa{spx@caution@} {div.caution_}
\spx@tempa{spx@attention@}{div.attention_}
\spx@tempa{spx@danger@} {div.danger_}
\spx@tempa{spx@error@} {div.error_}
\spx@tempa{spx@box@} {box_}% new at 6.2.0
% Support for legacy shadowsize
% This definition was broken at 5.1.0 and fixed at 6.1.2
\define@key{sphinx}{shadowsize}{%
\edef\spx@topic@shadow@xoffset{\number\dimexpr#1\relax sp}%
\let\spx@topic@shadow@yoffset\spx@topic@shadow@xoffset
\ifdim\spx@topic@shadow@xoffset=\z@
\spx@topic@withshadowfalse
\else
\spx@topic@withshadowtrue
\spx@topic@insetshadowfalse
\fi
}%
% Color keys
% (three of them: border, background, shadow)
%
% We associate a boolean to each color, so that the box code can
% decide to insert a \color call or consider it not needed.
% (pending question: should the box code systematically do
% a \normalcolor?)
\def\spx@tempa#1{%
\expandafter\spx@tempb
\csname if#1withshadowcolor\expandafter\endcsname
\csname if#1withbordercolor\expandafter\endcsname
\csname if#1withbackgroundcolor\endcsname
}%
\def\spx@tempb#1#2#3{\newif#1\newif#2\newif#3}%
% macro prefix
\spx@tempa{spx@pre@}
\spx@tempa{spx@topic@}
\spx@tempa{spx@warning@}
\spx@tempa{spx@caution@}
\spx@tempa{spx@attention@}
\spx@tempa{spx@danger@}
\spx@tempa{spx@error@}
\spx@tempa{spx@box@}% new at 6.2.0
%
\def\spx@tempa#1{% #1 = macro prefix
\expandafter\spx@tempb
\csname #1withbordercolortrue\expandafter\endcsname
\csname #1withbackgroundcolortrue\expandafter\endcsname
\csname #1withshadowcolortrue\endcsname
}
\def\spx@tempb#1#2#3#4#5{% #4 = option prefix, #5 = color name prefix
\define@key{sphinx}{#4border-TeXcolor}%
{#1\spx@defineorletcolor{#5BorderColor}##1\relax}%
\define@key{sphinx}{#4background-TeXcolor}%
{#2\spx@defineorletcolor{#5BgColor}##1\relax}%
\define@key{sphinx}{#4box-shadow-TeXcolor}%
{#3\spx@defineorletcolor{#5ShadowColor}##1\relax}%
}
% macro prefix option prefix color name prefix
\spx@tempa{spx@pre@} {pre_} {Verbatim}
% internal legacy color name is VerbatimColor not VerbatimBgColor:
\define@key{sphinx}{pre_background-TeXcolor}%
{\spx@pre@withbackgroundcolortrue\spx@defineorletcolor{VerbatimColor}#1\relax}%
\spx@pre@withbordercolortrue % 6.0.0 VerbatimBorderColor {RGB}{32,32,32}
\spx@pre@withbackgroundcolortrue % 6.0.0 VerbatimColor {gray}{0.95}
% Keep functioning these legacy sphinxsetup option names
\expandafter\let\expandafter\KV@sphinx@VerbatimBorderColor
\csname KV@sphinx@pre_border-TeXcolor\endcsname
\expandafter\let\expandafter\KV@sphinx@VerbatimColor
\csname KV@sphinx@pre_background-TeXcolor\endcsname
% macro prefix option prefix color name prefix
% MEMO: prior to 6.2.0, internal color names started with sphinxtopic, not
% sphinxTopic, and it was sphinxTopicBackgroundColor, not sphinxtopicBgColor.
\spx@tempa{spx@topic@} {div.topic_} {sphinxtopic}% (no legacy interface)
\spx@tempa{spx@warning@} {div.warning_} {sphinxwarning}
\spx@tempa{spx@caution@} {div.caution_} {sphinxcaution}
\spx@tempa{spx@attention@}{div.attention_} {sphinxattention}
\spx@tempa{spx@danger@} {div.danger_} {sphinxdanger}
\spx@tempa{spx@error@} {div.error_} {sphinxerror}
\spx@tempa{spx@box@} {box_} {sphinxbox}% new at 6.2.0
% Keep legacy sphinxsetup interface for warning type notices
\def\spx@tempa#1#2{% #1 = option prefix, #2 = legacy option prefix
\expandafter\let\csname KV@sphinx@#2BorderColor\expandafter\endcsname
\csname KV@sphinx@#1border-TeXcolor\endcsname
\expandafter\let\csname KV@sphinx@#2BgColor\expandafter\endcsname
\csname KV@sphinx@#1background-TeXcolor\endcsname
}
\spx@tempa{div.warning_} {warning}
\spx@tempa{div.caution_} {caution}
\spx@tempa{div.attention_} {attention}
\spx@tempa{div.danger_} {danger}
\spx@tempa{div.error_} {error}
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
% don't allow use of maxlistdepth via \sphinxsetup.
\DisableKeyvalOption{sphinx}{maxlistdepth}
\DisableKeyvalOption{sphinx}{numfigreset}
\DisableKeyvalOption{sphinx}{nonumfigreset}
\DisableKeyvalOption{sphinx}{mathnumfig}
\DisableKeyvalOption{sphinx}{booktabs}
\DisableKeyvalOption{sphinx}{borderless}
\DisableKeyvalOption{sphinx}{rowcolors}
% FIXME: this is unrelated to an option, move this elsewhere
% To allow hyphenation of first word in narrow contexts; no option,
% customization to be done via 'preamble' key
\newcommand*\sphinxAtStartPar{\leavevmode\nobreak\hskip\z@skip}
% No need for the \hspace{0pt} trick (\hskip\z@skip) with luatex
\ifdefined\directlua\let\sphinxAtStartPar\@empty\fi
% user interface: options can be changed midway in a document!
\newcommand\sphinxsetup{\setkeys{sphinx}}
%% MISCELLANEOUS CONTEXT
%
% flag to be set in a framed environment
% (defined here as currently needed by three sphinxlatex....sty files and
% even if not needed if such files are replaced, the definition does no harm)
\newif\ifspx@inframed
%
% \spx@ifcaptionpackage (defined at begin document)
% is needed currently in macros from:
% sphinxlatexliterals.sty (sphinxVerbatim)
% sphinxlatextables.sty (for some macros used in the table templates)
%
% \sphinxcaption is mark-up injected by the tabular and tabulary templates
% it is defined in sphinxlatextables.sty
%
% 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}%
}
%% PASS OPTIONS
%
% pass options to hyperref; it must not have been loaded already
\input{sphinxoptionshyperref.sty}
% pass options to geometry; it must not have been loaded already
\input{sphinxoptionsgeometry.sty}
%% COLOR (general)
%
% FIXME: these two should be deprecated
%
% FIXME: \normalcolor should be used and \py@NormalColor never defined
\def\py@NormalColor{\color{black}}
% FIXME: \color{TitleColor} should be used directly and \py@TitleColor
% should never get defined.
\def\py@TitleColor{\color{TitleColor}}
%% PACKAGES
%
% as will be indicated below, secondary style files load some more packages
%
% For \text macro (sphinx.util.texescape)
% also for usage of \firstchoice@true(false) in sphinxlatexgraphics.sty
\RequirePackage{amstext}
% It was passed "warn" option from latex template in case it is already loaded
% via some other package before \usepackage{sphinx} in preamble
\RequirePackage{textcomp}
% 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}
% Provides \captionof, used once by latex writer (\captionof{figure})
\RequirePackage{capt-of}
% Support hlist directive
\RequirePackage{multicol}
%% GRAPHICS
%
% It will always be needed, so let's load it here
\RequirePackage{graphicx}
\input{sphinxlatexgraphics.sty}
%% FRAMED ENVIRONMENTS
%
% \sphinxbox added at 6.2.0, its definition is in sphinxpackageboxes.
%
% It would be nice to have a \setkeys which would allow an argument
% holding an assumed tacit prefix, which here would be "box_", allowing
% the user to not have to use it and thus abbreviate the key names.
% But kvoptions does not provide it seems this on top of keyval.
% So I decided to alias all already defined options.
% - advantage: \sphinxbox options are shorter for user: no box_ prefix
% - inconventient: this \sphinxboxsetup can not customize other things
\@tfor\x:={border-width}%
{border-top-width}%
{border-right-width}%
{border-bottom-width}%
{border-left-width}%
{box-decoration-break}% This one is actually useless, as \sphinxbox
% creates an unbreakable horizontal box, not a breakable vertical
% box. And as is well-known it is very complicated (not to say
% impossible) to create in LaTeX breakable horizontal boxes. No
% package offers them. See the complications for the support of
% verbatimforcewraps in sphinxlatexliterals.sty or see the source
% code of the soul or soulutf8 packages.
{padding}%
{padding-top}%
{padding-right}%
{padding-bottom}%
{padding-left}%
{border-radius}%
{border-top-left-radius}%
{border-top-right-radius}%
{border-bottom-right-radius}%
{border-bottom-left-radius}%
{box-shadow}%
{border-TeXcolor}%
{background-TeXcolor}%
{box-shadow-TeXcolor}%
\do{\expandafter\let\csname KV@sphinxbox@\x\expandafter\endcsname
\csname KV@sphinx@box_\x\endcsname}
\newcommand\sphinxboxsetup{\setkeys{sphinxbox}}
% some of these defaults got already set directly
\sphinxboxsetup{border-width=\fboxrule,
padding=\fboxsep,
border-radius=\fboxsep,
border-TeXcolor=VerbatimBorderColor,
background-TeXcolor=VerbatimColor,%
}%
\RequirePackage{sphinxpackageboxes}
\def\spx@RequirePackage@PictIIe{%
\IfFileExists{pict2e.sty}
{\RequirePackage{pict2e}}
{\PackageWarningNoLine{sphinx}{%
The package pict2e is required for rounded boxes.\MessageBreak
It does not seem to be available on your system.\MessageBreak
Options for setting radii will be ignored}%
\sphinxbuildwarning{nopict2e}%
\def\spx@boxes@fcolorbox@rounded{\spx@boxes@fcolorbox}%
}%
}%
\AtBeginDocument{%
\spx@RequirePackage@PictIIe
\@ifpackageloaded{pict2e}{\let\spx@ifpackageloaded@pictiie\@firstoftwo}%
{\let\spx@ifpackageloaded@pictiie\@secondoftwo}%
}%
\input{sphinxlatexadmonitions.sty}
\input{sphinxlatexliterals.sty}
\input{sphinxlatexshadowbox.sty}
%% CONTAINERS
%
\input{sphinxlatexcontainers.sty}
%% PYGMENTS
% stylesheet for highlighting with pygments
\RequirePackage{sphinxhighlight}
%% TABLES
%
\input{sphinxlatextables.sty}
%% NUMBERING OF FIGURES, TABLES, AND LITERAL BLOCKS
%
\input{sphinxlatexnumfig.sty}
%% LISTS
%
\input{sphinxlatexlists.sty}
%% FOOTNOTES
%
% Support scopes for footnote numbering
% This is currently stepped at each input file
\newcounter{sphinxscope}
\newcommand{\sphinxstepscope}{\stepcounter{sphinxscope}}
% We ensure \thesphinxscope expands to digits tokens, independently of language
\renewcommand{\thesphinxscope}{\number\value{sphinxscope}}
\newcommand\sphinxthefootnotemark[2]{%
% this is used to make reference to an explicitly numbered footnote not on same page
% #1=label of footnote text, #2=page number where footnote text was printed
\ifdefined\pagename
\pagename\space#2, % <- space
\else
p. #2, % <- space
\fi #1% no space
}
% support large numbered footnotes in minipage; but this is now obsolete
% from systematic use of savenotes environment around minipages
\def\thempfootnote{\arabic{mpfootnote}}
% This package is needed to support hyperlinked footnotes in tables and
% framed contents, and to allow code-blocks in footnotes.
\RequirePackage{sphinxpackagefootnote}
%% INDEX, BIBLIOGRAPHY, APPENDIX, TABLE OF CONTENTS
%
\input{sphinxlatexindbibtoc.sty}
%% STYLING
%
\input{sphinxlatexstylepage.sty}
\input{sphinxlatexstyleheadings.sty}
\input{sphinxlatexstyletext.sty}
%% MODULE RELEASE DATA AND OBJECT DESCRIPTIONS
%
\input{sphinxlatexobjects.sty}
% FIXME: this line should be dropped, as "9" is default anyhow.
\ifdefined\pdfcompresslevel\pdfcompresslevel = 9 \fi
\endinput