/
sphinx.sty
762 lines (711 loc) · 30.2 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
%
% sphinx.sty
%
% Adapted from the old python.sty, mostly written by Fred Drake,
% by Georg Brandl.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2022/06/30 v5.1.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
\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
}}
%% 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 use case
\newcommand{\sphinxcolorlet}[2]
{\expandafter\let\csname\@backslashchar color@#1\expandafter\endcsname
\csname\@backslashchar color@#2\endcsname }
% 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}
\define@key{sphinx}{bookmarksdepth}{\AtBeginDocument{\hypersetup{bookmarksdepth=#1}}}
\AtBeginDocument{\define@key{sphinx}{bookmarksdepth}{\hypersetup{bookmarksdepth=#1}}}
% \DeclareBoolOption[false]{usespart}% not used
% dimensions, we declare the \dimen registers here.
\newdimen\sphinxverbatimsep % <-- TO BE REMOVED NOT USED ANYMORE AT 5.1.0
\newdimen\sphinxverbatimborder
%
% \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 explicitly. We end up
% using \define@key directly.
% verbatim
\sphinxverbatimsep=\fboxsep % <-- TO BE REMOVED NOT USED ANYMORE AT 5.1.0
\define@key{sphinx}{verbatimsep}{\sphinxverbatimsep\dimexpr #1\relax}
\sphinxverbatimborder=\fboxrule
\define@key{sphinx}{verbatimborder}{\sphinxverbatimborder\dimexpr #1\relax}
\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
% alternative names and definitions in 5.1.0 section below
\newdimen\sphinxshadowsep % <-- TO BE REMOVED NOT USED ANYMORE AT 5.1.0
\newdimen\sphinxshadowsize % <-- TO BE REMOVED NOT USED ANYMORE AT 5.1.0
\newdimen\sphinxshadowrule
\sphinxshadowsep=5pt
\define@key{sphinx}{shadowsep}{\sphinxshadowsep\dimexpr #1\relax}%
\sphinxshadowsize=4pt
\define@key{sphinx}{shadowsize}{\sphinxshadowsize\dimexpr #1\relax}
\sphinxshadowrule=\fboxrule % catches current value (probably 0.4pt)
\define@key{sphinx}{shadowrule}{\sphinxshadowsize\dimexpr #1\relax}
% 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}}
%%%%%%%%
%
% Additions 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}
% Future: should below all the macros holding dimensions be defined via some
% \edef and \dimexpr rather?
%
% Deliberately the code avoids creating (except by \let) new \dimen variables
% besides the legacy ones already defined.
%
% code-blocks
\let\spxdimen@pre@border\sphinxverbatimborder
\define@key{sphinx}{pre_border-top-width}{\def\spx@pre@border@top{#1}}
\define@key{sphinx}{pre_border-right-width}{\def\spx@pre@border@right{#1}}
\define@key{sphinx}{pre_border-bottom-width}{\def\spx@pre@border@bottom{#1}}
\define@key{sphinx}{pre_border-left-width}{\def\spx@pre@border@left{#1}}
% currently accepts only one dimension specification
\define@key{sphinx}{pre_border-width}{%
\spxdimen@pre@border\dimexpr #1\relax
\def\spx@pre@border@top {\spxdimen@pre@border}%
\let\spx@pre@border@right \spx@pre@border@top
\let\spx@pre@border@bottom\spx@pre@border@top
\let\spx@pre@border@left \spx@pre@border@top
}
\def\spx@pre@border@top {\spxdimen@pre@border}%
\let\spx@pre@border@right \spx@pre@border@top
\let\spx@pre@border@bottom\spx@pre@border@top
\let\spx@pre@border@left \spx@pre@border@top
\expandafter\let\expandafter\KV@sphinx@verbatimborder
\csname KV@sphinx@pre_border-width\endcsname
\newif\ifspx@pre@border@open % defaults to false (at least for 5.x series)
\define@key{sphinx}{pre_box-decoration-break}%
{\edef\spx@tempa{#1}%
\ifx\spx@tempa\spxstring@clone
\spx@pre@border@openfalse
\else\spx@pre@border@opentrue\fi}
%
% MEMO: \sphinxverbatimsep not used anywhere anymore in the code, to be removed
\define@key{sphinx}{pre_padding-top}{\def\spx@pre@padding@top{#1}}
\define@key{sphinx}{pre_padding-right}{\def\spx@pre@padding@right{#1}}
\define@key{sphinx}{pre_padding-bottom}{\def\spx@pre@padding@bottom{#1}}
\define@key{sphinx}{pre_padding-left}{\def\spx@pre@padding@left{#1}}
\define@key{sphinx}{pre_padding}{%
\def\spx@pre@padding@top {#1}%
\let\spx@pre@padding@right \spx@pre@padding@top
\let\spx@pre@padding@bottom\spx@pre@padding@top
\let\spx@pre@padding@left \spx@pre@padding@top
}
\edef\spx@pre@padding@top {\number\fboxsep sp}% \sphinxverbatimsep to be removed
\let\spx@pre@padding@right \spx@pre@padding@top
\let\spx@pre@padding@bottom\spx@pre@padding@top
\let\spx@pre@padding@left \spx@pre@padding@top
\expandafter\let\expandafter\KV@sphinx@verbatimsep
\csname KV@sphinx@pre_padding\endcsname
%
% We do not define a new \dimen (in 5.x pre-5.1.0 dev branch there
% was a \sphinxverbatimradius when rounded boxes were first introduced,
% but we removed it).
\define@key{sphinx}{pre_border-top-left-radius}{\def\spx@pre@radius@topleft{#1}}
\define@key{sphinx}{pre_border-top-right-radius}{\edef\spx@pre@radius@topright{#1}}
\define@key{sphinx}{pre_border-bottom-right-radius}{\def\spx@pre@radius@bottomright{#1}}
\define@key{sphinx}{pre_border-bottom-left-radius}{\def\spx@pre@radius@bottomleft{#1}}
\define@key{sphinx}{pre_border-radius}{%
\def\spx@pre@radius@topleft {#1}%
\let\spx@pre@radius@topright \spx@pre@radius@topleft
\let\spx@pre@radius@bottomright\spx@pre@radius@topleft
\let\spx@pre@radius@bottomleft \spx@pre@radius@topleft
}
\let\spx@pre@radius@topleft \z@
\let\spx@pre@radius@topright \spx@pre@radius@topleft
\let\spx@pre@radius@bottomright\spx@pre@radius@topleft
\let\spx@pre@radius@bottomleft \spx@pre@radius@topleft
\AtBeginDocument{\if1\ifdim\spx@pre@radius@topleft>\z@0\fi
\ifdim\spx@pre@radius@topright>\z@0\fi
\ifdim\spx@pre@radius@bottomright>\z@0\fi
\ifdim\spx@pre@radius@bottomleft>\z@0\fi
1\else\spx@RequirePackage@PictIIe\fi}
%
\newif\ifspx@pre@withshadow
\newif\ifspx@pre@insetshadow
% Attention only "none" or "<xoffset> <yoffset> [optional inset]", no color
\define@key{sphinx}{pre_box-shadow}{\spx@pre@box@shadow@setter #1 {} {} \@nnil}%
% TODO add parsing to fetch color... but this requires a TeX layer to convert
% color spec in CSS format to color/xcolor format
\def\spx@pre@box@shadow@setter #1 #2 #3 #4\@nnil{%
\edef\spx@tempa{#1}%
\ifx\spx@tempa\spxstring@none
\spx@pre@withshadowfalse
\else
\spx@pre@withshadowtrue
\edef\spx@pre@shadow@xoffset{\number\dimexpr#1\relax sp}%
\edef\spx@pre@shadow@yoffset{\number\dimexpr#2+\z@\relax sp}%
\if\relax\detokenize{#3}\relax
\spx@pre@insetshadowfalse
\else
\spx@pre@insetshadowtrue
\fi
\fi
}%
\spx@pre@box@shadow@setter none {} {} \@nnil
%
\newif\ifspx@pre@withbordercolor
\define@key{sphinx}{pre_border-TeXcolor}{%
\spx@pre@withbordercolortrue
\definecolor{VerbatimBorderColor}#1%
}
\expandafter\let\expandafter\KV@sphinx@VerbatimBorderColor
\csname KV@sphinx@pre_border-TeXcolor\endcsname
\newif\ifspx@pre@withbackgroundcolor
\define@key{sphinx}{pre_background-TeXcolor}{%
\spx@pre@withbackgroundcolortrue
\definecolor{VerbatimColor}#1%
}
\expandafter\let\expandafter\KV@sphinx@VerbatimColor
\csname KV@sphinx@pre_background-TeXcolor\endcsname
\newif\ifspx@pre@withshadowcolor
\define@key{sphinx}{pre_box-shadow-TeXcolor}{%
\spx@pre@withshadowcolortrue
\definecolor{sphinxVerbatimShadowColor}#1%
}
\definecolor{sphinxVerbatimShadowColor}{rgb}{0,0,0}
% topics
\let\spxdimen@topic@border\sphinxshadowrule
\define@key{sphinx}{aside.topic_border-top-width}{\def\spx@topic@border@top{#1}}
\define@key{sphinx}{aside.topic_border-right-width}{\def\spx@topic@border@right{#1}}
\define@key{sphinx}{aside.topic_border-bottom-width}{\def\spx@topic@border@bottom{#1}}
\define@key{sphinx}{aside.topic_border-left-width}{\def\spx@topic@border@left{#1}}
% attention currently accepts only one dimension specification
\define@key{sphinx}{aside.topic_border-width}{%
\spxdimen@topic@border\dimexpr #1\relax
\def\spx@topic@border@top {\spxdimen@topic@border}%
\let\spx@topic@border@right \spx@topic@border@top
\let\spx@topic@border@bottom\spx@topic@border@top
\let\spx@topic@border@left \spx@topic@border@top
}
\let\spx@topic@border@top \spxdimen@topic@border
\let\spx@topic@border@right \spx@topic@border@top
\let\spx@topic@border@bottom\spx@topic@border@top
\let\spx@topic@border@left \spx@topic@border@top
\expandafter\let\expandafter\KV@sphinx@shadowrule
\csname KV@sphinx@topic_border-width\endcsname
\newif\ifspx@topic@border@open % defaults to false (legacy)
\define@key{sphinx}{aside.topic_box-decoration-break}%
{\edef\spx@tempa{#1}%
\ifx\spx@tempa\spxstring@clone
\spx@topic@border@openfalse
\else\spx@topic@border@opentrue\fi}%
%
% MEMO: \sphinxshadowsep not used anywhere anymore in code base and to be removed
\define@key{sphinx}{topic_padding-top}{\def\spx@topic@padding@top{#1}}
\define@key{sphinx}{topic_padding-right}{\def\spx@topic@padding@right{#1}}
\define@key{sphinx}{topic_padding-bottom}{\def\spx@topic@padding@bottom{#1}}
\define@key{sphinx}{topic_padding-left}{\def\spx@topic@padding@left{#1}}
\define@key{sphinx}{topic_padding}{%
\def\spx@topic@padding@top {#1}%
\let\spx@topic@padding@right \spx@topic@padding@top
\let\spx@topic@padding@bottom\spx@topic@padding@top
\let\spx@topic@padding@left \spx@topic@padding@top
}
\def\spx@topic@padding@top {5pt}% no usage anymore of \sphinxshadowsep dimen register
\let\spx@topic@padding@right \spx@topic@padding@top
\let\spx@topic@padding@bottom\spx@topic@padding@top
\let\spx@topic@padding@left \spx@topic@padding@top
\expandafter\let\expandafter\KV@sphinx@shadowsep
\csname KV@sphinx@topic_padding\endcsname
%
\def\spx@topic@radius@topleft{\z@}
\def\spx@topic@radius@topright{\z@}
\def\spx@topic@radius@bottomright{\z@}
\def\spx@topic@radius@bottomleft{\z@}
\define@key{sphinx}{aside.topic_border-top-left-radius}{\def\spx@topic@radius@topleft{#1}}
\define@key{sphinx}{aside.topic_border-top-right-radius}{\def\spx@topic@radius@topright{#1}}
\define@key{sphinx}{aside.topic_border-bottom-right-radius}{\def\spx@topic@radius@bottomright{#1}}
\define@key{sphinx}{aside.topic_border-bottom-left-radius}{\def\spx@topic@radius@bottomleft{#1}}
\define@key{sphinx}{aside.topic_border-radius}{%
\def\spx@topic@radius@topleft {#1}%
\let\spx@topic@radius@topright \spx@topic@radius@topleft
\let\spx@topic@radius@bottomright\spx@topic@radius@topleft
\let\spx@topic@radius@bottomleft \spx@topic@radius@topleft
}
\let\spx@topic@radius@topleft \z@
\let\spx@topic@radius@topright \spx@topic@radius@topleft
\let\spx@topic@radius@bottomright\spx@topic@radius@topleft
\let\spx@topic@radius@bottomleft \spx@topic@radius@topleft
\AtBeginDocument{\if1\ifdim\spx@topic@radius@topleft>\z@0\fi
\ifdim\spx@topic@radius@topright>\z@0\fi
\ifdim\spx@topic@radius@bottomright>\z@0\fi
\ifdim\spx@topic@radius@bottomleft>\z@0\fi
1\else\spx@RequirePackage@PictIIe\fi}
%
\newif\ifspx@topic@withshadow
\newif\ifspx@topic@insetshadow
% Attention only "none" or "<xoffset> <yoffset> [optional inset]", no color
\define@key{sphinx}{aside.topic_box-shadow}{\spx@topic@box@shadow@setter #1 {} {} \@nnil}%
\def\spx@topic@box@shadow@setter #1 #2 #3 #4\@nnil{%
\edef\spx@tempa{#1}%
\ifx\spx@tempa\spxstring@none
\spx@topic@withshadowfalse
\else
\spx@topic@withshadowtrue
\edef\spx@topic@shadow@xoffset{\number\dimexpr#1\relax sp}%
\edef\spx@topic@shadow@yoffset{\number\dimexpr#2+\z@\relax sp}%
\if\relax\detokenize{#3}\relax
\spx@topic@insetshadowfalse
\else
\spx@topic@insetshadowtrue
\fi
\fi
}%
\spx@topic@box@shadow@setter 4pt 4pt {} \@nnil
% Suport for legacy shadowsize, the \sphinxshadowsize \dimen register
% is not used anymore and should not even be allocated in future
\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@box@withshadowtrue
\else
\spx@topic@box@withshadowfalse
\spx@topic@box@shadow@insetfalse
\fi
}%
\definecolor{sphinxTopicBorderColor}{rgb}{0,0,0}
\definecolor{sphinxTopicBackgroundColor}{rgb}{1,1,1}
\definecolor{sphinxTopicShadowColor}{rgb}{0,0,0}
\newif\ifspx@topic@withbordercolor
\define@key{sphinx}{aside.topic_border-TeXcolor}{%
\spx@topic@withbordercolortrue
\definecolor{sphinxTopicBorderColor}#1%
}
\newif\ifspx@topic@withbackgroundcolor
\define@key{sphinx}{aside.topic_background-TeXcolor}{%
\spx@topic@withbackgroundcolortrue
\definecolor{sphinxTopicBackgroundColor}#1%
}
\newif\ifspx@topic@withshadowcolor
\define@key{sphinx}{aside.topic_box-shadow-TeXcolor}{%
\spx@topic@withshadowcolortrue
\definecolor{sphinxTopicShadowColor}#1%
}
% warning, caution, attention, danger, error
\def\spx@tempc#1{%
\expandafter\spx@tempb
% MEMO: the diverging naming of first one is conditioned at this time by the fact
% that sphinxnotice environment must work both for these admonitions and the
% note, tip etc... ones
\csname spx@opt@#1border\expandafter\endcsname
\csname spx@#1@border@top\expandafter\endcsname
\csname spx@#1@border@right\expandafter\endcsname
\csname spx@#1@border@left\expandafter\endcsname
\csname spx@#1@border@bottom\expandafter\endcsname
\csname ifspx@#1@border@open\expandafter\endcsname
\csname spx@#1@border@opentrue\expandafter\endcsname
\csname spx@#1@border@openfalse\endcsname
{#1}%
}%
\def\spx@tempb #1#2#3#4#5#6#7#8#9{%
\define@key{sphinx}{div.#9_border-top-width}{\def#2{##1}}%
\define@key{sphinx}{div.#9_border-right-width}{\def#3{##1}}%
\define@key{sphinx}{div.#9_border-bottom-width}{\def#4{##1}}%
\define@key{sphinx}{div.#9_border-left-width}{\def#5{##1}}%
\define@key{sphinx}{div.#9_border-width}{\def#1{##1}\def#2{#1}\let#3#2\let#4#2\let#5#2}%
\def#1{1pt}\let#2#1\let#3#2\let#4#2\let#5#2%
\newif#6%
\define@key{sphinx}{div.#9_box-decoration-break}%
{\edef\spx@tempa{##1}%
\ifx\spx@tempa\spxstring@clone#8\else#7\fi}%
\expandafter\let\csname KV@sphinx@#9border\expandafter\endcsname
\csname KV@sphinx@div.#9_border-width\endcsname
}
\spx@tempc{warning}
\spx@tempc{caution}
\spx@tempc{attention}
\spx@tempc{danger}
\spx@tempc{error}
\def\spx@tempc#1{%
\expandafter\spx@tempb
\csname spx@#1@padding\expandafter\endcsname
\csname spx@#1@padding@top\expandafter\endcsname
\csname spx@#1@padding@right\expandafter\endcsname
\csname spx@#1@padding@left\expandafter\endcsname
\csname spx@#1@padding@bottom\endcsname
{#1}%
}%
\def\spx@tempb #1#2#3#4#5#6{%
\define@key{sphinx}{div.#6_padding-top}{\def#2{##1}}%
\define@key{sphinx}{div.#6_padding-right}{\def#3{##1}}%
\define@key{sphinx}{div.#6_padding-bottom}{\def#4{##1}}%
\define@key{sphinx}{div.#6_padding-left}{\def#5{##1}}%
\define@key{sphinx}{div.#6_padding}{\def#1{##1}\def#2{#1}\let#3#2\let#4#2\let#5#2}%
\edef#1{\number\dimexpr.6\baselineskip-1pt\relax sp}% (from legacy coding in sphinxheavybox)
\let#2#1\let#3#2\let#4#2\let#5#2%
\expandafter\let\csname KV@sphinx@#6padding\expandafter\endcsname
\csname KV@sphinx@div.#6_padding\endcsname
}
\spx@tempc{warning}
\spx@tempc{caution}
\spx@tempc{attention}
\spx@tempc{danger}
\spx@tempc{error}
\def\spx@tempc#1{%
\expandafter\spx@tempb
\csname spx@#1@radius@topleft\expandafter\endcsname
\csname spx@#1@radius@topright\expandafter\endcsname
\csname spx@#1@radius@bottomright\expandafter\endcsname
\csname spx@#1@radius@bottomleft\endcsname
{#1}%
}%
\def\spx@tempb #1#2#3#4#5{%
\define@key{sphinx}{div.#5_border-top-left-radius}{\def#1{##1}}%
\define@key{sphinx}{div.#5_border-top-right-radius}{\def#2{##1}}%
\define@key{sphinx}{div.#5_border-bottom-right-radius}{\def#3{##1}}%
\define@key{sphinx}{div.#5_border-bottom-left-radius}{\def#4{##1}}%
\define@key{sphinx}{div.#5_border-radius}{\def#1{##1}\let#2#1\let#3#1\let#4#1}%
\let#1\z@\let#2#1\let#3#2\let#4#2%
\AtBeginDocument{\if1\ifdim#1>\z@0\fi
\ifdim#2>\z@0\fi
\ifdim#3>\z@0\fi
\ifdim#4>\z@0\fi
1\else\spx@RequirePackage@PictIIe\fi}%
}
\spx@tempc{warning}
\spx@tempc{caution}
\spx@tempc{attention}
\spx@tempc{danger}
\spx@tempc{error}
\def\spx@tempc#1{%
\expandafter\spx@tempb
\csname ifspx@#1@withshadow\expandafter\endcsname
\csname ifspx@#1@insetshadow\expandafter\endcsname
\csname ifspx@#1@withshadowcolor\expandafter\endcsname
\csname ifspx@#1@withbordercolor\expandafter\endcsname
\csname ifspx@#1@withbackgroundcolor\endcsname
}%
\def\spx@tempb#1#2#3#4#5{\newif#1\newif#2\newif#3\newif#4\newif#5}%
\spx@tempc{warning}
\spx@tempc{caution}
\spx@tempc{attention}
\spx@tempc{danger}
\spx@tempc{error}
\def\spx@tempc#1{%
\expandafter\spx@tempb
\csname spx@#1@withshadowtrue\expandafter\endcsname
\csname spx@#1@withshadowfalse\expandafter\endcsname
\csname spx@#1@insetshadowtrue\expandafter\endcsname
\csname spx@#1@insetshadowfalse\expandafter\endcsname
\csname spx@#1@box@shadow@setter\expandafter\endcsname
\csname spx@#1@box@shadow@xoffset\expandafter\endcsname
\csname spx@#1@box@shadow@yoffset\endcsname
{#1}%
}%
\def\spx@tempb#1#2#3#4#5#6#7#8{%
\define@key{sphinx}{div.#8_box-shadow}{#5##1 {} {} \@nnil}%
\def#5##1 ##2 ##3 ##4\@nnil{%
\edef\spx@tempa{##1}%
\ifx\spx@tempa\spxstring@none
#2%
\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
}
\spx@tempc{warning}
\spx@tempc{caution}
\spx@tempc{attention}
\spx@tempc{danger}
\spx@tempc{error}
\def\spx@tempc#1{%
\expandafter\spx@tempb
\csname spx@#1@withbordercolortrue\expandafter\endcsname
\csname spx@#1@withbackgroundcolortrue\expandafter\endcsname
\csname spx@#1@withshadowcolortrue\endcsname
{#1}%
}
\def\spx@tempb#1#2#3#4{%
\definecolor{sphinx#4BorderColor}{rgb}{0,0,0}%
\definecolor{sphinx#4BgColor}{rgb}{1,1,1}%
\definecolor{sphinx#4ShadowColor}{rgb}{0,0,0}%
\define@key{sphinx}{div.#4_border-TeXcolor}{#1\definecolor{sphinx#4BorderColor}##1}%
\define@key{sphinx}{div.#4_background-TeXcolor}{#2\definecolor{sphinx#4BgColor}##1}%
\define@key{sphinx}{div.#4_box-shadow-TeXcolor}{#3\definecolor{sphinx#4ShadowColor}##1}%
\expandafter\let\csname KV@sphinx@#4BorderColor\expandafter\endcsname
\csname KV@sphinx@div.#4_border-TeXcolor\endcsname
\expandafter\let\csname KV@sphinx@#4BgColor\expandafter\endcsname
\csname KV@sphinx@div.#4_background-TeXcolor\endcsname
}
\spx@tempc{warning}
\spx@tempc{caution}
\spx@tempc{attention}
\spx@tempc{danger}
\spx@tempc{error}
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
% don't allow use of maxlistdepth via \sphinxsetup.
\DisableKeyvalOption{sphinx}{maxlistdepth}
\DisableKeyvalOption{sphinx}{numfigreset}
\DisableKeyvalOption{sphinx}{nonumfigreset}
\DisableKeyvalOption{sphinx}{mathnumfig}
% 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[1]{\setkeys{sphinx}{#1}}
%% 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
%
\RequirePackage{sphinxpackageboxes}
\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