summaryrefslogtreecommitdiffstats
path: root/sphinx/texinputs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:25:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:25:40 +0000
commitcf7da1843c45a4c2df7a749f7886a2d2ba0ee92a (patch)
tree18dcde1a8d1f5570a77cd0c361de3b490d02c789 /sphinx/texinputs
parentInitial commit. (diff)
downloadsphinx-cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a.tar.xz
sphinx-cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a.zip
Adding upstream version 7.2.6.upstream/7.2.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sphinx/texinputs')
-rw-r--r--sphinx/texinputs/LICRcyr2utf8.xdy101
-rw-r--r--sphinx/texinputs/LICRlatin2utf8.xdy239
-rw-r--r--sphinx/texinputs/LatinRules.xdy611
-rw-r--r--sphinx/texinputs/Makefile_t92
-rw-r--r--sphinx/texinputs/latexmkjarc_t22
-rw-r--r--sphinx/texinputs/latexmkrc_t32
-rw-r--r--sphinx/texinputs/make.bat_t50
-rw-r--r--sphinx/texinputs/python.ist16
-rw-r--r--sphinx/texinputs/sphinx.sty1013
-rw-r--r--sphinx/texinputs/sphinx.xdy230
-rw-r--r--sphinx/texinputs/sphinxhowto.cls102
-rw-r--r--sphinx/texinputs/sphinxlatexadmonitions.sty242
-rw-r--r--sphinx/texinputs/sphinxlatexcontainers.sty22
-rw-r--r--sphinx/texinputs/sphinxlatexgraphics.sty122
-rw-r--r--sphinx/texinputs/sphinxlatexindbibtoc.sty69
-rw-r--r--sphinx/texinputs/sphinxlatexlists.sty131
-rw-r--r--sphinx/texinputs/sphinxlatexliterals.sty1004
-rw-r--r--sphinx/texinputs/sphinxlatexnumfig.sty122
-rw-r--r--sphinx/texinputs/sphinxlatexobjects.sty365
-rw-r--r--sphinx/texinputs/sphinxlatexshadowbox.sty116
-rw-r--r--sphinx/texinputs/sphinxlatexstyleheadings.sty86
-rw-r--r--sphinx/texinputs/sphinxlatexstylepage.sty79
-rw-r--r--sphinx/texinputs/sphinxlatexstyletext.sty181
-rw-r--r--sphinx/texinputs/sphinxlatextables.sty1246
-rw-r--r--sphinx/texinputs/sphinxmanual.cls128
-rw-r--r--sphinx/texinputs/sphinxoptionsgeometry.sty54
-rw-r--r--sphinx/texinputs/sphinxoptionshyperref.sty35
-rw-r--r--sphinx/texinputs/sphinxpackageboxes.sty854
-rw-r--r--sphinx/texinputs/sphinxpackagecyrillic.sty55
-rw-r--r--sphinx/texinputs/sphinxpackagefootnote.sty433
30 files changed, 7852 insertions, 0 deletions
diff --git a/sphinx/texinputs/LICRcyr2utf8.xdy b/sphinx/texinputs/LICRcyr2utf8.xdy
new file mode 100644
index 0000000..a9ca1c8
--- /dev/null
+++ b/sphinx/texinputs/LICRcyr2utf8.xdy
@@ -0,0 +1,101 @@
+;; -*- coding: utf-8; mode: Lisp; -*-
+;; style file for xindy
+;; filename: LICRcyr2utf8.xdy
+;; description: style file for xindy which maps back LaTeX Internal
+;; Character Representation of Cyrillic to utf-8
+;; usage: for use with pdflatex produced .idx files.
+;; Contributed by the Sphinx team, July 2018.
+(merge-rule "\IeC {\'\CYRG }" "Ѓ" :string)
+(merge-rule "\IeC {\'\CYRK }" "Ќ" :string)
+(merge-rule "\IeC {\'\cyrg }" "ѓ" :string)
+(merge-rule "\IeC {\'\cyrk }" "ќ" :string)
+(merge-rule "\IeC {\CYRA }" "А" :string)
+(merge-rule "\IeC {\CYRB }" "Б" :string)
+(merge-rule "\IeC {\CYRC }" "Ц" :string)
+(merge-rule "\IeC {\CYRCH }" "Ч" :string)
+(merge-rule "\IeC {\CYRD }" "Д" :string)
+(merge-rule "\IeC {\CYRDJE }" "Ђ" :string)
+(merge-rule "\IeC {\CYRDZE }" "Ѕ" :string)
+(merge-rule "\IeC {\CYRDZHE }" "Џ" :string)
+(merge-rule "\IeC {\CYRE }" "Е" :string)
+(merge-rule "\IeC {\CYREREV }" "Э" :string)
+(merge-rule "\IeC {\CYRERY }" "Ы" :string)
+(merge-rule "\IeC {\CYRF }" "Ф" :string)
+(merge-rule "\IeC {\CYRG }" "Г" :string)
+(merge-rule "\IeC {\CYRGUP }" "Ґ" :string)
+(merge-rule "\IeC {\CYRH }" "Х" :string)
+(merge-rule "\IeC {\CYRHRDSN }" "Ъ" :string)
+(merge-rule "\IeC {\CYRI }" "И" :string)
+(merge-rule "\IeC {\CYRIE }" "Є" :string)
+(merge-rule "\IeC {\CYRII }" "І" :string)
+(merge-rule "\IeC {\CYRISHRT }" "Й" :string)
+(merge-rule "\IeC {\CYRJE }" "Ј" :string)
+(merge-rule "\IeC {\CYRK }" "К" :string)
+(merge-rule "\IeC {\CYRL }" "Л" :string)
+(merge-rule "\IeC {\CYRLJE }" "Љ" :string)
+(merge-rule "\IeC {\CYRM }" "М" :string)
+(merge-rule "\IeC {\CYRN }" "Н" :string)
+(merge-rule "\IeC {\CYRNJE }" "Њ" :string)
+(merge-rule "\IeC {\CYRO }" "О" :string)
+(merge-rule "\IeC {\CYRP }" "П" :string)
+(merge-rule "\IeC {\CYRR }" "Р" :string)
+(merge-rule "\IeC {\CYRS }" "С" :string)
+(merge-rule "\IeC {\CYRSFTSN }" "Ь" :string)
+(merge-rule "\IeC {\CYRSH }" "Ш" :string)
+(merge-rule "\IeC {\CYRSHCH }" "Щ" :string)
+(merge-rule "\IeC {\CYRT }" "Т" :string)
+(merge-rule "\IeC {\CYRTSHE }" "Ћ" :string)
+(merge-rule "\IeC {\CYRU }" "У" :string)
+(merge-rule "\IeC {\CYRUSHRT }" "Ў" :string)
+(merge-rule "\IeC {\CYRV }" "В" :string)
+(merge-rule "\IeC {\CYRYA }" "Я" :string)
+(merge-rule "\IeC {\CYRYI }" "Ї" :string)
+(merge-rule "\IeC {\CYRYO }" "Ё" :string)
+(merge-rule "\IeC {\CYRYU }" "Ю" :string)
+(merge-rule "\IeC {\CYRZ }" "З" :string)
+(merge-rule "\IeC {\CYRZH }" "Ж" :string)
+(merge-rule "\IeC {\cyra }" "а" :string)
+(merge-rule "\IeC {\cyrb }" "б" :string)
+(merge-rule "\IeC {\cyrc }" "ц" :string)
+(merge-rule "\IeC {\cyrch }" "ч" :string)
+(merge-rule "\IeC {\cyrd }" "д" :string)
+(merge-rule "\IeC {\cyrdje }" "ђ" :string)
+(merge-rule "\IeC {\cyrdze }" "ѕ" :string)
+(merge-rule "\IeC {\cyrdzhe }" "џ" :string)
+(merge-rule "\IeC {\cyre }" "е" :string)
+(merge-rule "\IeC {\cyrerev }" "э" :string)
+(merge-rule "\IeC {\cyrery }" "ы" :string)
+(merge-rule "\IeC {\cyrf }" "ф" :string)
+(merge-rule "\IeC {\cyrg }" "г" :string)
+(merge-rule "\IeC {\cyrgup }" "ґ" :string)
+(merge-rule "\IeC {\cyrh }" "х" :string)
+(merge-rule "\IeC {\cyrhrdsn }" "ъ" :string)
+(merge-rule "\IeC {\cyri }" "и" :string)
+(merge-rule "\IeC {\cyrie }" "є" :string)
+(merge-rule "\IeC {\cyrii }" "і" :string)
+(merge-rule "\IeC {\cyrishrt }" "й" :string)
+(merge-rule "\IeC {\cyrje }" "ј" :string)
+(merge-rule "\IeC {\cyrk }" "к" :string)
+(merge-rule "\IeC {\cyrl }" "л" :string)
+(merge-rule "\IeC {\cyrlje }" "љ" :string)
+(merge-rule "\IeC {\cyrm }" "м" :string)
+(merge-rule "\IeC {\cyrn }" "н" :string)
+(merge-rule "\IeC {\cyrnje }" "њ" :string)
+(merge-rule "\IeC {\cyro }" "о" :string)
+(merge-rule "\IeC {\cyrp }" "п" :string)
+(merge-rule "\IeC {\cyrr }" "р" :string)
+(merge-rule "\IeC {\cyrs }" "с" :string)
+(merge-rule "\IeC {\cyrsftsn }" "ь" :string)
+(merge-rule "\IeC {\cyrsh }" "ш" :string)
+(merge-rule "\IeC {\cyrshch }" "щ" :string)
+(merge-rule "\IeC {\cyrt }" "т" :string)
+(merge-rule "\IeC {\cyrtshe }" "ћ" :string)
+(merge-rule "\IeC {\cyru }" "у" :string)
+(merge-rule "\IeC {\cyrushrt }" "ў" :string)
+(merge-rule "\IeC {\cyrv }" "в" :string)
+(merge-rule "\IeC {\cyrya }" "я" :string)
+(merge-rule "\IeC {\cyryi }" "ї" :string)
+(merge-rule "\IeC {\cyryo }" "ё" :string)
+(merge-rule "\IeC {\cyryu }" "ю" :string)
+(merge-rule "\IeC {\cyrz }" "з" :string)
+(merge-rule "\IeC {\cyrzh }" "ж" :string)
diff --git a/sphinx/texinputs/LICRlatin2utf8.xdy b/sphinx/texinputs/LICRlatin2utf8.xdy
new file mode 100644
index 0000000..1d76825
--- /dev/null
+++ b/sphinx/texinputs/LICRlatin2utf8.xdy
@@ -0,0 +1,239 @@
+;; style file for xindy
+;; filename: LICRlatin2utf8.xdy
+;; description: style file for xindy which maps back LaTeX Internal
+;; Character Representation of letters (as arising in .idx index
+;; file) to UTF-8 encoding for correct sorting by xindy.
+;; usage: for use with the pdflatex engine,
+;; *not* for use with xelatex or lualatex.
+;;
+;; This is based upon xindy's distributed file tex/inputenc/utf8.xdy.
+;; The modifications include:
+;;
+;; - Updates for compatibility with current LaTeX macro encoding.
+;;
+;; - Systematic usage of the \IeC {...} mark-up, because mark-up in
+;; tex/inputenc/utf8.xdy was using it on seemingly random basis, and
+;; Sphinx coercing of xindy usability for both Latin and Cyrillic scripts
+;; with pdflatex requires its systematic presence here.
+;;
+;; - Support for some extra letters: Ÿ, Ŋ, ŋ, Œ, œ, IJ, ij, ȷ and ẞ.
+;;
+;; Indeed Sphinx needs to support for pdflatex engine all Unicode letters
+;; available in TeX T1 font encoding. The above letters are found in
+;; that encoding but not in the Latin1, 2, 3 charsets which are those
+;; covered by original tex/inputenc/utf8.xdy.
+;;
+;; - There is a problem that ȷ is not supported out-of-the box by LaTeX
+;; with inputenc, one must add explicitly
+;; \DeclareUnicodeCharacter{0237}{\j}
+;; to preamble of LaTeX document. However this character is not supported
+;; by the TeX "times" font used by default by Sphinx for pdflatex engine.
+;;
+;; **Update**: since LaTeX 2018/12/01, the \j as well as \SS, \k{} and
+;; \.{} need no extra user declaration anymore.
+;;
+;; - ẞ needs \DeclareUnicodeCharacter{1E9E}{\SS} (but ß needs no extra set-up).
+;;
+;; - U+02DB (˛) and U+02D9 (˙) are also not supported by inputenc
+;; out of the box and require
+;; \DeclareUnicodeCharacter{02DB}{\k{}}
+;; \DeclareUnicodeCharacter{02D9}{\.{}}
+;; to be added to preamble.
+;;
+;; - U+0127 ħ and U+0126 Ħ are absent from TeX T1+TS1 font encodings.
+;;
+;; - Characters Ŋ and ŋ are not supported by TeX font "times" used by
+;; default by Sphinx for pdflatex engine but they are supported by
+;; some TeX fonts, in particular by the default LaTeX font for T1
+;; encoding.
+;;
+;; - " and ~ must be escaped as ~" and resp. ~~ in xindy merge rules.
+;;
+;; Contributed by the Sphinx team, July 2018.
+;;
+;; See sphinx.xdy for superior figures, as they are escaped by LaTeX writer.
+(merge-rule "\IeC {\textonesuperior }" "¹" :string)
+(merge-rule "\IeC {\texttwosuperior }" "²" :string)
+(merge-rule "\IeC {\textthreesuperior }" "³" :string)
+(merge-rule "\IeC {\'a}" "á" :string)
+(merge-rule "\IeC {\'A}" "Á" :string)
+(merge-rule "\IeC {\`a}" "à" :string)
+(merge-rule "\IeC {\`A}" "À" :string)
+(merge-rule "\IeC {\^a}" "â" :string)
+(merge-rule "\IeC {\^A}" "Â" :string)
+(merge-rule "\IeC {\~"a}" "ä" :string)
+(merge-rule "\IeC {\~"A}" "Ä" :string)
+(merge-rule "\IeC {\~~a}" "ã" :string)
+(merge-rule "\IeC {\~~A}" "Ã" :string)
+(merge-rule "\IeC {\c c}" "ç" :string)
+(merge-rule "\IeC {\c C}" "Ç" :string)
+(merge-rule "\IeC {\'c}" "ć" :string)
+(merge-rule "\IeC {\'C}" "Ć" :string)
+(merge-rule "\IeC {\^c}" "ĉ" :string)
+(merge-rule "\IeC {\^C}" "Ĉ" :string)
+(merge-rule "\IeC {\.c}" "ċ" :string)
+(merge-rule "\IeC {\.C}" "Ċ" :string)
+(merge-rule "\IeC {\c s}" "ş" :string)
+(merge-rule "\IeC {\c S}" "Ş" :string)
+(merge-rule "\IeC {\c t}" "ţ" :string)
+(merge-rule "\IeC {\c T}" "Ţ" :string)
+(merge-rule "\IeC {\-}" "­" :string); soft hyphen
+(merge-rule "\IeC {\textdiv }" "÷" :string)
+(merge-rule "\IeC {\'e}" "é" :string)
+(merge-rule "\IeC {\'E}" "É" :string)
+(merge-rule "\IeC {\`e}" "è" :string)
+(merge-rule "\IeC {\`E}" "È" :string)
+(merge-rule "\IeC {\^e}" "ê" :string)
+(merge-rule "\IeC {\^E}" "Ê" :string)
+(merge-rule "\IeC {\~"e}" "ë" :string)
+(merge-rule "\IeC {\~"E}" "Ë" :string)
+(merge-rule "\IeC {\^g}" "ĝ" :string)
+(merge-rule "\IeC {\^G}" "Ĝ" :string)
+(merge-rule "\IeC {\.g}" "ġ" :string)
+(merge-rule "\IeC {\.G}" "Ġ" :string)
+(merge-rule "\IeC {\^h}" "ĥ" :string)
+(merge-rule "\IeC {\^H}" "Ĥ" :string)
+(merge-rule "\IeC {\H o}" "ő" :string)
+(merge-rule "\IeC {\H O}" "Ő" :string)
+(merge-rule "\IeC {\textacutedbl }" "˝" :string)
+(merge-rule "\IeC {\H u}" "ű" :string)
+(merge-rule "\IeC {\H U}" "Ű" :string)
+(merge-rule "\IeC {\ae }" "æ" :string)
+(merge-rule "\IeC {\AE }" "Æ" :string)
+(merge-rule "\IeC {\textcopyright }" "©" :string)
+(merge-rule "\IeC {\c \ }" "¸" :string)
+(merge-rule "\IeC {\dh }" "ð" :string)
+(merge-rule "\IeC {\DH }" "Ð" :string)
+(merge-rule "\IeC {\dj }" "đ" :string)
+(merge-rule "\IeC {\DJ }" "Đ" :string)
+(merge-rule "\IeC {\guillemotleft }" "«" :string)
+(merge-rule "\IeC {\guillemotright }" "»" :string)
+(merge-rule "\IeC {\'\i }" "í" :string)
+(merge-rule "\IeC {\`\i }" "ì" :string)
+(merge-rule "\IeC {\^\i }" "î" :string)
+(merge-rule "\IeC {\~"\i }" "ï" :string)
+(merge-rule "\IeC {\i }" "ı" :string)
+(merge-rule "\IeC {\^\j }" "ĵ" :string)
+(merge-rule "\IeC {\k {}}" "˛" :string)
+(merge-rule "\IeC {\l }" "ł" :string)
+(merge-rule "\IeC {\L }" "Ł" :string)
+(merge-rule "\IeC {\nobreakspace }" " " :string)
+(merge-rule "\IeC {\o }" "ø" :string)
+(merge-rule "\IeC {\O }" "Ø" :string)
+(merge-rule "\IeC {\textsterling }" "£" :string)
+(merge-rule "\IeC {\textparagraph }" "¶" :string)
+(merge-rule "\IeC {\ss }" "ß" :string)
+(merge-rule "\IeC {\textsection }" "§" :string)
+(merge-rule "\IeC {\textbrokenbar }" "¦" :string)
+(merge-rule "\IeC {\textcent }" "¢" :string)
+(merge-rule "\IeC {\textcurrency }" "¤" :string)
+(merge-rule "\IeC {\textdegree }" "°" :string)
+(merge-rule "\IeC {\textexclamdown }" "¡" :string)
+(merge-rule "\IeC {\texthbar }" "ħ" :string)
+(merge-rule "\IeC {\textHbar }" "Ħ" :string)
+(merge-rule "\IeC {\textonehalf }" "½" :string)
+(merge-rule "\IeC {\textonequarter }" "¼" :string)
+(merge-rule "\IeC {\textordfeminine }" "ª" :string)
+(merge-rule "\IeC {\textordmasculine }" "º" :string)
+(merge-rule "\IeC {\textperiodcentered }" "·" :string)
+(merge-rule "\IeC {\textquestiondown }" "¿" :string)
+(merge-rule "\IeC {\textregistered }" "®" :string)
+(merge-rule "\IeC {\textthreequarters }" "¾" :string)
+(merge-rule "\IeC {\textyen }" "¥" :string)
+(merge-rule "\IeC {\th }" "þ" :string)
+(merge-rule "\IeC {\TH }" "Þ" :string)
+(merge-rule "\IeC {\'I}" "Í" :string)
+(merge-rule "\IeC {\`I}" "Ì" :string)
+(merge-rule "\IeC {\^I}" "Î" :string)
+(merge-rule "\IeC {\~"I}" "Ï" :string)
+(merge-rule "\IeC {\.I}" "İ" :string)
+(merge-rule "\IeC {\^J}" "Ĵ" :string)
+(merge-rule "\IeC {\k a}" "ą" :string)
+(merge-rule "\IeC {\k A}" "Ą" :string)
+(merge-rule "\IeC {\k e}" "ę" :string)
+(merge-rule "\IeC {\k E}" "Ę" :string)
+(merge-rule "\IeC {\'l}" "ĺ" :string)
+(merge-rule "\IeC {\'L}" "Ĺ" :string)
+(merge-rule "\IeC {\textlnot }" "¬" :string)
+(merge-rule "\IeC {\textmu }" "µ" :string)
+(merge-rule "\IeC {\'n}" "ń" :string)
+(merge-rule "\IeC {\'N}" "Ń" :string)
+(merge-rule "\IeC {\~~n}" "ñ" :string)
+(merge-rule "\IeC {\~~N}" "Ñ" :string)
+(merge-rule "\IeC {\'o}" "ó" :string)
+(merge-rule "\IeC {\'O}" "Ó" :string)
+(merge-rule "\IeC {\`o}" "ò" :string)
+(merge-rule "\IeC {\`O}" "Ò" :string)
+(merge-rule "\IeC {\^o}" "ô" :string)
+(merge-rule "\IeC {\^O}" "Ô" :string)
+(merge-rule "\IeC {\~"o}" "ö" :string)
+(merge-rule "\IeC {\~"O}" "Ö" :string)
+(merge-rule "\IeC {\~~o}" "õ" :string)
+(merge-rule "\IeC {\~~O}" "Õ" :string)
+(merge-rule "\IeC {\textpm }" "±" :string)
+(merge-rule "\IeC {\r a}" "å" :string)
+(merge-rule "\IeC {\r A}" "Å" :string)
+(merge-rule "\IeC {\'r}" "ŕ" :string)
+(merge-rule "\IeC {\'R}" "Ŕ" :string)
+(merge-rule "\IeC {\r u}" "ů" :string)
+(merge-rule "\IeC {\r U}" "Ů" :string)
+(merge-rule "\IeC {\'s}" "ś" :string)
+(merge-rule "\IeC {\'S}" "Ś" :string)
+(merge-rule "\IeC {\^s}" "ŝ" :string)
+(merge-rule "\IeC {\^S}" "Ŝ" :string)
+(merge-rule "\IeC {\textasciidieresis }" "¨" :string)
+(merge-rule "\IeC {\textasciimacron }" "¯" :string)
+(merge-rule "\IeC {\.{}}" "˙" :string)
+(merge-rule "\IeC {\textasciiacute }" "´" :string)
+(merge-rule "\IeC {\texttimes }" "×" :string)
+(merge-rule "\IeC {\u a}" "ă" :string)
+(merge-rule "\IeC {\u A}" "Ă" :string)
+(merge-rule "\IeC {\u g}" "ğ" :string)
+(merge-rule "\IeC {\u G}" "Ğ" :string)
+(merge-rule "\IeC {\textasciibreve }" "˘" :string)
+(merge-rule "\IeC {\'u}" "ú" :string)
+(merge-rule "\IeC {\'U}" "Ú" :string)
+(merge-rule "\IeC {\`u}" "ù" :string)
+(merge-rule "\IeC {\`U}" "Ù" :string)
+(merge-rule "\IeC {\^u}" "û" :string)
+(merge-rule "\IeC {\^U}" "Û" :string)
+(merge-rule "\IeC {\~"u}" "ü" :string)
+(merge-rule "\IeC {\~"U}" "Ü" :string)
+(merge-rule "\IeC {\u u}" "ŭ" :string)
+(merge-rule "\IeC {\u U}" "Ŭ" :string)
+(merge-rule "\IeC {\v c}" "č" :string)
+(merge-rule "\IeC {\v C}" "Č" :string)
+(merge-rule "\IeC {\v d}" "ď" :string)
+(merge-rule "\IeC {\v D}" "Ď" :string)
+(merge-rule "\IeC {\v e}" "ě" :string)
+(merge-rule "\IeC {\v E}" "Ě" :string)
+(merge-rule "\IeC {\v l}" "ľ" :string)
+(merge-rule "\IeC {\v L}" "Ľ" :string)
+(merge-rule "\IeC {\v n}" "ň" :string)
+(merge-rule "\IeC {\v N}" "Ň" :string)
+(merge-rule "\IeC {\v r}" "ř" :string)
+(merge-rule "\IeC {\v R}" "Ř" :string)
+(merge-rule "\IeC {\v s}" "š" :string)
+(merge-rule "\IeC {\v S}" "Š" :string)
+(merge-rule "\IeC {\textasciicaron }" "ˇ" :string)
+(merge-rule "\IeC {\v t}" "ť" :string)
+(merge-rule "\IeC {\v T}" "Ť" :string)
+(merge-rule "\IeC {\v z}" "ž" :string)
+(merge-rule "\IeC {\v Z}" "Ž" :string)
+(merge-rule "\IeC {\'y}" "ý" :string)
+(merge-rule "\IeC {\'Y}" "Ý" :string)
+(merge-rule "\IeC {\~"y}" "ÿ" :string)
+(merge-rule "\IeC {\'z}" "ź" :string)
+(merge-rule "\IeC {\'Z}" "Ź" :string)
+(merge-rule "\IeC {\.z}" "ż" :string)
+(merge-rule "\IeC {\.Z}" "Ż" :string)
+;; letters not in Latin1, 2, 3 but available in TeX T1 font encoding
+(merge-rule "\IeC {\~"Y}" "Ÿ" :string)
+(merge-rule "\IeC {\NG }" "Ŋ" :string)
+(merge-rule "\IeC {\ng }" "ŋ" :string)
+(merge-rule "\IeC {\OE }" "Œ" :string)
+(merge-rule "\IeC {\oe }" "œ" :string)
+(merge-rule "\IeC {\IJ }" "IJ" :string)
+(merge-rule "\IeC {\ij }" "ij" :string)
+(merge-rule "\IeC {\j }" "ȷ" :string)
+(merge-rule "\IeC {\SS }" "ẞ" :string)
diff --git a/sphinx/texinputs/LatinRules.xdy b/sphinx/texinputs/LatinRules.xdy
new file mode 100644
index 0000000..b20fbbb
--- /dev/null
+++ b/sphinx/texinputs/LatinRules.xdy
@@ -0,0 +1,611 @@
+;; Common Lisp style file for xindy
+;; filename: LatinRules.xdy
+;;
+;; Please note that this data file deliberately uses strings
+;; with single non-ascii bytes. This is intentional and
+;; follows the usage observed in similar xindy support files.
+;;
+;; It is based upon xindy's files lang/general/utf8.xdy and
+;; lang/general/utf8-lang.xdy which implement
+;; "a general sorting order for Western European languages".
+;;
+;; The aim for Sphinx is to be able to index in a Cyrillic document
+;; also terms using the Latin alphabets, inclusive of letters
+;; with diacritics. To this effect the xindy rules from lang/general
+;; got manually re-coded to avoid collisions with the encoding
+;; done by xindy for sorting words in Cyrillic languages, which was
+;; observed not to use bytes with octal encoding 0o266 or higher.
+;;
+;; So here we use only 0o266 or higher bytes.
+;; (Ŋ, ŋ, IJ, and ij are absent from
+;; lang/general/utf8.xdy and not included here.)
+;; Contributed by the Sphinx team, 2018.
+
+(define-letter-group "A" :prefixes (""))
+(define-letter-group "B" :after "A" :prefixes (""))
+(define-letter-group "C" :after "B" :prefixes (""))
+(define-letter-group "D" :after "C" :prefixes (""))
+(define-letter-group "E" :after "D" :prefixes (""))
+(define-letter-group "F" :after "E" :prefixes (""))
+(define-letter-group "G" :after "F" :prefixes (""))
+(define-letter-group "H" :after "G" :prefixes (""))
+(define-letter-group "I" :after "H" :prefixes (""))
+(define-letter-group "J" :after "I" :prefixes (""))
+(define-letter-group "K" :after "J" :prefixes (""))
+(define-letter-group "L" :after "K" :prefixes (""))
+(define-letter-group "M" :after "L" :prefixes (""))
+(define-letter-group "N" :after "M" :prefixes (""))
+(define-letter-group "O" :after "N" :prefixes (""))
+(define-letter-group "P" :after "O" :prefixes (""))
+(define-letter-group "Q" :after "P" :prefixes (""))
+(define-letter-group "R" :after "Q" :prefixes (""))
+(define-letter-group "S" :after "R" :prefixes (""))
+(define-letter-group "T" :after "S" :prefixes (""))
+(define-letter-group "U" :after "T" :prefixes (""))
+(define-letter-group "V" :after "U" :prefixes (""))
+(define-letter-group "W" :after "V" :prefixes (""))
+(define-letter-group "X" :after "W" :prefixes (""))
+(define-letter-group "Y" :after "X" :prefixes (""))
+(define-letter-group "Z" :after "Y" :prefixes (""))
+
+(define-rule-set "sphinx-xy-alphabetize"
+
+ :rules (("À" "" :string)
+ ("Ă" "" :string)
+ ("â" "" :string)
+ ("Ä" "" :string)
+ ("à" "" :string)
+ ("Å" "" :string)
+ ("Ã" "" :string)
+ ("Á" "" :string)
+ ("á" "" :string)
+ ("ã" "" :string)
+ ("Â" "" :string)
+ ("ă" "" :string)
+ ("å" "" :string)
+ ("ą" "" :string)
+ ("ä" "" :string)
+ ("Ą" "" :string)
+ ("æ" "" :string)
+ ("Æ" "" :string)
+ ("ć" "" :string)
+ ("ĉ" "" :string)
+ ("ç" "" :string)
+ ("Č" "" :string)
+ ("č" "" :string)
+ ("Ĉ" "" :string)
+ ("Ç" "" :string)
+ ("Ć" "" :string)
+ ("ď" "" :string)
+ ("Đ" "" :string)
+ ("Ď" "" :string)
+ ("đ" "" :string)
+ ("ê" "" :string)
+ ("Ę" "" :string)
+ ("Ě" "" :string)
+ ("ë" "" :string)
+ ("ě" "" :string)
+ ("é" "" :string)
+ ("È" "" :string)
+ ("Ë" "" :string)
+ ("É" "" :string)
+ ("è" "" :string)
+ ("Ê" "" :string)
+ ("ę" "" :string)
+ ("ĝ" "" :string)
+ ("ğ" "" :string)
+ ("Ğ" "" :string)
+ ("Ĝ" "" :string)
+ ("ĥ" "" :string)
+ ("Ĥ" "" :string)
+ ("Ï" "" :string)
+ ("Í" "" :string)
+ ("ï" "" :string)
+ ("Î" "" :string)
+ ("î" "" :string)
+ ("ı" "" :string)
+ ("İ" "" :string)
+ ("í" "" :string)
+ ("Ì" "" :string)
+ ("ì" "" :string)
+ ("Ĵ" "" :string)
+ ("ĵ" "" :string)
+ ("ł" "" :string)
+ ("Ł" "" :string)
+ ("ľ" "" :string)
+ ("Ľ" "" :string)
+ ("ń" "" :string)
+ ("Ń" "" :string)
+ ("ñ" "" :string)
+ ("ň" "" :string)
+ ("Ñ" "" :string)
+ ("Ň" "" :string)
+ ("Õ" "" :string)
+ ("Ő" "" :string)
+ ("ó" "" :string)
+ ("ö" "" :string)
+ ("ô" "" :string)
+ ("ő" "" :string)
+ ("Ø" "" :string)
+ ("Ö" "" :string)
+ ("õ" "" :string)
+ ("Ô" "" :string)
+ ("ø" "" :string)
+ ("Ó" "" :string)
+ ("Ò" "" :string)
+ ("ò" "" :string)
+ ("œ" "ĺ" :string)
+ ("Œ" "ĺ" :string)
+ ("Ř" "" :string)
+ ("ř" "" :string)
+ ("Ŕ" "" :string)
+ ("ŕ" "" :string)
+ ("ŝ" "" :string)
+ ("Ś" "" :string)
+ ("ș" "" :string)
+ ("ş" "" :string)
+ ("Ŝ" "" :string)
+ ("ś" "" :string)
+ ("Ș" "" :string)
+ ("š" "" :string)
+ ("Ş" "" :string)
+ ("Š" "" :string)
+ ("ß" "" :string)
+ ("Ț" "" :string)
+ ("Ť" "" :string)
+ ("ț" "" :string)
+ ("ť" "" :string)
+ ("û" "" :string)
+ ("ŭ" "" :string)
+ ("ů" "" :string)
+ ("ű" "" :string)
+ ("ù" "" :string)
+ ("Ŭ" "" :string)
+ ("Ù" "" :string)
+ ("Ű" "" :string)
+ ("Ü" "" :string)
+ ("Ů" "" :string)
+ ("ú" "" :string)
+ ("Ú" "" :string)
+ ("Û" "" :string)
+ ("ü" "" :string)
+ ("ÿ" "" :string)
+ ("Ý" "" :string)
+ ("Ÿ" "" :string)
+ ("ý" "" :string)
+ ("Ż" "" :string)
+ ("Ž" "" :string)
+ ("Ź" "" :string)
+ ("ž" "" :string)
+ ("ż" "" :string)
+ ("ź" "" :string)
+ ("a" "" :string)
+ ("A" "" :string)
+ ("b" "" :string)
+ ("B" "" :string)
+ ("c" "" :string)
+ ("C" "" :string)
+ ("d" "" :string)
+ ("D" "" :string)
+ ("e" "" :string)
+ ("E" "" :string)
+ ("F" "" :string)
+ ("f" "" :string)
+ ("G" "" :string)
+ ("g" "" :string)
+ ("H" "" :string)
+ ("h" "" :string)
+ ("i" "" :string)
+ ("I" "" :string)
+ ("J" "" :string)
+ ("j" "" :string)
+ ("K" "" :string)
+ ("k" "" :string)
+ ("L" "" :string)
+ ("l" "" :string)
+ ("M" "" :string)
+ ("m" "" :string)
+ ("n" "" :string)
+ ("N" "" :string)
+ ("O" "" :string)
+ ("o" "" :string)
+ ("p" "" :string)
+ ("P" "" :string)
+ ("Q" "" :string)
+ ("q" "" :string)
+ ("r" "" :string)
+ ("R" "" :string)
+ ("S" "" :string)
+ ("s" "" :string)
+ ("t" "" :string)
+ ("T" "" :string)
+ ("u" "" :string)
+ ("U" "" :string)
+ ("v" "" :string)
+ ("V" "" :string)
+ ("W" "" :string)
+ ("w" "" :string)
+ ("x" "" :string)
+ ("X" "" :string)
+ ("Y" "" :string)
+ ("y" "" :string)
+ ("z" "" :string)
+ ("Z" "" :string)
+ ))
+
+(define-rule-set "sphinx-xy-resolve-diacritics"
+
+ :rules (("Ĥ" "" :string)
+ ("ó" "" :string)
+ ("ľ" "" :string)
+ ("Ř" "" :string)
+ ("ĝ" "" :string)
+ ("ď" "" :string)
+ ("Ě" "" :string)
+ ("ĥ" "" :string)
+ ("Č" "" :string)
+ ("Ĵ" "" :string)
+ ("ě" "" :string)
+ ("ž" "" :string)
+ ("Ď" "" :string)
+ ("ř" "" :string)
+ ("Ž" "" :string)
+ ("ı" "" :string)
+ ("Ť" "" :string)
+ ("á" "" :string)
+ ("č" "" :string)
+ ("Á" "" :string)
+ ("ň" "" :string)
+ ("Š" "" :string)
+ ("Ň" "" :string)
+ ("ĵ" "" :string)
+ ("ť" "" :string)
+ ("Ó" "" :string)
+ ("ý" "" :string)
+ ("Ĝ" "" :string)
+ ("Ú" "" :string)
+ ("Ľ" "" :string)
+ ("š" "" :string)
+ ("Ý" "" :string)
+ ("ú" "" :string)
+ ("Ś" "" :string)
+ ("ć" "" :string)
+ ("Ł" "" :string)
+ ("ł" "" :string)
+ ("ń" "" :string)
+ ("À" "" :string)
+ ("Ź" "" :string)
+ ("à" "" :string)
+ ("Ń" "" :string)
+ ("Đ" "" :string)
+ ("ÿ" "" :string)
+ ("ś" "" :string)
+ ("Ğ" "" :string)
+ ("ğ" "" :string)
+ ("Ù" "" :string)
+ ("İ" "" :string)
+ ("đ" "" :string)
+ ("ù" "" :string)
+ ("Ț" "" :string)
+ ("é" "" :string)
+ ("ŕ" "" :string)
+ ("Ć" "" :string)
+ ("ț" "" :string)
+ ("ò" "" :string)
+ ("ź" "" :string)
+ ("Ò" "" :string)
+ ("Ÿ" "" :string)
+ ("Ŕ" "" :string)
+ ("É" "" :string)
+ ("ĉ" "" :string)
+ ("ô" "" :string)
+ ("Í" "" :string)
+ ("ŝ" "" :string)
+ ("Ż" "" :string)
+ ("Ă" "" :string)
+ ("Ŝ" "" :string)
+ ("ñ" "" :string)
+ ("ŭ" "" :string)
+ ("í" "" :string)
+ ("È" "" :string)
+ ("Ô" "" :string)
+ ("Ŭ" "" :string)
+ ("ż" "" :string)
+ ("Ñ" "" :string)
+ ("è" "" :string)
+ ("Ĉ" "" :string)
+ ("ă" "" :string)
+ ("â" "" :string)
+ ("û" "" :string)
+ ("ê" "" :string)
+ ("Õ" "" :string)
+ ("õ" "" :string)
+ ("ș" "" :string)
+ ("ç" "" :string)
+ ("Â" "" :string)
+ ("Ê" "" :string)
+ ("Û" "" :string)
+ ("Ç" "" :string)
+ ("ì" "" :string)
+ ("Ì" "" :string)
+ ("Ș" "" :string)
+ ("ö" "" :string)
+ ("Ö" "" :string)
+ ("ş" "" :string)
+ ("ů" "" :string)
+ ("ë" "" :string)
+ ("ã" "" :string)
+ ("î" "" :string)
+ ("Î" "" :string)
+ ("Ã" "" :string)
+ ("Ş" "" :string)
+ ("Ů" "" :string)
+ ("Ë" "" :string)
+ ("ï" "" :string)
+ ("Ő" "" :string)
+ ("Ï" "" :string)
+ ("Ę" "" :string)
+ ("ő" "" :string)
+ ("Ü" "" :string)
+ ("Å" "" :string)
+ ("ü" "" :string)
+ ("ę" "" :string)
+ ("å" "" :string)
+ ("Ä" "" :string)
+ ("ű" "" :string)
+ ("Ø" "" :string)
+ ("ø" "" :string)
+ ("Ű" "" :string)
+ ("ä" "" :string)
+ ("Ą" "" :string)
+ ("ą" "" :string)
+ ("œ" "" :string)
+ ("ß" "" :string)
+ ("Æ" "" :string)
+ ("Œ" "" :string)
+ ("æ" "" :string)
+ ("e" "" :string)
+ ("t" "" :string)
+ ("L" "" :string)
+ ("Y" "" :string)
+ ("J" "" :string)
+ ("a" "" :string)
+ ("p" "" :string)
+ ("u" "" :string)
+ ("j" "" :string)
+ ("b" "" :string)
+ ("G" "" :string)
+ ("U" "" :string)
+ ("F" "" :string)
+ ("H" "" :string)
+ ("i" "" :string)
+ ("z" "" :string)
+ ("c" "" :string)
+ ("l" "" :string)
+ ("A" "" :string)
+ ("Q" "" :string)
+ ("w" "" :string)
+ ("D" "" :string)
+ ("R" "" :string)
+ ("d" "" :string)
+ ("s" "" :string)
+ ("r" "" :string)
+ ("k" "" :string)
+ ("v" "" :string)
+ ("m" "" :string)
+ ("P" "" :string)
+ ("y" "" :string)
+ ("K" "" :string)
+ ("q" "" :string)
+ ("S" "" :string)
+ ("I" "" :string)
+ ("C" "" :string)
+ ("M" "" :string)
+ ("Z" "" :string)
+ ("T" "" :string)
+ ("W" "" :string)
+ ("B" "" :string)
+ ("h" "" :string)
+ ("x" "" :string)
+ ("X" "" :string)
+ ("f" "" :string)
+ ("E" "" :string)
+ ("V" "" :string)
+ ("N" "" :string)
+ ("O" "" :string)
+ ("o" "" :string)
+ ("g" "" :string)
+ ("n" "" :string)
+ ))
+
+(define-rule-set "sphinx-xy-resolve-case"
+
+ :rules (("Ú" "8" :string)
+ ("Ÿ" "8" :string)
+ ("Ç" "8" :string)
+ ("Ĉ" "8" :string)
+ ("Ŕ" "8" :string)
+ ("Ľ" "8" :string)
+ ("Ů" "8" :string)
+ ("Ý" "8" :string)
+ ("É" "8" :string)
+ ("Ë" "8" :string)
+ ("Ș" "8" :string)
+ ("Ì" "8" :string)
+ ("Ê" "8" :string)
+ ("Ň" "8" :string)
+ ("Ą" "8" :string)
+ ("Š" "8" :string)
+ ("Û" "8" :string)
+ ("Ş" "8" :string)
+ ("Ć" "8" :string)
+ ("Ò" "8" :string)
+ ("Ĝ" "8" :string)
+ ("Ñ" "8" :string)
+ ("Ó" "8" :string)
+ ("Î" "8" :string)
+ ("Á" "8" :string)
+ ("Ã" "8" :string)
+ ("Ț" "8" :string)
+ ("Å" "8" :string)
+ ("Ğ" "8" :string)
+ ("Ü" "8" :string)
+ ("È" "8" :string)
+ ("Ô" "8" :string)
+ ("İ" "8" :string)
+ ("Ű" "8" :string)
+ ("Ù" "8" :string)
+ ("Ŭ" "8" :string)
+ ("Â" "8" :string)
+ ("Ť" "8" :string)
+ ("Ń" "8" :string)
+ ("Ď" "8" :string)
+ ("Ź" "8" :string)
+ ("Ž" "8" :string)
+ ("Đ" "8" :string)
+ ("Ŝ" "8" :string)
+ ("Č" "8" :string)
+ ("Ĵ" "8" :string)
+ ("Ö" "8" :string)
+ ("Ø" "8" :string)
+ ("Ż" "8" :string)
+ ("Ł" "8" :string)
+ ("Ă" "8" :string)
+ ("Ě" "8" :string)
+ ("Ő" "8" :string)
+ ("Õ" "8" :string)
+ ("Ę" "8" :string)
+ ("Ï" "8" :string)
+ ("À" "8" :string)
+ ("Ĥ" "8" :string)
+ ("Ä" "8" :string)
+ ("Ś" "8" :string)
+ ("Ř" "8" :string)
+ ("Í" "8" :string)
+ ("Œ" "89" :string)
+ ("Æ" "89" :string)
+ ("ì" "9" :string)
+ ("è" "9" :string)
+ ("ą" "9" :string)
+ ("š" "9" :string)
+ ("ú" "9" :string)
+ ("å" "9" :string)
+ ("ă" "9" :string)
+ ("ę" "9" :string)
+ ("ü" "9" :string)
+ ("ź" "9" :string)
+ ("ò" "9" :string)
+ ("ť" "9" :string)
+ ("ț" "9" :string)
+ ("ĵ" "9" :string)
+ ("ŕ" "9" :string)
+ ("ż" "9" :string)
+ ("ä" "9" :string)
+ ("ý" "9" :string)
+ ("ù" "9" :string)
+ ("á" "9" :string)
+ ("é" "9" :string)
+ ("č" "9" :string)
+ ("ň" "9" :string)
+ ("ś" "9" :string)
+ ("ø" "9" :string)
+ ("í" "9" :string)
+ ("đ" "9" :string)
+ ("ı" "9" :string)
+ ("ğ" "9" :string)
+ ("î" "9" :string)
+ ("ã" "9" :string)
+ ("à" "9" :string)
+ ("ř" "9" :string)
+ ("ő" "9" :string)
+ ("ů" "9" :string)
+ ("ș" "9" :string)
+ ("ÿ" "9" :string)
+ ("ë" "9" :string)
+ ("ŭ" "9" :string)
+ ("ç" "9" :string)
+ ("ű" "9" :string)
+ ("ñ" "9" :string)
+ ("õ" "9" :string)
+ ("ě" "9" :string)
+ ("ş" "9" :string)
+ ("ž" "9" :string)
+ ("ĝ" "9" :string)
+ ("ŝ" "9" :string)
+ ("ń" "9" :string)
+ ("û" "9" :string)
+ ("ł" "9" :string)
+ ("ď" "9" :string)
+ ("ĥ" "9" :string)
+ ("ê" "9" :string)
+ ("ô" "9" :string)
+ ("ĉ" "9" :string)
+ ("â" "9" :string)
+ ("ć" "9" :string)
+ ("ï" "9" :string)
+ ("ö" "9" :string)
+ ("ľ" "9" :string)
+ ("ó" "9" :string)
+ ("æ" "99" :string)
+ ("ß" "99" :string)
+ ("œ" "99" :string)
+ ("N" "8" :string)
+ ("V" "8" :string)
+ ("O" "8" :string)
+ ("X" "8" :string)
+ ("E" "8" :string)
+ ("P" "8" :string)
+ ("K" "8" :string)
+ ("T" "8" :string)
+ ("Z" "8" :string)
+ ("M" "8" :string)
+ ("C" "8" :string)
+ ("I" "8" :string)
+ ("S" "8" :string)
+ ("B" "8" :string)
+ ("W" "8" :string)
+ ("D" "8" :string)
+ ("R" "8" :string)
+ ("H" "8" :string)
+ ("F" "8" :string)
+ ("Q" "8" :string)
+ ("A" "8" :string)
+ ("G" "8" :string)
+ ("U" "8" :string)
+ ("J" "8" :string)
+ ("Y" "8" :string)
+ ("L" "8" :string)
+ ("o" "9" :string)
+ ("n" "9" :string)
+ ("g" "9" :string)
+ ("x" "9" :string)
+ ("f" "9" :string)
+ ("y" "9" :string)
+ ("q" "9" :string)
+ ("h" "9" :string)
+ ("w" "9" :string)
+ ("s" "9" :string)
+ ("d" "9" :string)
+ ("v" "9" :string)
+ ("k" "9" :string)
+ ("r" "9" :string)
+ ("m" "9" :string)
+ ("z" "9" :string)
+ ("c" "9" :string)
+ ("i" "9" :string)
+ ("l" "9" :string)
+ ("b" "9" :string)
+ ("j" "9" :string)
+ ("a" "9" :string)
+ ("p" "9" :string)
+ ("u" "9" :string)
+ ("t" "9" :string)
+ ("e" "9" :string)
+ ))
+
+(use-rule-set :run 0
+ :rule-set ("sphinx-xy-alphabetize"))
+(use-rule-set :run 1
+ :rule-set ("sphinx-xy-resolve-diacritics"))
+(use-rule-set :run 2
+ :rule-set ("sphinx-xy-resolve-case"))
diff --git a/sphinx/texinputs/Makefile_t b/sphinx/texinputs/Makefile_t
new file mode 100644
index 0000000..96bb0fe
--- /dev/null
+++ b/sphinx/texinputs/Makefile_t
@@ -0,0 +1,92 @@
+# Makefile for Sphinx LaTeX output
+
+ALLDOCS = $(basename $(wildcard *.tex))
+ALLPDF = $(addsuffix .pdf,$(ALLDOCS))
+{% if latex_engine == 'xelatex' -%}
+ALLDVI =
+ALLXDV = $(addsuffix .xdv,$(ALLDOCS))
+{% else -%}
+ALLDVI = $(addsuffix .dvi,$(ALLDOCS))
+ALLXDV =
+{% endif -%}
+ALLPS = $(addsuffix .ps,$(ALLDOCS))
+
+# Prefix for archive names
+ARCHIVEPREFIX =
+# Additional LaTeX options (passed via variables in latexmkrc/latexmkjarc file)
+export LATEXOPTS ?=
+# Additional latexmk options
+{% if latex_engine == 'xelatex' -%}
+# with latexmk version 4.52b or higher set LATEXMKOPTS to -xelatex either here
+# or on command line for faster builds.
+{% endif -%}
+LATEXMKOPTS ?=
+{% if xindy_use -%}
+export XINDYOPTS = {{ xindy_lang_option }} -M sphinx.xdy
+{% if latex_engine == 'pdflatex' -%}
+XINDYOPTS += -M LICRlatin2utf8.xdy
+{% if xindy_cyrillic -%}
+XINDYOPTS += -M LICRcyr2utf8.xdy
+{% endif -%}
+{% endif -%}
+{% if xindy_cyrillic -%}
+XINDYOPTS += -M LatinRules.xdy
+{% endif -%}
+{% endif -%}
+# format: pdf or dvi (used only by archive targets)
+FMT = pdf
+
+{% if latex_engine in ('platex', 'uplatex') -%}
+# latexmkrc is read then overridden by latexmkjarc
+LATEX = latexmk -r latexmkjarc -dvi
+PDFLATEX = latexmk -r latexmkjarc -pdfdvi -dvi- -ps-
+{% else -%}
+LATEX = latexmk -dvi
+PDFLATEX = latexmk -pdf -dvi- -ps-
+{% endif %}
+
+{% if latex_engine != 'xelatex' -%}
+%.dvi: %.tex FORCE_MAKE
+ $(LATEX) $(LATEXMKOPTS) '$<'
+
+{% endif -%}
+%.ps: %.dvi
+ dvips '$<'
+
+%.pdf: %.tex FORCE_MAKE
+ $(PDFLATEX) $(LATEXMKOPTS) '$<'
+
+all: $(ALLPDF)
+
+all-dvi: $(ALLDVI)
+
+all-ps: $(ALLPS)
+
+all-pdf: $(ALLPDF)
+
+zip: all-$(FMT)
+ mkdir $(ARCHIVEPREFIX)docs-$(FMT)
+ cp $(ALLPDF) $(ARCHIVEPREFIX)docs-$(FMT)
+ zip -q -r -9 $(ARCHIVEPREFIX)docs-$(FMT).zip $(ARCHIVEPREFIX)docs-$(FMT)
+ rm -r $(ARCHIVEPREFIX)docs-$(FMT)
+
+tar: all-$(FMT)
+ mkdir $(ARCHIVEPREFIX)docs-$(FMT)
+ cp $(ALLPDF) $(ARCHIVEPREFIX)docs-$(FMT)
+ tar cf $(ARCHIVEPREFIX)docs-$(FMT).tar $(ARCHIVEPREFIX)docs-$(FMT)
+ rm -r $(ARCHIVEPREFIX)docs-$(FMT)
+
+gz: tar
+ gzip -9 < $(ARCHIVEPREFIX)docs-$(FMT).tar > $(ARCHIVEPREFIX)docs-$(FMT).tar.gz
+
+bz2: tar
+ bzip2 -9 -k $(ARCHIVEPREFIX)docs-$(FMT).tar
+
+xz: tar
+ xz -9 -k $(ARCHIVEPREFIX)docs-$(FMT).tar
+
+clean:
+ rm -f *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla *.ps *.tar *.tar.gz *.tar.bz2 *.tar.xz $(ALLPDF) $(ALLDVI) $(ALLXDV) *.fls *.fdb_latexmk
+
+.PHONY: all all-pdf all-dvi all-ps clean zip tar gz bz2 xz
+.PHONY: FORCE_MAKE
diff --git a/sphinx/texinputs/latexmkjarc_t b/sphinx/texinputs/latexmkjarc_t
new file mode 100644
index 0000000..c7403a9
--- /dev/null
+++ b/sphinx/texinputs/latexmkjarc_t
@@ -0,0 +1,22 @@
+$latex = '{{ latex_engine }} ' . $ENV{'LATEXOPTS'} . ' -kanji=utf8 %O %S';
+$dvipdf = 'dvipdfmx %O -o %D %S';
+$makeindex = 'internal mendex %S %B %D';
+sub mendex {
+ my ($source, $basename, $destination) = @_;
+ my $dictfile = $basename . ".dic";
+ unlink($destination);
+ system("mendex", "-U", "-f", "-d", $dictfile, "-s", "python.ist", $source);
+ if ($? > 0) {
+ print("mendex exited with error code $? (ignored)\n");
+ }
+ if (!-e $destination) {
+ # create an empty .ind file if nothing
+ open(FH, ">" . $destination);
+ close(FH);
+ }
+ return 0;
+}
+add_cus_dep( "glo", "gls", 0, "makeglo" );
+sub makeglo {
+ return system( "mendex -J -f -s gglo.ist -o '$_[0].gls' '$_[0].glo'" );
+}
diff --git a/sphinx/texinputs/latexmkrc_t b/sphinx/texinputs/latexmkrc_t
new file mode 100644
index 0000000..a33b541
--- /dev/null
+++ b/sphinx/texinputs/latexmkrc_t
@@ -0,0 +1,32 @@
+{% if latex_engine == 'pdflatex' -%}
+$latex = 'latex ' . $ENV{'LATEXOPTS'} . ' %O %S';
+$pdflatex = 'pdflatex ' . $ENV{'LATEXOPTS'} . ' %O %S';
+{% elif latex_engine == 'lualatex' -%}
+$latex = 'lualatex --output-format=dvi ' . $ENV{'LATEXOPTS'} . ' %O %S';
+$pdflatex = 'lualatex ' . $ENV{'LATEXOPTS'} . ' %O %S';
+{% elif latex_engine == 'xelatex' -%}
+$latex = 'xelatex --no-pdf ' . $ENV{'LATEXOPTS'} . ' %O %S';
+$pdflatex = 'xelatex ' . $ENV{'LATEXOPTS'} . ' %O %S';
+{% endif -%}
+$lualatex = 'lualatex ' . $ENV{'LATEXOPTS'} . ' %O %S';
+$xelatex = 'xelatex --no-pdf ' . $ENV{'LATEXOPTS'} . ' %O %S';
+{% if xindy_use -%}
+$makeindex = 'internal xindy ' . $ENV{'XINDYOPTS'} . ' %O -o %D %S';
+sub xindy {
+ my @args = @_;
+ if (-z $args[-1]) {
+ # create an empty .ind file if .idx is empty
+ open(FH, ">" . $args[-2]);
+ close(FH);
+ return 0;
+ } else {
+ return system("xindy", @args);
+ }
+}
+{% else -%}
+$makeindex = 'makeindex -s python.ist %O -o %D %S';
+{% endif -%}
+add_cus_dep( "glo", "gls", 0, "makeglo" );
+sub makeglo {
+ return system( "makeindex -s gglo.ist -o '$_[0].gls' '$_[0].glo'" );
+}
diff --git a/sphinx/texinputs/make.bat_t b/sphinx/texinputs/make.bat_t
new file mode 100644
index 0000000..da2805a
--- /dev/null
+++ b/sphinx/texinputs/make.bat_t
@@ -0,0 +1,50 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+pushd %~dp0
+
+{% if latex_engine in ('platex', 'uplatex') -%}
+REM latexmkrc is read then overridden by latexmkjarc
+set PDFLATEX=latexmk -r latexmkjarc -pdfdvi -dvi- -ps-
+{% else -%}
+set PDFLATEX=latexmk -pdf -dvi- -ps-
+{% endif %}
+set "LATEXOPTS= "
+
+{% if xindy_use -%}
+set XINDYOPTS={{ xindy_lang_option }} -M sphinx.xdy
+{% if latex_engine == 'pdflatex' -%}
+set XINDYOPTS=%XINDYOPTS% -M LICRlatin2utf8.xdy
+{% if xindy_cyrillic -%}
+set XINDYOPTS=%XINDYOPTS% -M LICRcyr2utf8.xdy
+{% endif -%}
+{% endif -%}
+{% if xindy_cyrillic -%}
+set XINDYOPTS=%XINDYOPTS% -M LatinRules.xdy
+{% endif -%}
+set XINDYOPTS=%XINDYOPTS% -I xelatex
+{% endif -%}
+
+
+if "%1" == "" goto all-pdf
+
+if "%1" == "all-pdf" (
+ :all-pdf
+ for %%i in (*.tex) do (
+ %PDFLATEX% %LATEXMKOPTS% %%i
+ )
+ goto end
+)
+
+if "%1" == "all-pdf-ja" (
+ goto all-pdf
+)
+
+if "%1" == "clean" (
+ del /q /s *.dvi *.log *.ind *.aux *.toc *.syn *.idx *.out *.ilg *.pla *.ps *.tar *.tar.gz *.tar.bz2 *.tar.xz *.fls *.fdb_latexmk
+ goto end
+)
+
+:end
+popd
diff --git a/sphinx/texinputs/python.ist b/sphinx/texinputs/python.ist
new file mode 100644
index 0000000..70536a6
--- /dev/null
+++ b/sphinx/texinputs/python.ist
@@ -0,0 +1,16 @@
+line_max 100
+headings_flag 1
+heading_prefix " \\bigletter "
+
+preamble "\\begin{sphinxtheindex}
+\\let\\bigletter\\sphinxstyleindexlettergroup
+\\let\\spxpagem \\sphinxstyleindexpagemain
+\\let\\spxentry \\sphinxstyleindexentry
+\\let\\spxextra \\sphinxstyleindexextra
+
+"
+
+postamble "\n\n\\end{sphinxtheindex}\n"
+
+symhead_positive "{\\sphinxsymbolsname}"
+numhead_positive "{\\sphinxnumbersname}"
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
new file mode 100644
index 0000000..6c31f32
--- /dev/null
+++ b/sphinx/texinputs/sphinx.sty
@@ -0,0 +1,1013 @@
+%
+% 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/19 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_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 code-blocks. But \fcolorbox
+% appears also in Pygmentize output mark-up. Also, since 5.3.0, 'sphinxsetup'
+% color options get a richer input syntax if Sphinx knows xcolor is loaded,
+% and the \sphinxcolorblend (for tables) is made available only if xcolor is
+% loaded.
+\IfFileExists{xcolor.sty}{
+% Should Sphinx load xcolor with its dvipsnames and svgnames options?
+ \RequirePackage{xcolor}
+}{
+ \RequirePackage{color}
+}
+
+% the \colorlet of xcolor (if at all loaded) is overkill for most 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 internally used dimen registers
+% \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 were kept for backward compatibility. Unfortunately
+% this had bugs due to typos, which got fixed later at 6.1.2.
+%
+% All configuration is now to be found in the "CSS" section below.
+%
+% \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
+%
+% 5.1.0 added much customizability to warning, caution, attention, danger and
+% error types of notices via an enhanced sphinxheavybox environment.
+%
+% 6.2.0 added the possibility to use the same kind of rendering also for
+% note, hint, important, and tip.
+%
+% Legacy user interface for options was kept working. All of it is handled in
+% the "CSS" section below.
+%
+% These 6.2.0 added booleans serve internally. There is no reason for user to
+% know about them, except if it is desired to toggle mid-way in the document
+% whether note, hint, important, and tip should use the "lightbox" or the
+% "heavybox" rendering.
+\DeclareBoolOption[false]{heavynote}
+\DeclareBoolOption[false]{heavyhint}
+\DeclareBoolOption[false]{heavyimportant}
+\DeclareBoolOption[false]{heavytip}
+% 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 backward 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
+% border color defaults to black
+% at 6.2.0 also background color is possible, but it then triggers
+% usage of the "sphinxheavybox" from sphinxlatexadmonitions.sty.
+\sphinxDeclareSphinxColorOption{noteBorderColor}{{rgb}{0,0,0}}
+\sphinxDeclareSphinxColorOption{hintBorderColor}{{rgb}{0,0,0}}
+\sphinxDeclareSphinxColorOption{importantBorderColor}{{rgb}{0,0,0}}
+\sphinxDeclareSphinxColorOption{tipBorderColor}{{rgb}{0,0,0}}
+\sphinxDeclareSphinxColorOption{noteBgColor}{{rgb}{1,1,1}}
+\sphinxDeclareSphinxColorOption{hintBgColor}{{rgb}{1,1,1}}
+\sphinxDeclareSphinxColorOption{importantBgColor}{{rgb}{1,1,1}}
+\sphinxDeclareSphinxColorOption{tipBgColor}{{rgb}{1,1,1}}
+% admonition boxes, "heavy" style
+% border color defaults to black and background color to white
+% As long as the color are not explicitly set via user options,
+% the sphinxpackageboxes.sty code will actually not use them anyhow.
+\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}}
+% BgColor should have been from the start BackgroundColor for better
+% match with CSS property names, but this is legacy interface
+% which is too late to change because the internal color names
+% and not only the option names have been documented at user level.
+\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 at 5.1.0 (and possibility of rounded boxes)
+% -----------------------------------
+%
+% These CSS-named alikes allow to configure 4 border widths, 4 padding seps, 4
+% corner radii, optional shadow, border color, background color, shadow color.
+%
+% In future, an alternative user interface will perhaps be provided to parse
+% genuine CSS, but this will be easier to do in Python than in LaTeX.
+%
+% Refactoring (and extension) at 6.2.0
+% ------------------------------------
+%
+% 6.2.0 batch defines in one go all auxiliaries for code-blocks, topics, and
+% admonitions. The needed steps to maintain the legacy option names working
+% and to set some specific defaults are handled in a second step.
+%
+% This allowed to:
+%
+% - associate these CSS-named options also to note, hint, important, and tip
+% which thus can access the full customizability of sphinxheavybox if they use
+% it.
+%
+% - provide a \sphinxbox command for boxing inline text elements with the same
+% full customizability.
+%
+% The \dimen's \sphinxverbatimborder, \sphinxverbatimsep, \sphinxshadowsep,
+% \sphinxshadowsize, and \sphinxshadowrule, which had been deprecated have
+% finally been removed entirely. No more \dimen register is used here only
+% storage in macros.
+%
+\def\spxstring@none{none}
+\def\spxstring@clone{clone}
+%
+% 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
+}
+% MEMO: prior to 6.2.0 the \fboxrule value (0.4pt, a priori) was frozen here via
+% a \dimen assignment done immediately. Now it remains \fboxrule until being used.
+% 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@note@} {div.note_} {noteborder} {0.5pt}
+\spx@tempa{spx@hint@} {div.hint_} {hintborder} {0.5pt}
+\spx@tempa{spx@important@}{div.important_}{importantborder}{0.5pt}
+\spx@tempa{spx@tip@} {div.tip_} {tipborder} {0.5pt}
+\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
+% 6.2.0 has added support for box-decoration-break=slice to all
+% other directives, formerly the option setting was ignored for them.
+
+% 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 (3pt, a priori) was frozen here via
+% a \dimen assignment done immediately. 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 6.2.0, "note" type admonitions used sphinxlightbox automatically
+% and had no interface to set the padding parameters needed by sphinxheavybox.
+% At 6.2.0 they acquired such interface and the default is set as for legacy
+% default of "warning" type. I hesitated using \fboxsep, but if I did I would
+% then need to explain how to change "note etc..." into behaving exactly
+% as "warning etc...", which goes via the \dimexpr here which is too scary to
+% put sanely into documentation.
+\spx@tempa{spx@note@} {div.note_} {\dimexpr.6\baselineskip-\spx@note@border\relax}
+\spx@tempa{spx@hint@} {div.hint_} {\dimexpr.6\baselineskip-\spx@hint@border\relax}
+\spx@tempa{spx@important@}{div.important_} {\dimexpr.6\baselineskip-\spx@important@border\relax}
+\spx@tempa{spx@tip@} {div.tip_} {\dimexpr.6\baselineskip-\spx@tip@border\relax}
+% 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 (so that it dynamically adapts to the border width setting).
+% MEMO: I could use everywhere \spx@notice@border, as sphinxadmonition environment
+% configures it to hold the \spx@<type>@border value.
+\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
+% 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
+%
+% Prior to 6.2.0, the "rounded box" branch obeyed the 4 radii but ignored
+% the separate border widths and used only the border-width setting.
+% Now, all 4 + 4 parameters are obeyed.
+\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
+}
+% The init value for corner radius in code-blocks was \z@ (i.e. 0pt) prior
+% to 6.0.0., then 3pt, then \fboxsep at 6.2.0 as padding is \fboxsep,
+% and \fboxsep=3pt per default (also with platex).
+% macro prefix option prefix init value
+\spx@tempa{spx@pre@} {pre_} \fboxsep
+\spx@tempa{spx@topic@} {div.topic_} \z@
+\spx@tempa{spx@note@} {div.note_} \z@
+\spx@tempa{spx@hint@} {div.hint_} \z@
+\spx@tempa{spx@important@}{div.important_} \z@
+\spx@tempa{spx@tip@} {div.tip_} \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_} \fboxsep
+
+% Shadow keys
+%
+% Prior to 6.2.0, an "inset" shadow caused the rendering to ignore
+% rounded corners. Starting with 6.2.0, an "inset" shadow is simply
+% ignored (not implemented) if any of the corner radii is positive,
+% rather than forcing a rectangle+inset shadow output.
+\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@note@}
+\spx@tempa{spx@hint@}
+\spx@tempa{spx@important@}
+\spx@tempa{spx@tip@}
+\spx@tempa{spx@warning@}
+\spx@tempa{spx@caution@}
+\spx@tempa{spx@attention@}
+\spx@tempa{spx@danger@}
+\spx@tempa{spx@error@}
+\spx@tempa{spx@box@}
+%
+\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: at 5.1.0 and up to 6.2.0, an \edef with \number\dimexpr was
+ % used here. Since 6.2.0, expansion is delayed to time of use as for
+ % the other dimensions handled above. This is synched with an added
+ % encapsulation in \dimexpr...\relax by the "setup" from
+ % sphinxpackageboxes.sty. An induced regression had to be fixed in
+ % the sphinxShadowBox environment as it was using in an \ifdim the
+ % \spx@topic@shadow@yoffset macro, now holding by default 4pt+\z@
+ % rather than an already digested 262144sp. The +\z@ is in case ##2
+ % is empty.
+ \else #1%
+ \def#6{##1}\def#7{##2+\z@}%
+ \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@note@} {div.note_}
+\spx@tempa{spx@hint@} {div.hint_}
+\spx@tempa{spx@important@}{div.important_}
+\spx@tempa{spx@tip@} {div.tip_}
+\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_}
+
+% Support for legacy shadowsize (topic/contents)
+% This definition was broken due to a typo at 5.1.0 and got fixed at 6.1.2
+% MEMO: at 6.2.0 this no longer does \number\dimexpr in an \edef. Reason is to
+% keep in sync with div.topic_box-shadow handling of xoffset and yoffset.
+% Attention in particular to \ifdim context, we add a \dimexpr to the one here.
+\define@key{sphinx}{shadowsize}{%
+ \def\spx@topic@shadow@xoffset{#1}%
+ \let\spx@topic@shadow@yoffset\spx@topic@shadow@xoffset
+ \ifdim\dimexpr\spx@topic@shadow@xoffset=\z@
+ \spx@topic@withshadowfalse
+ \else
+ \spx@topic@withshadowtrue
+ \spx@topic@insetshadowfalse
+ \fi
+}%
+
+% Color keys
+% (four of them: border, background, shadow and the text color)
+%
+% Some problems due to legacy naming scheme which had diverging conventions
+% for code-blocks (VerbatimBorderColor, VerbatimColor) and admonitions
+% (sphinxwarningBorderColor, sphinxwarningBgColor, etc...) regarding the
+% internal names of the used colors. Unfortunately VerbatimColor and for
+% example sphinxwarningBgColor are also documented at user level, they are not
+% only internally used.
+%
+% For topic directive, "legacy" (by this I mean Sphinx around 2016-2017 after
+% my first additions to LaTeX) had no interface for colors, so I could change
+% some internals with no breakage during 5.x up to 6.2.0. So topic
+% (shadowbox) could be unified with admonitions (sphinxheavybox), and the
+% "set-up" macros could all be moved into a single one in the
+% sphinxpackageboxes.sty file, with only one argument holding the directive
+% type.
+%
+% It was then needed only for sphinxlatexliterals.sty to let its
+% \spx@verb@boxes@fcolorbox@setup incorporate some extra adjustment.
+%
+% We associate a boolean to each color, so that the box code can
+% decide to insert a \color command or consider it is not needed.
+\def\spx@tempa#1{%
+ \expandafter\spx@tempb
+ \csname if#1withshadowcolor\expandafter\endcsname
+ \csname if#1withbordercolor\expandafter\endcsname
+ \csname if#1withbackgroundcolor\expandafter\endcsname
+ \csname if#1withtextcolor\endcsname
+}%
+\def\spx@tempb#1#2#3#4{\newif#1\newif#2\newif#3\newif#4}%
+% macro prefix
+\spx@tempa{spx@pre@}
+\spx@tempa{spx@topic@}
+\spx@tempa{spx@note@}
+\spx@tempa{spx@hint@}
+\spx@tempa{spx@important@}
+\spx@tempa{spx@tip@}
+\spx@tempa{spx@warning@}
+\spx@tempa{spx@caution@}
+\spx@tempa{spx@attention@}
+\spx@tempa{spx@danger@}
+\spx@tempa{spx@error@}
+\spx@tempa{spx@box@}
+%
+\def\spx@tempa#1{% #1 = macro prefix
+ \expandafter\spx@tempb
+ \csname #1withbordercolortrue\expandafter\endcsname
+ \csname #1withbackgroundcolortrue\expandafter\endcsname
+ \csname #1withshadowcolortrue\expandafter\endcsname
+ \csname #1withtextcolortrue\endcsname
+}
+\def\spx@tempb#1#2#3#4#5#6{% #5 = option prefix, #6 = color name prefix
+ \define@key{sphinx}{#5border-TeXcolor}%
+ {#1\spx@defineorletcolor{#6BorderColor}##1\relax}%
+ \define@key{sphinx}{#5background-TeXcolor}%
+ {#2\spx@defineorletcolor{#6BgColor}##1\relax}%
+ \define@key{sphinx}{#5box-shadow-TeXcolor}%
+ {#3\spx@defineorletcolor{#6ShadowColor}##1\relax}%
+ \define@key{sphinx}{#5TeXcolor}%
+ {#4\spx@defineorletcolor{#6TextColor}##1\relax}%
+}
+% macro prefix option prefix color name prefix
+\spx@tempa{spx@pre@} {pre_} {Verbatim}
+ % (memo: internal VerbatimShadowColor was formerly sphinxVerbatimShadowColor)
+ % internal legacy color name is VerbatimColor not VerbatimBgColor, so redefine:
+ \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 legacy option names working
+ \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
+% (6.2.0 modified some internal namings for the colors of topic boxes)
+% macro prefix option prefix color name prefix
+\spx@tempa{spx@topic@} {div.topic_} {sphinxtopic}% (no legacy interface)
+\spx@tempa{spx@note@} {div.note_} {sphinxnote}
+\spx@tempa{spx@hint@} {div.hint_} {sphinxhint}
+\spx@tempa{spx@important@}{div.important_} {sphinximportant}
+\spx@tempa{spx@tip@} {div.tip_} {sphinxtip}
+\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}
+ % Keep legacy sphinxsetup color options interface for "strong" admonitions
+ \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}
+
+ % Keep legacy sphinxsetup <type>BorderColor for <type>=note, hint, ...
+ % which will not trigger sphinxheavybox
+ % Add "legacy" hintTextColor etc... that will not trigger sphinxheavybox
+ \def\spx@tempa#1#2{% #1 = CSS like 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@#2TextColor\expandafter\endcsname
+ \csname KV@sphinx@#1TeXcolor\endcsname
+ }
+ \spx@tempa{div.note_} {note}
+ \spx@tempa{div.hint_} {hint}
+ \spx@tempa{div.important_} {important}
+ \spx@tempa{div.tip_} {tip}
+
+% The TeXextras key
+%
+\def\spx@tempa#1{% #1 = macro prefix
+ \expandafter\spx@tempb\csname #1TeXextras\endcsname
+}
+\def\spx@tempb#1#2{% #2 = option prefix
+ \define@key{sphinx}{#2TeXextras}{\def#1{##1}}%
+}
+% macro prefix option prefix
+\spx@tempa{spx@pre@} {pre_}
+\spx@tempa{spx@topic@} {div.topic_}
+\spx@tempa{spx@note@} {div.note_}
+\spx@tempa{spx@hint@} {div.hint_}
+\spx@tempa{spx@important@}{div.important_}
+\spx@tempa{spx@tip@} {div.tip_}
+\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_}
+ % Add "legacy" hintTeXextras etc... that will not trigger sphinxheavybox
+ \def\spx@tempa#1#2{% #1 = CSS like option prefix, #2 = legacy option prefix
+ \expandafter\let\csname KV@sphinx@#2TeXextras\expandafter\endcsname
+ \csname KV@sphinx@#1TeXextras\endcsname
+ }
+ \spx@tempa{div.note_} {note}
+ \spx@tempa{div.hint_} {hint}
+ \spx@tempa{div.important_} {important}
+ \spx@tempa{div.tip_} {tip}
+
+% For note type admonitions, redefine all CSS-like named options to trigger
+% the "heavybox" path.
+%
+% MEMO: the noteBorderColor and noteborder legacy options have already been
+% re-created and they do not trigger the "heavybox" as their meaning will not
+% be modified in the loop below contrarily to their CSS counterparts
+% div.note_border-TeXcolor and div.note_border-width, and to the noteBgColor
+% etc... which are handled below.
+%
+% This goes via rather hardcore TeX here.
+\def\spx@tempa#1{\if\relax#1\expandafter\@gobble
+ \else
+ \toks@{##1}%
+ \expandafter\def\csname KV@sphinx@div.note_#1\expandafter\endcsname
+ \the\toks0\expandafter{%
+ \csname spx@opt@heavynotetrue\expandafter\expandafter\expandafter\endcsname
+ \csname KV@sphinx@div.note_#1\endcsname{##1}}%
+ \expandafter\def\csname KV@sphinx@div.hint_#1\expandafter\endcsname
+ \the\toks0\expandafter{%
+ \csname spx@opt@heavyhinttrue\expandafter\expandafter\expandafter\endcsname
+ \csname KV@sphinx@div.hint_#1\endcsname{##1}}%
+ \expandafter\def\csname KV@sphinx@div.important_#1\expandafter\endcsname
+ \the\toks0\expandafter{%
+ \csname spx@opt@heavyimportanttrue\expandafter\expandafter\expandafter\endcsname
+ \csname KV@sphinx@div.important_#1\endcsname{##1}}%
+ \expandafter\def\csname KV@sphinx@div.tip_#1\expandafter\endcsname
+ \the\toks0\expandafter{%
+ \csname spx@opt@heavytiptrue\expandafter\expandafter\expandafter\endcsname
+ \csname KV@sphinx@div.tip_#1\endcsname{##1}}%
+ \fi
+ \spx@tempa
+}
+\spx@tempa{border-width}%
+ {border-top-width}{border-right-width}{border-bottom-width}{border-left-width}%
+ {box-decoration-break}%
+ {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}{TeXcolor}%
+ {TeXextras}%
+\relax
+
+% Now we add at 6.2.0 <type>BgColor et al. options which will trigger the
+% "heavybox" as they are \let to the div.<type>_background-TeXColor option
+% which has already been enhanced to set the boolean for rendering via
+% "heavybox". This is in contrast with legacy <type>BorderColor,
+% and with the new <type>TeXcolor and <type>TeXextras.
+ \def\spx@tempa#1#2{% #1 = CSS like option prefix, #2 = legacy style option prefix
+ \expandafter\let\csname KV@sphinx@#2BgColor\expandafter\endcsname
+ \csname KV@sphinx@#1background-TeXcolor\endcsname
+ }
+ \spx@tempa{div.note_} {note}
+ \spx@tempa{div.hint_} {hint}
+ \spx@tempa{div.important_} {important}
+ \spx@tempa{div.tip_} {tip}
+
+\newif\ifspx@opt@box@addstrut
+\expandafter\def\csname KV@sphinx@box_addstrut\endcsname#1{%
+ \csname spx@opt@box@addstrut#1\endcsname
+}
+\expandafter\def\csname KV@sphinx@box_addstrut@default\endcsname{%
+ \spx@opt@box@addstruttrue
+}
+
+\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.
+%
+% Alias all \sphinxsetup "box_" keys to become \sphinxboxsetup no-prefix keys
+\@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}{TeXcolor}%
+ {TeXextras}{addstrut}{addstrut@default}%
+\do{\expandafter\let\csname KV@sphinxbox@\x\expandafter\endcsname
+ \csname KV@sphinx@box_\x\endcsname}
+% Let \sphinxboxsetup also prepare a "reset", which will be used by nested
+% boxes; currently and by laziness this is implemented simply by accumulating
+% all passed options inside some storage, in the order they were given, rather
+% than saving the box would-be parameters. Advantage is that this will not
+% have to be modified if additional keys are added in future (e.g. for
+% elliptic corners). Storing obeys TeX groups. (these details would be
+% relevant only for some genuine independent LaTeX package and manual user
+% authored mark-up, not Sphinx auto mark-up).
+\newcommand\sphinxboxsetup[1]{%
+ \setkeys{sphinxbox}{#1}%
+ \expandafter\def\expandafter\spx@boxes@sphinxbox@defaults\expandafter
+ {\spx@boxes@sphinxbox@defaults,#1}%
+}
+\def\spx@boxes@sphinxbox@reset{%
+ \begingroup\def\x{\endgroup\setkeys{sphinxbox}}%
+ \expandafter\x\expandafter{\spx@boxes@sphinxbox@defaults}%
+}
+% Some of these defaults got already set. But we now list them all explicitly
+% for a complete initial configuration of reset storage.
+%
+\let\spx@boxes@sphinxbox@defaults\@gobble
+\sphinxboxsetup{%
+ border-width=\fboxrule,% <-not really needed to avoid EOL space
+ padding=\fboxsep,% but done here out of habit
+ border-radius=\fboxsep,%
+ box-shadow=none,%
+% As xcolor is perhaps not loaded we can not use background-TeXcolor=VerbatimColor
+% which would not be compatible with \definecolor syntax.
+ border-TeXcolor={RGB}{32,32,32},% the default VerbatimBorderColor
+ background-TeXcolor={gray}{0.95},% the default VerbatimColor
+ box-shadow-TeXcolor={rgb}{0,0,0},%
+ TeXextras={},%
+ addstrut=false% (a final comma here would not hurt)
+ }%
+\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
diff --git a/sphinx/texinputs/sphinx.xdy b/sphinx/texinputs/sphinx.xdy
new file mode 100644
index 0000000..0dcf113
--- /dev/null
+++ b/sphinx/texinputs/sphinx.xdy
@@ -0,0 +1,230 @@
+;;; -*- mode: lisp; coding: utf-8; -*-
+
+;; Unfortunately xindy is out-of-the-box hyperref-incompatible. This
+;; configuration is a workaround, which requires to pass option
+;; hyperindex=false to hyperref.
+;; textit and emph not currently used, spxpagem replaces former textbf
+(define-attributes (("textbf" "textit" "emph" "spxpagem" "default")))
+(markup-locref :open "\textbf{\hyperpage{" :close "}}" :attr "textbf")
+(markup-locref :open "\textit{\hyperpage{" :close "}}" :attr "textit")
+(markup-locref :open "\emph{\hyperpage{" :close "}}" :attr "emph")
+(markup-locref :open "\spxpagem{\hyperpage{" :close "}}" :attr "spxpagem")
+(markup-locref :open "\hyperpage{" :close "}" :attr "default")
+
+(require "numeric-sort.xdy")
+
+;; xindy base module latex.xdy loads tex.xdy and the latter instructs
+;; xindy to ignore **all** TeX macros in .idx entries, except those
+;; explicitly described in merge rule. But when after applying all
+;; merge rules an empty string results, xindy raises an error:
+
+;; ERROR: CHAR: index 0 should be less than the length of the string
+
+;; For example when using pdflatex with utf-8 characters the index
+;; file will contain \IeC macros and they will get ignored except if
+;; suitable merge rules are loaded early. The texindy script coming
+;; with xindy provides this, but only for Latin scripts. The texindy
+;; man page says to use rather xelatex or lualatex in case of Cyrillic
+;; scripts.
+
+;; Sphinx contributes LICRcyr2utf8.xdy to provide support for Cyrillic
+;; scripts for the pdflatex engine.
+
+;; Another issue caused by xindy ignoring all TeX macros except those
+;; explicitly declared reveals itself when attempting to index ">>>",
+;; as the ">" is converted to "\textgreater{}" by Sphinx's LaTeX
+;; escaping.
+
+;; To fix this, Sphinx does **not** use texindy, and does not even
+;; load the xindy latex.xdy base module.
+
+;(require "latex.xdy")
+
+;; Rather it incorporates some suitable extracts from latex.xdy and
+;; tex.xdy with additional Sphinx contributed rules.
+
+;; But, this means for pdflatex and Latin scripts that the xindy file
+;; tex/inputenc/uf8.xdy is not usable because it refers to the macro
+;; \IeC only sporadically, and as tex.xdy is not loaded, a rule such as
+;; (merge-rule "\'e" "é" :string)
+;; does not work, it must be
+;; (merge-rule "\IeC {\'e}" "é" :string)
+;; So Sphinx contributes LICRlatin2utf8.xdy to mitigate that problem.
+
+;;;;;;;; extracts from tex.xdy (discarding most original comments):
+
+;;;
+;;; TeX conventions
+;;;
+
+;; Discard leading and trailing white space. Collapse multiple white
+;; space characters to blank.
+
+(merge-rule "^ +" "" :eregexp)
+(merge-rule " +$" "" :eregexp)
+(merge-rule " +" " " :eregexp)
+
+;; Handle TeX markup
+
+(merge-rule "\\([{}$%&#])" "\1" :eregexp)
+
+;;;;;;;; end of extracts from xindy's tex.xdy
+
+;;;;;;;; extracts from latex.xdy:
+
+;; Standard location classes: arabic and roman numbers, and alphabets.
+
+(define-location-class "arabic-page-numbers" ("arabic-numbers"))
+(define-location-class "roman-page-numbers" ("roman-numbers-lowercase"))
+(define-location-class "Roman-page-numbers" ("roman-numbers-uppercase"))
+(define-location-class "alpha-page-numbers" ("alpha"))
+(define-location-class "Alpha-page-numbers" ("ALPHA"))
+
+;; Output Markup
+
+(markup-letter-group-list :sep "~n~n \indexspace~n")
+
+(markup-indexentry :open "~n \item " :depth 0)
+(markup-indexentry :open "~n \subitem " :depth 1)
+(markup-indexentry :open "~n \subsubitem " :depth 2)
+
+(markup-locclass-list :open ", " :sep ", ")
+(markup-locref-list :sep ", ")
+
+;;;;;;;; end of extracts from latex.xdy
+
+;; The LaTeX \index command turns \ into normal character so the TeX macros
+;; written to .idx files are not followed by a blank. This is different
+;; from non-ascii letters which end up (with pdflatex) as \IeC macros in .idx
+;; file, with a blank space after \IeC
+
+;; Details of the syntax are explained at
+;; http://xindy.sourceforge.net/doc/manual-3.html
+;; In absence of :string, "xindy uses an auto-detection mechanism to decide,
+;; if the pattern is a regular expression or not". But it is not obvious to
+;; guess, for example "\\_" is not detected as RE but "\\P\{\}" is, so for
+;; being sure we apply the :string switch everywhere and do not use \\ etc...
+
+;; Go back from sphinx.util.texescape TeX macros to UTF-8
+
+(merge-rule "\sphinxleftcurlybrace{}" "{" :string)
+(merge-rule "\sphinxrightcurlybrace{}" "}" :string)
+(merge-rule "\_" "_" :string)
+(merge-rule "{[}" "[" :string)
+(merge-rule "{]}" "]" :string)
+(merge-rule "\textbackslash{}" "\" :string) ; " for Emacs syntax highlighting
+(merge-rule "\textasciitilde{}" "~~" :string); the ~~ escape is needed here
+(merge-rule "\textasciicircum{}" "^" :string)
+(merge-rule "\sphinxhyphen{}" "-" :string)
+(merge-rule "\textquotesingle{}" "'" :string)
+(merge-rule "\textasciigrave{}" "`" :string)
+(merge-rule "\textless{}" "<" :string)
+(merge-rule "\textgreater{}" ">" :string)
+(merge-rule "\P{}" "¶" :string)
+(merge-rule "\S{}" "§" :string)
+(merge-rule "\texteuro{}" "€" :string)
+(merge-rule "\(\infty\)" "∞" :string)
+(merge-rule "\(\pm\)" "±" :string)
+(merge-rule "\(\rightarrow\)" "→" :string)
+(merge-rule "\(\checkmark\)" "✓" :string)
+(merge-rule "\textendash{}" "–" :string)
+(merge-rule "\textbar{}" "|" :string)
+(merge-rule "\(\sp{\text{0}}\)" "⁰" :string)
+(merge-rule "\(\sp{\text{1}}\)" "¹" :string)
+(merge-rule "\(\sp{\text{2}}\)" "²" :string)
+(merge-rule "\(\sp{\text{3}}\)" "³" :string)
+(merge-rule "\(\sp{\text{4}}\)" "⁴" :string)
+(merge-rule "\(\sp{\text{5}}\)" "⁵" :string)
+(merge-rule "\(\sp{\text{6}}\)" "⁶" :string)
+(merge-rule "\(\sp{\text{7}}\)" "⁷" :string)
+(merge-rule "\(\sp{\text{8}}\)" "⁸" :string)
+(merge-rule "\(\sp{\text{9}}\)" "⁹" :string)
+(merge-rule "\(\sb{\text{0}}\)" "₀" :string)
+(merge-rule "\(\sb{\text{1}}\)" "₁" :string)
+(merge-rule "\(\sb{\text{2}}\)" "₂" :string)
+(merge-rule "\(\sb{\text{3}}\)" "₃" :string)
+(merge-rule "\(\sb{\text{4}}\)" "₄" :string)
+(merge-rule "\(\sb{\text{5}}\)" "₅" :string)
+(merge-rule "\(\sb{\text{6}}\)" "₆" :string)
+(merge-rule "\(\sb{\text{7}}\)" "₇" :string)
+(merge-rule "\(\sb{\text{8}}\)" "₈" :string)
+(merge-rule "\(\sb{\text{9}}\)" "₉" :string)
+(merge-rule "\IeC {\textalpha }" "α" :string)
+(merge-rule "\IeC {\textbeta }" "β" :string)
+(merge-rule "\IeC {\textgamma }" "γ" :string)
+(merge-rule "\IeC {\textdelta }" "δ" :string)
+(merge-rule "\IeC {\textepsilon }" "ε" :string)
+(merge-rule "\IeC {\textzeta }" "ζ" :string)
+(merge-rule "\IeC {\texteta }" "η" :string)
+(merge-rule "\IeC {\texttheta }" "θ" :string)
+(merge-rule "\IeC {\textiota }" "ι" :string)
+(merge-rule "\IeC {\textkappa }" "κ" :string)
+(merge-rule "\IeC {\textlambda }" "λ" :string)
+(merge-rule "\IeC {\textmu }" "μ" :string)
+(merge-rule "\IeC {\textnu }" "ν" :string)
+(merge-rule "\IeC {\textxi }" "ξ" :string)
+(merge-rule "\IeC {\textomicron }" "ο" :string)
+(merge-rule "\IeC {\textpi }" "π" :string)
+(merge-rule "\IeC {\textrho }" "ρ" :string)
+(merge-rule "\IeC {\textsigma }" "σ" :string)
+(merge-rule "\IeC {\texttau }" "τ" :string)
+(merge-rule "\IeC {\textupsilon }" "υ" :string)
+(merge-rule "\IeC {\textphi }" "φ" :string)
+(merge-rule "\IeC {\textchi }" "χ" :string)
+(merge-rule "\IeC {\textpsi }" "ψ" :string)
+(merge-rule "\IeC {\textomega }" "ω" :string)
+(merge-rule "\IeC {\textAlpha }" "Α" :string)
+(merge-rule "\IeC {\textBeta }" "Β" :string)
+(merge-rule "\IeC {\textGamma }" "Γ" :string)
+(merge-rule "\IeC {\textDelta }" "Δ" :string)
+(merge-rule "\IeC {\textEpsilon }" "Ε" :string)
+(merge-rule "\IeC {\textZeta }" "Ζ" :string)
+(merge-rule "\IeC {\textEta }" "Η" :string)
+(merge-rule "\IeC {\textTheta }" "Θ" :string)
+(merge-rule "\IeC {\textIota }" "Ι" :string)
+(merge-rule "\IeC {\textKappa }" "Κ" :string)
+(merge-rule "\IeC {\textLambda }" "Λ" :string)
+(merge-rule "\IeC {\textMu }" "Μ" :string)
+(merge-rule "\IeC {\textNu }" "Ν" :string)
+(merge-rule "\IeC {\textTheta }" "Θ" :string)
+(merge-rule "\IeC {\textIota }" "Ι" :string)
+(merge-rule "\IeC {\textKappa }" "Κ" :string)
+(merge-rule "\IeC {\textLambda }" "Λ" :string)
+(merge-rule "\IeC {\textMu }" "Μ" :string)
+(merge-rule "\IeC {\textNu }" "Ν" :string)
+(merge-rule "\IeC {\textXi }" "Ξ" :string)
+(merge-rule "\IeC {\textOmicron }" "Ο" :string)
+(merge-rule "\IeC {\textPi }" "Π" :string)
+(merge-rule "\IeC {\textRho }" "Ρ" :string)
+(merge-rule "\IeC {\textSigma }" "Σ" :string)
+(merge-rule "\IeC {\textTau }" "Τ" :string)
+(merge-rule "\IeC {\textUpsilon }" "Υ" :string)
+(merge-rule "\IeC {\textPhi }" "Φ" :string)
+(merge-rule "\IeC {\textChi }" "Χ" :string)
+(merge-rule "\IeC {\textPsi }" "Ψ" :string)
+(merge-rule "\IeC {\textOmega }" "Ω" :string)
+(merge-rule "\IeC {\textohm }" "Ω" :string)
+
+;; This xindy module provides some basic support for "see"
+(require "makeindex.xdy")
+
+;; This creates one-letter headings and works fine with utf-8 letters.
+;; For Cyrillic with pdflatex works thanks to LICRcyr2utf8.xdy
+(require "latin-lettergroups.xdy")
+
+;; currently we don't (know how to easily) separate "Numbers" from
+;; "Symbols" with xindy as is the case with makeindex.
+(markup-index :open "\begin{sphinxtheindex}
+\let\lettergroup\sphinxstyleindexlettergroup
+\let\lettergroupDefault\sphinxstyleindexlettergroupDefault
+\let\spxpagem\sphinxstyleindexpagemain
+\let\spxentry\sphinxstyleindexentry
+\let\spxextra\sphinxstyleindexextra
+
+"
+ :close "
+
+\end{sphinxtheindex}
+"
+ :tree)
+
diff --git a/sphinx/texinputs/sphinxhowto.cls b/sphinx/texinputs/sphinxhowto.cls
new file mode 100644
index 0000000..8d7dd0e
--- /dev/null
+++ b/sphinx/texinputs/sphinxhowto.cls
@@ -0,0 +1,102 @@
+%
+% sphinxhowto.cls for Sphinx (https://www.sphinx-doc.org/)
+%
+
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesClass{sphinxhowto}[2019/12/01 v2.3.0 Document class (Sphinx howto)]
+
+% 'oneside' option overriding the 'twoside' default
+\newif\if@oneside
+\DeclareOption{oneside}{\@onesidetrue}
+% Pass remaining document options to the parent class.
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}}
+\ProcessOptions\relax
+
+% Default to two-side document
+\if@oneside
+% nothing to do (oneside is the default)
+\else
+\PassOptionsToClass{twoside}{\sphinxdocclass}
+\fi
+
+\LoadClass{\sphinxdocclass}
+
+% Set some sane defaults for section numbering depth and TOC depth. You can
+% reset these counters in your preamble.
+%
+\setcounter{secnumdepth}{2}
+\setcounter{tocdepth}{2}% i.e. section and subsection
+
+% Adapt \and command to the flushright context of \sphinxmaketitle, to
+% avoid ragged line endings if author names do not fit all on one single line
+\DeclareRobustCommand{\and}{%
+ \end{tabular}\kern-\tabcolsep
+ \allowbreak
+ \hskip\dimexpr1em+\tabcolsep\@plus.17fil\begin{tabular}[t]{c}%
+}%
+% If it is desired that each author name be on its own line, use in preamble:
+%\DeclareRobustCommand{\and}{%
+% \end{tabular}\kern-\tabcolsep\\\begin{tabular}[t]{c}%
+%}%
+% Change the title page to look a bit better, and fit in with the fncychap
+% ``Bjarne'' style a bit better.
+%
+\newcommand{\sphinxmaketitle}{%
+ \noindent\rule{\linewidth}{1pt}\par
+ \begingroup % for PDF information dictionary
+ \def\endgraf{ }\def\and{\& }%
+ \pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup
+ \hypersetup{pdfauthor={\@author}, pdftitle={\@title}}%
+ \endgroup
+ \begin{flushright}
+ \sphinxlogo
+ \py@HeaderFamily
+ {\Huge \@title }\par
+ {\itshape\large \py@release \releaseinfo}\par
+ \vspace{25pt}
+ {\Large
+ \begin{tabular}[t]{c}
+ \@author
+ \end{tabular}\kern-\tabcolsep}\par
+ \vspace{25pt}
+ \@date \par
+ \py@authoraddress \par
+ \end{flushright}
+ \@thanks
+ \setcounter{footnote}{0}
+ \let\thanks\relax\let\maketitle\relax
+ %\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
+}
+
+\newcommand{\sphinxtableofcontents}{%
+ \begingroup
+ \parskip \z@skip
+ \sphinxtableofcontentshook
+ \tableofcontents
+ \endgroup
+ \noindent\rule{\linewidth}{1pt}\par
+ \vspace{12pt}%
+}
+\newcommand\sphinxtableofcontentshook{}
+\pagenumbering{arabic}
+
+% Fix the bibliography environment to add an entry to the Table of
+% Contents.
+% For an article document class this environment is a section,
+% so no page break before it.
+%
+\newenvironment{sphinxthebibliography}[1]{%
+ % \phantomsection % not needed here since TeXLive 2010's hyperref
+ \begin{thebibliography}{#1}%
+ \addcontentsline{toc}{section}{\ifdefined\refname\refname\else\ifdefined\bibname\bibname\fi\fi}}{\end{thebibliography}}
+
+
+% Same for the indices.
+% The memoir class already does this, so we don't duplicate it in that case.
+%
+\@ifclassloaded{memoir}
+ {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}
+ {\newenvironment{sphinxtheindex}{%
+ \phantomsection % needed because no chapter, section, ... is created by theindex
+ \begin{theindex}%
+ \addcontentsline{toc}{section}{\indexname}}{\end{theindex}}}
diff --git a/sphinx/texinputs/sphinxlatexadmonitions.sty b/sphinx/texinputs/sphinxlatexadmonitions.sty
new file mode 100644
index 0000000..a31ae4c
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexadmonitions.sty
@@ -0,0 +1,242 @@
+%% NOTICES AND ADMONITIONS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexadmonitions.sty}[2023/03/19 admonitions]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+%
+% - sphinxseealso environment added at 6.1.0
+%
+% - sphinxadmonition (environment)
+% This is a dispatch supporting
+%
+% - note, hint, important, tip (via sphinxlightbox)
+% (also optionally via sphinxheavybox since 6.2.0)
+% - warning, caution, attention, danger, error (via sphinxheavybox)
+%
+% Each sphinx<notice name> environment can be redefined by user.
+% The defaults are customizable via various colour and dimension
+% settings, cf sphinx docs (latex customization).
+%
+% Requires:
+\RequirePackage{sphinxpackageboxes}
+\RequirePackage{framed}% used by sphinxheavybox
+%
+% Dependencies (they do not need to be defined at time of loading):
+%
+% - of course the various colour and dimension options handled via sphinx.sty
+%
+% - dimension register \spx@image@maxheight from sphinxlatexgraphics.sty
+%
+% - \savenotes/\spewnotes from sphinxpackagefootnote (for sphinxheavybox)
+%
+% - \sphinxstylenotetitle, ..., \sphinxstylewarningtitle, etc... which are used by
+% default in the corresponding sphinx<notice> environments to replace at 6.2.0
+% formerly hard-coded \sphinxstrong{#1}<space>
+% Their definitions are in sphinxlatexstyletext.sty.
+
+
+% Provides: (also in sphinxlatexliterals.sty)
+\providecommand*\sphinxvspacefixafterfrenchlists{%
+ \ifvmode\ifdim\lastskip<\z@ \vskip\parskip\fi\else\par\fi
+}
+
+% Some are quite plain
+\newenvironment{sphinxseealso}[1]{\sphinxstyleseealsotitle{#1}}{}
+
+% This \dimen register is a legacy relic from Sphinx 1.5 which is used now
+% only for sphinxlightbox. It is set in the sphinxadmonition environment.
+\newdimen\spx@notice@border
+
+\newenvironment{sphinxlightbox}{%
+ \par
+ \noindent{\color{spx@notice@bordercolor}%
+ \rule{\linewidth}{\spx@notice@border}}%
+ \par\nobreak
+ {\parskip\z@skip\noindent}%
+ }
+ {%
+ % counteract previous possible negative skip (French lists!):
+ % (we can't cancel that any earlier \vskip introduced a potential pagebreak)
+ \sphinxvspacefixafterfrenchlists
+ \nobreak\vbox{\noindent\kern\@totalleftmargin
+ {\color{spx@notice@bordercolor}%
+ \rule[\dimexpr.4\baselineskip-\spx@notice@border\relax]
+ {\linewidth}{\spx@notice@border}}\hss}\allowbreak
+ }% end of sphinxlightbox environment definition
+
+% note/hint/important/tip notices
+%
+% Since 1.5 these environments are named individually to allow user to
+% redefine them entirely.
+%
+% The Sphinx definitions were done like this, prior to 6.2.0:
+%
+% \newenvironment{sphinxhint}[1]
+% {\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
+%
+% The more complex definition below will branch to sphinxheavybox if a certain
+% boolean associated to the notice type is true. This boolean is set to true
+% whenever a CSS-named alike options for the notice type has been used in
+% sphinxsetup. The old coding as above would still work, with the new options
+% being then simply ignored. A user redefinition will probably either use
+% directly sphinxlightbox or sphinxheavybox or something else, with no need to
+% test the boolean.
+%
+% 6.2.0 also adds one layer of mark-up via \sphinxnotetitle etc..., because
+% the former \sphinxstrong{#1}<space> used a too generic \sphinxstrong. But
+% perhaps the #1 should be passed over to sphinx{light,heavy}box as parameter.
+% Unfortunately replacing these environments with one-parameter environments
+% would be potentially a breaking change. Anyway, sphinxpackageboxes.sty does not
+% provide a "titled" box; the caption of code-blocks is handled by extra
+% code in sphinxVerbatim.
+\newenvironment{sphinxnote}[1]
+ {\edef\spx@env{sphinx\ifspx@opt@heavynote heavy\else light\fi box}%
+ \expandafter\begin\expandafter{\spx@env}\sphinxstylenotetitle{#1}}
+ {\expandafter\end\expandafter{\spx@env}}
+\newenvironment{sphinxhint}[1]
+ {\edef\spx@env{sphinx\ifspx@opt@heavyhint heavy\else light\fi box}%
+ \expandafter\begin\expandafter{\spx@env}\sphinxstylehinttitle{#1}}
+ {\expandafter\end\expandafter{\spx@env}}
+\newenvironment{sphinximportant}[1]
+ {\edef\spx@env{sphinx\ifspx@opt@heavyimportant heavy\else light\fi box}%
+ \expandafter\begin\expandafter{\spx@env}\sphinxstyleimportanttitle{#1}}
+ {\expandafter\end\expandafter{\spx@env}}
+\newenvironment{sphinxtip}[1]
+ {\edef\spx@env{sphinx\ifspx@opt@heavytip heavy\else light\fi box}%
+ \expandafter\begin\expandafter{\spx@env}\sphinxstyletiptitle{#1}}
+ {\expandafter\end\expandafter{\spx@env}}
+
+% warning/caution/attention/danger/error get more distinction
+%
+% Code adapted from framed.sty's "snugshade" environment.
+% Nesting works (inner frames do not allow page breaks).
+\newenvironment{sphinxheavybox}{\par
+ % 6.2.0 allows to not have to distinguish here between warning type notices
+ % which always use sphinxheavybox or note type notices which might use it.
+ % (MEMO: it is not a problem here if there is no sphinx<type>ShadowColor,
+ % as it used only if set)
+ \spx@boxes@fcolorbox@setup{\spx@noticetype}%
+ % Those are used by sphinxVerbatim if the \ifspx@inframed boolean is true
+ \setlength{\FrameRule}{0.5\dimexpr\spx@boxes@border@top+\spx@boxes@border@bottom\relax}%
+ % MEMO: prior to 5.1.0 \FrameSep was determined as 0.6\baselineskip -
+ % \FrameRule, and there was no possibility for user to adjust padding.
+ % Then \fcolorbox was used with \fboxrule set to \FrameRule and \fboxsep
+ % set to \FrameSep.
+ % The 5.1.0 default calculation of padding parameters maintains PDF output
+ % identical to legacy behaviour, as long as padding is not set by user.
+ \setlength{\FrameSep}{0.5\dimexpr\spx@boxes@padding@top+\spx@boxes@padding@bottom\relax}%
+ % "setup" macro has prepared the \spx@boxes@... dimen registers
+ \advance\spx@image@maxheight
+ -\dimexpr\spx@boxes@border@top+\spx@boxes@border@bottom
+ +\spx@boxes@padding@top+\spx@boxes@padding@bottom
+ +\baselineskip\relax % will happen again if nested, needed indeed!
+ % MEMO: the next comment is before boxing was extended to allow padding and
+ % multiple border-widths, not to mention shadows...
+ % configure framed.sty's parameters to obtain same vertical spacing
+ % as for "light" boxes. We need for this to manually insert parskip glue and
+ % revert a skip done by framed before the frame.
+ \ltx@ifundefined{OuterFrameSep}{}{\OuterFrameSep\z@skip}%
+ \vspace{\FrameHeightAdjust}
+ % copied/adapted from framed.sty's snugshade
+ % but now using in place of \fcolorbox the Sphinx sophisticated own
+ \def\FrameCommand##1{%
+ \hskip\@totalleftmargin
+ % "setup" macro MUST have been called before
+ \spx@boxes@fcolorbox{##1}%
+ \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
+ }%
+ % 6.2.0 adds support for div.<notice type>_box-decoration-break=slice.
+ % (it is yet undecided if slice style should inhibit a bottom shadow)
+ \csname ifspx@\spx@noticetype @border@open\endcsname
+ \def\FirstFrameCommand
+ {\spx@boxes@fcolorbox@setup@openbottom\FrameCommand}%
+ \def\MidFrameCommand
+ {\spx@boxes@fcolorbox@setup@openboth \FrameCommand}%
+ \def\LastFrameCommand
+ {\spx@boxes@fcolorbox@setup@opentop \FrameCommand}%
+ \fi
+ \savenotes
+ % use a minipage if we are already inside a framed environment
+ \ifspx@inframed
+ \noindent\begin{minipage}{\linewidth}
+ \else
+ % handle case where notice is first thing in a list item (or is quoted)
+ \if@inlabel
+ \noindent\par\vspace{-\baselineskip}
+ \else
+ \vspace{\parskip}
+ \fi
+ \fi
+ \MakeFramed {\spx@inframedtrue
+ \advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize
+ % minipage initialization copied from LaTeX source code.
+ \@pboxswfalse
+ \let\@listdepth\@mplistdepth \@mplistdepth\z@
+ \@minipagerestore
+ \@setminipage }%
+ \color@begingroup % workaround to an upstream framed.sty bug
+ }
+ {%
+ \par\unskip
+ \color@endgroup % matches the \color@begingroup
+ \@minipagefalse
+ \endMakeFramed
+ \ifspx@inframed\end{minipage}\fi
+ % set footnotes at bottom of page
+ \spewnotes
+ % arrange for similar spacing below frame as for "light" boxes.
+ \vskip .4\baselineskip
+ }% end of sphinxheavybox environment definition
+
+% - Since 1.5 these environments are named individually to allow user to
+% redefine them entirely.
+%
+% - Since 5.1.0, sphinxheavybox is more versatile and four border widths, four
+% padding widths, four corner radii, optional shadow, and three colors can all
+% be modified via CSS-named alike options.
+%
+% - Since 6.2.0, also note/hint/important/tip notices can use these options
+% and then they go automatically via sphinxheavybox. If only the legacy options
+% are used, they keep using sphinxlightbox.
+%
+% - Since 6.2.0, \sphinxwarningtitle etc... add one level of mark-up (they
+% expand to \sphinxstrong{#1}<space> which was former hard-coded mark-up).
+% Example:
+% \renewcommand{\sphinxwarningtitle}[1]{\textbf{#1}\par\smallskip
+% {\color{sphinxwarningBorderColor}\hrule height1pt}\smallskip}
+\newenvironment{sphinxwarning}[1]
+ {\begin{sphinxheavybox}\sphinxstylewarningtitle{#1}}{\end{sphinxheavybox}}
+\newenvironment{sphinxcaution}[1]
+ {\begin{sphinxheavybox}\sphinxstylecautiontitle{#1}}{\end{sphinxheavybox}}
+\newenvironment{sphinxattention}[1]
+ {\begin{sphinxheavybox}\sphinxstyleattentiontitle{#1}}{\end{sphinxheavybox}}
+\newenvironment{sphinxdanger}[1]
+ {\begin{sphinxheavybox}\sphinxstyledangertitle{#1}}{\end{sphinxheavybox}}
+\newenvironment{sphinxerror}[1]
+ {\begin{sphinxheavybox}\sphinxstyleerrortitle{#1}}{\end{sphinxheavybox}}
+
+% the main dispatch for all types of notices
+\newenvironment{sphinxadmonition}[2]{% #1=type, #2=heading
+ % can't use #1 directly in definition of end part
+ \def\spx@noticetype {#1}%
+ % those next three are a remnant of legacy code; they are not used at
+ % all by sphinxheavybox, and their usage could be disposed of by sphinxlightbox
+ % but we keep for backward compatibility and also because it may be simpler
+ % for user redefinitions to employ for example "spx@notice@bgcolor" and not
+ % the more bulky "sphinx\spx@noticetype BgColor".
+ \sphinxcolorlet{spx@notice@bordercolor}{sphinx#1BorderColor}%
+ \sphinxcolorlet{spx@notice@bgcolor}{sphinx#1BgColor}%
+ \spx@notice@border \dimexpr\csname spx@#1@border\endcsname\relax
+ % trigger the sphinx<type> environment, #2=heading is passed as argument
+ \begin{sphinx#1}{#2}%
+ % 6.2.0 support of div.<type>_TeX{color,extras} options
+ \csname ifspx@\spx@noticetype @withtextcolor\endcsname
+ \color{sphinx\spx@noticetype TextColor}%
+ \fi
+ \csname spx@\spx@noticetype @TeXextras\endcsname
+ }
+ % workaround some LaTeX "feature" of \end command (can't use "sphinx#1" here)
+ {\edef\spx@temp{\noexpand\end{sphinx\spx@noticetype}}\spx@temp}
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexcontainers.sty b/sphinx/texinputs/sphinxlatexcontainers.sty
new file mode 100644
index 0000000..93b2c8c
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexcontainers.sty
@@ -0,0 +1,22 @@
+%% CONTAINER DIRECTIVES
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexcontainers.sty}[2021/05/03 containers]
+
+% The purpose of this file is to provide a dummy environment sphinxclass which
+% will be inserted for each class in each container directive. The class name
+% will be passed as the argument to the environment.
+%
+% For a class foo, the user can define customised handling of that class by
+% defining the sphinxclassfoo LaTeX environment.
+
+\newenvironment{sphinxuseclass}[1]{%
+ \def\sphinxClassFunctionName{sphinxclass#1}%
+ \ltx@ifundefined{\sphinxClassFunctionName}%
+ {}% undefined so do nothing
+ {\expandafter\begin\expandafter{\sphinxClassFunctionName}}%
+}{%
+ \ltx@ifundefined{\sphinxClassFunctionName}%
+ {}% we did nothing so we keep doing nothing
+ {\expandafter\end\expandafter{\sphinxClassFunctionName}}%
+}%
diff --git a/sphinx/texinputs/sphinxlatexgraphics.sty b/sphinx/texinputs/sphinxlatexgraphics.sty
new file mode 100644
index 0000000..fd0aae6
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexgraphics.sty
@@ -0,0 +1,122 @@
+%% GRAPHICS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexgraphics.sty}[2021/01/27 graphics]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+%
+% - macros:
+%
+% - \sphinxfigcaption
+% - \sphinxincludegraphics
+%
+% - environments:
+%
+% - sphinxfigure-in-table
+%
+% May change:
+%
+% - \sphinxcaption (at begin document)
+%
+% Also provides:
+%
+% - \sphinxsafeincludegraphics (default of \sphinxincludegraphics since 2.0)
+% - \spx@image@maxheight dimension (used by sphinxlatexadmonitions.sty)
+% - \spx@image@box scratch box register (also used by sphinxlatexliterals.sty)
+%
+% Requires:
+% \RequirePackage{graphicx}% done in sphinx.sty
+\RequirePackage{amstext}% needed for \firstchoice@true(false)
+
+% \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
+\newbox\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}}
+% 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}
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexindbibtoc.sty b/sphinx/texinputs/sphinxlatexindbibtoc.sty
new file mode 100644
index 0000000..79e30a1
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexindbibtoc.sty
@@ -0,0 +1,69 @@
+%% INDEX, BIBLIOGRAPHY, APPENDIX, TABLE OF CONTENTS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexindbibtoc.sty}[2021/01/27 index, bib., toc]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+%
+% - environments: (backup defaults or get redefined)
+%
+% - sphinxtheindex (direct mark-up or via python.ist or sphinx.xdy)
+% - sphinxthebibliography
+%
+% - macros: (defines defaults)
+%
+% - \sphinxmaketitle
+% - \sphinxtableofcontents
+% - \sphinxnonalphabeticalgroupname
+% - \sphinxsymbolsname
+% - \sphinxnumbersname
+% - \sphinxcite
+%
+% Requires:
+\RequirePackage{makeidx}
+
+% 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*{\sphinxmaketitle}{\maketitle}
+\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}{}
+
+\protected\def\sphinxcite{\cite}
+
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexlists.sty b/sphinx/texinputs/sphinxlatexlists.sty
new file mode 100644
index 0000000..8e79355
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexlists.sty
@@ -0,0 +1,131 @@
+%% ALPHANUMERIC LIST ITEMS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexlists.sty}[2021/12/20 lists]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+% - \sphinxsetlistlabels
+% - \sphinxlineitem
+% and for the maxlistdepth key of sphinxsetup
+% Dependencies: the \spx@opt@maxlistdepth from sphinx.sty
+
+% We need some helpers macros
+\newtoks\spx@lineitemlabel
+\long\def\sphinx@gobto@sphinxlineitem#1\sphinxlineitem{}
+% TeX/LaTeX has no (easy to use) built-in "peek-ahead" mechanism, but
+% we would like to know if next token is another \sphinxlineitem (this
+% can happen in glossary entries with multiple terms for same definition)
+% so we simply grab next token (assuming it is not {tokens} originally)
+\newcommand\sphinxlineitem[2]{%
+ % safe test of whether #2 is \sphinxlineitem
+ \sphinx@gobto@sphinxlineitem#2\@gobbletwo\sphinxlineitem\unless
+ \iftrue
+ % case with sphinxlineitem immediately followed by another \sphinxlineitem:
+ % accumulate successive terms until actual definition or sub-list is found
+ \spx@lineitemlabel\expandafter{\the\spx@lineitemlabel\strut#1\\}%
+ \else
+ % now issue the \item command with possibly multi-line contents
+ % these weird incantations with \kern are related to how LaTeX
+ % handles \item generally
+ \item[\kern\labelwidth\kern-\itemindent\kern-\leftmargin
+ {\parbox[t]{\dimexpr\linewidth+\leftmargin\relax}{%
+ \raggedright
+ \the\spx@lineitemlabel% accumulated terms before this one, CR separated
+ \strut#1}}% due to LaTeX internals no \par token allowed here,
+ % but the \parbox will insert one tacitly at end
+ \kern-\labelsep]%
+ \spx@lineitemlabel{}%
+ % this causes the label to be typeset (filling up the line), clearing up
+ % things in case a nested list follows.
+ \leavevmode
+ \fi #2%
+}%
+
+
+\newcommand\sphinxsetlistlabels[5]
+{% #1 = style, #2 = enum, #3 = enumnext, #4 = prefix, #5 = suffix
+ % #2 and #3 are counters used by enumerate environment 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
+}
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexliterals.sty b/sphinx/texinputs/sphinxlatexliterals.sty
new file mode 100644
index 0000000..3a73a76
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexliterals.sty
@@ -0,0 +1,1004 @@
+%% LITERAL BLOCKS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexliterals.sty}[2023/04/01 code-blocks and parsed literals]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+%
+% - macros:
+% - \sphinxLiteralBlockLabel
+% - \sphinxSetupCaptionForVerbatim
+% - \sphinxSetupCodeBlockInFootnote
+% - \sphinxhref
+% - \sphinxnolinkurl
+% - \sphinxresetverbatimhllines
+% - \sphinxunactivateextrasandspace
+% - \sphinxupquote
+% - \sphinxurl
+%
+% - environments:
+% - sphinxVerbatim
+% - sphinxVerbatimintable
+% - sphinxalltt
+%
+% Dependency:
+%
+% - hyperref (for \phantomsection and \capstart) (loaded later)
+%
+% Executes \RequirePackage for:
+%
+% - framed
+% - fancyvrb
+% - alltt
+% - upquote
+% - needspace
+% - sphinxpackageboxes
+\RequirePackage{sphinxpackageboxes}
+
+% also in sphinxlatexadmonitions.sty:
+% This is a workaround to a "feature" of French lists, when literal block
+% follows immediately; usable generally (does only \par then), a priori...
+\providecommand*\sphinxvspacefixafterfrenchlists{%
+ \ifvmode\ifdim\lastskip<\z@ \vskip\parskip\fi\else\par\fi
+}
+
+% For framing allowing pagebreaks
+\RequirePackage{framed}
+% For source code
+% MEMO: fancyvrb is used mainly to
+% 1- control horizontal and vertical spacing
+% 2- optional line numbering
+% 3- optional line emphasizing
+% 4- while still allowing expansion of Pygments latex mark-up
+% Other aspects such as framing, caption handling, codeline wrapping are
+% added on top of it. We should stop using fancyvrb and implement
+% 1, 2, 3, 4 by own Sphinx fully native Verbatim. This would greatly simplify
+% in particular wrapping long code lines in a way allowing page breaks.
+\RequirePackage{fancyvrb}
+% For parsed-literal blocks.
+\RequirePackage{alltt}
+% Display "real" single quotes in literal blocks.
+\RequirePackage{upquote}
+% Skip to next page if not enough space at bottom
+\RequirePackage{needspace}
+
+% 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 ("sphinxpackagefootnote.sty").
+
+% for emphasizing lines
+\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
+
+% Prior to Sphinx 1.5, \Verbatim and \endVerbatim were modified by Sphinx.
+% The aliases defined here are used in sphinxVerbatim environment and can
+% serve as hook-points with no need to modify \Verbatim itself.
+\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}
+
+% if forced use of minipage encapsulation is needed (e.g. table cells)
+\newif\ifsphinxverbatimwithminipage \sphinxverbatimwithminipagefalse
+
+% Framing macro for use with framed.sty's \FrameCommand
+% MEMO: the sophisticated code in \spx@fcolorbox/\spx@CustomFBox
+% is here for good reasons
+% - be responsive to indented list environments in the manner of
+% the "framed" (\fbox) and "shaded" (\colorbox) environments of
+% framed.sty; indeed code here is an evolution related to \fcolorbox
+% - attach non-detachable continuation hints above/below frame
+% - draw the frame and fill the background color in a manner avoiding
+% problems in some pdf viewers
+% - do background coloring differently from color.sty/xcolor.sty macros
+% (even core internal ones) to work around issues at page breaks
+% as the framed contents are split into chunks with possibly unpaired
+% "color push" or "color pop"
+% About the produced output:
+% - it obeys current indentation,
+% - frame with 4 padding parameters and 4 border-width parameters
+% - the contents use the full available text width, limited by indentation,
+% - #1 = will be typeset above frame, in a non detachable way,
+% - #2 = will be typeset below frame, in a non detachable way,
+% - #3 = will be typeset within the frame.
+% #1 and #2 are expected to be already typeset \hbox'es.
+% #3 are the contents, and in the context of usage of fancyvrb+framed,
+% it will arrive here already transformed into horizontal boxes,
+% interline penalties and glues.
+%
+\long\def\spx@verb@FrameCommand #1#2#3{%
+ % The \spx@verb@boxes@fcolorbox@setup MUST have been executed beforehand.
+ % These \hskips are for fancyvrb.sty measuring and will make the
+ % framing "adapt" to an indented context.
+ \hskip\@totalleftmargin
+ \hskip-\spx@boxes@border@left\hskip-\spx@boxes@padding@left
+ \spx@verb@fcolorbox {#1}{#2}{#3}%
+ \hskip-\spx@boxes@padding@right\hskip-\spx@boxes@border@right
+ \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
+}%
+\long\def\spx@verb@fcolorbox #1#2#3{%
+ % The \spx@verb@boxes@fcolorbox@setup MUST have been executed beforehand.
+%
+ % MEMO: in the context of framed.sty this will always expand inside some
+ % \hbox isolated from other code, so we can use \box\z@, \box\tw@,...
+ % with no need of extra group.
+%
+ % MEMO: this code was originally using \color@b@x but the latter has
+ % problematic features regarding color in a context like here where #3
+ % may contain an unbalanced "color push".
+%
+ \setbox\z@\hbox{#3}%
+ \edef\spx@verb@fcolorbox@width@sp
+ {\number\dimexpr\wd\z@+\spx@boxes@border@left
+ +\spx@boxes@padding@left
+ +\spx@boxes@padding@right
+ +\spx@boxes@border@right\relax sp}%
+ \vbox{#1% continuation hint attached above frame, uses \spx@verb@fcolorbox@width@sp
+ % the boxes@fcolorbox constructs an \hbox with bbox containing the border
+ % \spx@verb@boxes@fcolorbox@setup MUST have been executed beforehand.
+ \spx@boxes@fcolorbox{\box\z@}%
+ % This \nointerlineskip to maintain legacy spacing when a \hrule was
+ % formerly last prior item in vertical list. TODO: remove this at 6.0.0 ?
+ \nointerlineskip
+ #2% continuation hint attached below frame, uses \spx@verb@fcolorbox@width@sp
+ }% end of \vbox
+}%
+\def\spx@verb@fcolorbox@put@c#1{% hide width from framed.sty measuring
+ \moveright.5\dimexpr\spx@verb@fcolorbox@width@sp\hb@xt@\z@{\hss#1\hss}%
+}%
+\def\spx@verb@fcolorbox@put@r#1{% right align with contents, width hidden
+ \moveright\dimexpr\spx@verb@fcolorbox@width@sp-%
+ \spx@boxes@padding@right-%
+ \spx@boxes@border@right\hb@xt@\z@{\hss#1}%
+}%
+\def\spx@verb@fcolorbox@put@l#1{% left align with contents, width hidden
+ \moveright\dimexpr\spx@boxes@border@left+%
+ \spx@boxes@padding@left\hb@xt@\z@{#1\hss}%
+}%
+%
+\def\sphinxVerbatim@Continued{%
+ \csname spx@verb@fcolorbox@put@\spx@opt@verbatimcontinuedalign\endcsname
+ {{\normalcolor\sphinxstylecodecontinued\literalblockcontinuedname}}%
+}%
+\def\sphinxVerbatim@Continues{%
+ \csname spx@verb@fcolorbox@put@\spx@opt@verbatimcontinuesalign\endcsname
+ {{\normalcolor\sphinxstylecodecontinues\literalblockcontinuesname}}%
+}%
+\def\sphinxVerbatim@Title{%
+ \spx@verb@fcolorbox@put@c{\unhcopy\sphinxVerbatim@TitleBox}%
+}%
+\let\sphinxVerbatim@Before\@empty
+\let\sphinxVerbatim@After\@empty
+% Defaults are redefined in document preamble according to language
+\newcommand*\literalblockcontinuedname{continued from previous page}%
+\newcommand*\literalblockcontinuesname{continues on next page}%
+%
+\def\sphinxVerbatim@FrameCommand{%
+ \spx@verb@FrameCommand\sphinxVerbatim@Before\sphinxVerbatim@After
+}%
+\def\sphinxVerbatim@FirstFrameCommand{%
+ \ifspx@pre@border@open
+ \spx@boxes@fcolorbox@setup@openbottom
+ \fi
+ \spx@verb@FrameCommand\sphinxVerbatim@Before\sphinxVerbatim@Continues
+}%
+\def\sphinxVerbatim@MidFrameCommand{%
+ \ifspx@pre@border@open
+ \spx@boxes@fcolorbox@setup@openboth
+ \fi
+ \spx@verb@FrameCommand\sphinxVerbatim@Continued\sphinxVerbatim@Continues
+}%
+\def\sphinxVerbatim@LastFrameCommand{%
+ \ifspx@pre@border@open
+ \spx@boxes@fcolorbox@setup@opentop
+ \fi
+ \spx@verb@FrameCommand\sphinxVerbatim@Continued\sphinxVerbatim@After
+}%
+%
+\def\spx@verb@boxes@fcolorbox@setup{%
+ % Prepares usage of \spx@boxes@fcolorbox
+ % Extras to remap legacy color names VerbatimBorderColor and VerbatimColor
+ % to a common naming scheme with admonitions (and topic directive), as
+ % expected by \spx@boxes@fcolorbox@setup from sphinxpackageboxes.sty.
+ \sphinxcolorlet{sphinxpreBorderColor}{VerbatimBorderColor}%
+ \sphinxcolorlet{sphinxpreBgColor}{VerbatimColor}%
+ % This VerbatimShadowColor is not a legacy name nor user documented but is
+ % an outcome of sphinx.sty batch definitions for CSS option support.
+ \sphinxcolorlet{sphinxpreShadowColor}{VerbatimShadowColor}%
+ \spx@boxes@fcolorbox@setup{pre}%
+ \ifspx@opt@verbatimwithframe
+ \else
+ \spx@boxes@border@top\z@
+ \spx@boxes@border@right\z@
+ \spx@boxes@border@bottom\z@
+ \spx@boxes@border@left\z@
+ \spx@boxes@border\z@
+ % MEMO: rounded corners still make sense in presence of a background
+ % color, so we do not force the fcolorbox@rectangle here
+ \fi
+}%
+
+% For linebreaks inside Verbatim environment from package fancyvrb.
+\newbox\sphinxcontinuationbox
+\newbox\sphinxvisiblespacebox
+\newcommand*\sphinxafterbreak {\copy\sphinxcontinuationbox}
+
+% Take advantage of the already applied Pygments mark-up to insert
+% potential linebreaks for TeX processing.
+% {, <, #, %, $, ' and ": go to next line.
+% _, }, ^, &, >, -, ~, and \: stay at end of broken line.
+% Use of \textquotesingle for straight quote.
+% FIXME: convert this to package options ?
+\newcommand*\sphinxbreaksbeforelist {%
+ \do\PYGZob\{\do\PYGZlt\<\do\PYGZsh\#\do\PYGZpc\%% {, <, #, %,
+ \do\PYGZdl\$\do\PYGZdq\"% $, "
+ \def\PYGZsq
+ {\discretionary{}{\sphinxafterbreak\textquotesingle}{\textquotesingle}}% '
+}
+\newcommand*\sphinxbreaksafterlist {%
+ \do\PYGZus\_\do\PYGZcb\}\do\PYGZca\^\do\PYGZam\&% _, }, ^, &,
+ \do\PYGZgt\>\do\PYGZhy\-\do\PYGZti\~% >, -, ~
+ \do\PYGZbs\\% \
+}
+\newcommand*\sphinxbreaksatspecials {%
+ \def\do##1##2%
+ {\def##1{\discretionary{}{\sphinxafterbreak\char`##2}{\char`##2}}}%
+ \sphinxbreaksbeforelist
+ \def\do##1##2%
+ {\def##1{\discretionary{\char`##2}{\sphinxafterbreak}{\char`##2}}}%
+ \sphinxbreaksafterlist
+}
+
+\def\sphinx@verbatim@nolig@list {\do \`}%
+% Some characters . , ; ? ! / are neither pygmentized nor "tex-escaped".
+% This macro makes them "active" and they will insert potential linebreaks.
+% Not compatible with math mode (cf \sphinxunactivateextras, which uses
+% these lists to make sure activated characters get de-activated).
+\newcommand*\sphinxbreaksbeforeactivelist {}% none
+\newcommand*\sphinxbreaksafteractivelist {\do\.\do\,\do\;\do\?\do\!\do\/}
+\newcommand*\sphinxbreaksviaactive {%
+ \def\do##1{\lccode`\~`##1%
+ \lowercase{\def~}{\discretionary{}{\sphinxafterbreak\char`##1}{\char`##1}}%
+ \catcode`##1\active}%
+ \sphinxbreaksbeforeactivelist
+ \def\do##1{\lccode`\~`##1%
+ \lowercase{\def~}{\discretionary{\char`##1}{\sphinxafterbreak}{\char`##1}}%
+ \catcode`##1\active}%
+ \sphinxbreaksafteractivelist
+ \lccode`\~`\~
+}
+
+% If the linebreak is at a space, the latter will be displayed as visible
+% space at end of first line, and a continuation symbol starts next line.
+\def\spx@verbatim@space {%
+ \nobreak\hskip\z@skip
+ \discretionary{\copy\sphinxvisiblespacebox}{\sphinxafterbreak}
+ {\kern\fontdimen2\font}%
+}%
+
+% if the available space on page is less than \literalblockneedspace, insert pagebreak
+\newcommand{\sphinxliteralblockneedspace}{5\baselineskip}
+\newcommand{\sphinxliteralblockwithoutcaptionneedspace}{1.5\baselineskip}
+% The title (caption) is specified from outside as macro \sphinxVerbatimTitle.
+% \sphinxVerbatimTitle is reset to empty after each use of Verbatim.
+\newcommand*\sphinxVerbatimTitle {}
+% This box to typeset the caption before framed.sty multiple passes for framing.
+\newbox\sphinxVerbatim@TitleBox
+% This box to measure contents if nested as inner \MakeFramed requires then
+% minipage encapsulation but too long contents then break outer \MakeFramed
+\newbox\sphinxVerbatim@ContentsBox
+% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
+\newcommand*\sphinxLiteralBlockLabel {}
+\newcommand*\sphinxSetupCaptionForVerbatim [1]
+{%
+ \sphinxvspacefixafterfrenchlists
+ \needspace{\sphinxliteralblockneedspace}%
+% insert a \label via \sphinxLiteralBlockLabel
+% reset to normal the color for the literal block caption
+ \def\sphinxVerbatimTitle
+ {\py@NormalColor\sphinxcaption{\sphinxLiteralBlockLabel #1}}%
+}
+\newcommand*\sphinxSetupCodeBlockInFootnote {%
+ \fvset{fontsize=\footnotesize}\let\caption\sphinxfigcaption
+ \sphinxverbatimwithminipagetrue % reduces vertical spaces
+ % we counteract (this is in a group) the \@normalsize from \caption
+ \let\normalsize\footnotesize\let\@parboxrestore\relax
+ \def\spx@abovecaptionskip{\sphinxverbatimsmallskipamount}%
+}
+\newcommand*{\sphinxverbatimsmallskipamount}{\smallskipamount}
+% serves to implement line highlighting
+\newcommand\sphinxFancyVerbFormatLine[1]{%
+ \expandafter\sphinx@verbatim@checkifhl\expandafter{\the\FV@CodeLineNo}%
+ \ifin@
+ \sphinxVerbatimHighlightLine{#1}%
+ \else
+ \sphinxVerbatimFormatLine{#1}%
+ \fi
+}%
+\let\spx@original@set@color\set@color
+\newcommand\sphinxVerbatimHighlightLine[1]{%
+% This is morally a \colorbox (with a \fboxsep which would be 0pt)
+% but some issues of potential colour disappearance at pagebreaks
+% require workaround such as the one done here.
+ \leavevmode
+ % MEMO: usage of original \colorbox would insert a \set@color here
+ % and this then places a "color pop" at the end of the \box\z@.
+ % But this could pair erroneously with an unmatched "color push"
+ % as #1 is maybe only a part (already hboxed) of a codeline
+ % if (default) verbatimwrapslines=true
+ % (cf \spx@verb@@PreProcessLine; refs: #8686)
+ % MEMO: formerly we did something with \fboxsep in relation to the LaTeX
+ % bug graphics/4524 for \colorbox, but as we don't use \colorbox...
+ \setbox\z@\hb@xt@\linewidth{\strut#1\hss}%
+ % MEMO: \colorbox would lead to \color{sphinxVerbatimHighlightColor}
+ % plus \color@block, which results in doubled (a color.sty feature)
+ % color command send to device driver and more importantly has
+ % a "color pop" which will be after \box\z@. We avoid that for reasons
+ % mentioned above.
+ {%
+ \def\set@color{\let\set@color\spx@original@set@color}%
+ % will only set \current@color and delay the \set@color to \color@block
+ % as this all happens inside fancyvrb nested \hbox'es.
+ \color{sphinxVerbatimHighlightColor}%
+ % will use \current@color and pop it **before** \box\z@
+ \color@block{\wd\z@}{\ht\z@}{\dp\z@}\box\z@
+ }%
+ % we added a group only for \FV@RightListNumber not be influenced by the
+ % \current@color, if \fvset has been used to set numbers to the right.
+}%
+% MEMO: fancyvrb has options obeytabs and tabsize. Anyhow tab characters
+% do not make it to the tex file, they have been converted to spaces earlier.
+% But, if this was not the case, the support would be implemented here via
+% \newcommand\sphinxVerbatimFormatLine[1]{\FV@ObeyTabs{\strut #1}}%
+\newcommand\sphinxVerbatimFormatLine[1]{\strut#1}%
+% MEMO: if verbatimwrapslines is set to true (default) the #1 above is
+% simply \box\spx@tempboxb, from the next two macros.
+% The next two macros are a deep hack of fancyvrb.sty core line processing in
+% order to wrap too long lines, either at spaces and natural break-points,
+% (soft wrap) or optionally at any character (hard wrap). This requires deep
+% hack to work around the \hbox'es wrappers of fancyvrb.sty as they would
+% prevent page breaks. Formerly Sphinx obtained wrapping by inserting the
+% material into a vertical box (which was later again boxed -- twice -- by
+% fancyvrb thinking it was a single line...) but this was incompatible with
+% allowing page breaks (refs: #8686).
+% We use core TeX techniques to pre-process a paragraph then recover its
+% constituents lines (as boxes, not as tokens) and hand them over to original
+% fancyvrb line process. It is mandatory to update \FV@ProcessLine and
+% \@tempboxa globally to get fancyvrb internals into working to our
+% satisfaction.
+% This will get disrupted if anything adding vertical penalties or glues
+% is activated via some \vadjust from inside the Pygmentized code lines.
+\def\spx@verb@@ProcessLines{%
+ \unskip
+ \unpenalty
+ \setbox\spx@tempboxb\lastbox
+\ifvoid\spx@tempboxb\else
+ {\spx@verb@@ProcessLines}%
+ \FV@ProcessLine{\box\spx@tempboxb}%
+ \global\let\FV@ProcessLine\FV@ProcessLine
+ \global\setbox\@tempboxa=\box\@tempboxa
+ \aftergroup\spx@verb@@InhibitLineNumber
+\fi
+}%
+\def\spx@verb@@InhibitLineNumber{%
+ \let\FV@LeftListNumber\relax
+ \let\FV@RightListNumber\relax
+}%
+% This will replace fancyvrb's \FV@@PreProcessLine
+% Instead of boxing \FV@Line (which contains the Pygmentized line tokens), we
+% first typeset it in a vertical box of the suitable width (taking into
+% account nested lists) to activate the TeX built-in paragraph builder, then
+% we recover individual lines as horizontal boxes and feed them to fancyvrb
+% native line processing (which may add line numbers). The interline
+% penalties and vertical glue to maintain baseline distance will be added
+% again by this process so in recursive \spx@verb@@ProcessLines which starts
+% from bottom and makes its way up to first part of the wrapped line we do not
+% need to worry about them. An additional initial measuring step is needed if
+% user issued verbatimforcewraps=true, which elaborates on the same technique.
+% If hard wraps get activated, they get implemented via hacked \PYG macros.
+\def\spx@verb@@PreProcessLine{%
+ \FV@StepLineNo
+ \FV@Gobble
+ \def\spx@verb@FV@Line{\FV@Line}%
+ \ifspx@opt@verbatimforcewraps
+ \spx@verb@DecideIfWillDoForceWrap
+ \fi
+% MEMO: \everypar{} was issued earlier (and due to \@setminipage
+% would have been only \@minipagefalse\everypar{} otherwise).
+ \setbox\spx@tempboxa=\vtop{\hsize\linewidth
+ \raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
+ \doublehyphendemerits\z@\finalhyphendemerits\z@
+% MEMO: fancyvrb has options obeytabs and tabsize. Anyhow tab characters
+% do not make it to the tex file, they have been converted to spaces earlier.
+% But, if this was not the case, the support would be implemented here via
+% \FV@ObeyTabs{\strut\spx@verb@FV@Line\strut}%
+% And one would need a similar change in the measuring phase done by
+% \spx@verb@DecideIfWillDoForceWrap
+ \strut\spx@verb@FV@Line\strut
+% MEMO: since LaTeX 2021-06-01, there might be some hooks executed at
+% start and end of paragraphs (in future: PDF tagging), but we need an
+% explicit \par here for that. Else the kernel hooks at start of paragraph
+% are executed but not the ones at its end.
+ \par
+ }%
+ \setbox\spx@tempboxa=\vtop{\unvbox\spx@tempboxa
+ \setbox\spx@tempboxb\lastbox
+ {\spx@verb@@ProcessLines}%
+ \FV@ProcessLine{\box\spx@tempboxb}%
+ \global\let\FV@ProcessLine\FV@ProcessLine
+ \global\setbox\@tempboxa=\box\@tempboxa
+ }%
+ \unvbox\spx@tempboxa
+}%
+%
+% The normal line wrapping allows breaks at spaces and ascii non
+% letters, non digits. The \raggedright above means there will be
+% an overfilled line only if some non-breakable "word" was
+% encountered, which is longer than a line (it is moved always to
+% be on its own on a new line).
+%
+% The "forced" line wrapping will parse the tokens to add potential
+% breakpoints at each character. As some strings are highlighted,
+% we have to apply the highlighting character per character, which
+% requires to manipulate the output of the Pygments LaTeXFormatter.
+%
+% Doing this at latex level is complicated. The contents should
+% be as expected: i.e. some active characters from
+% \sphinxbreaksviaactive, some Pygments character escapes such as
+% \PYGZdl{}, and the highlighting \PYG macro with always 2
+% arguments. No other macros should be there, except perhaps
+% zero-parameter macros. In particular:
+% - the texcomments Pygments option must be set to False
+%
+% With pdflatex, Unicode input gives multi-bytes characters
+% where the first byte is active. We support the "utf8" macros
+% only. "utf8x" is not supported.
+%
+% The highlighting macro \PYG will be applied character per
+% character. Highlighting via a colored background gives thus a
+% chain of small colored boxes which may cause some artefact in
+% some pdf viewers. Can't do anything here if we do want the line
+% break to be possible.
+%
+% First a measurement step is done of what would the standard line
+% wrapping give (i.e line breaks only at spaces and non-letter,
+% non-digit ascii characters), cf TeX by Topic for the basic
+% dissecting technique: TeX unfortunately when building a vertical
+% box does not store in an accessible way what was the maximal
+% line-width during paragraph building.
+%
+% MEMO: in future use perhaps rather \RawNoindent/\RawParEnd, but
+% ltpara (LaTeX 2021-06-01) is not yet in final form (June 2022).
+%
+% Avoid LaTeX 2021 alteration of \@@par which potentially could break our
+% measurement step (typically if the para/after hook is configured to use
+% \vspace). Of course, breakage could happen only from user or package
+% adding things to basic Sphinx latex. And perhaps spring LaTeX 2021 will
+% provide a non-hooked \@@par, but this should work anyway and can't be
+% beaten for speed.
+\ltx@ifundefined{tex_par:D}
+% We could use \@ifl@t@r\fmtversion{2020/02/02}{use \tex_par:D}{use \@@par}.
+ {\let\spx@par\@@par}% \@@par is then expected to be TeX's original \par
+ {\expandafter\let\expandafter\spx@par\csname tex_par:D\endcsname}
+% More hesitation for avoiding the at-start-of-par hooks for our
+% measurement : 1. with old LaTeX, we can not avoid hooks from everyhook
+% or similar packages, 2. and perhaps the hooks add stuff which we should
+% actually measure. Ideally, hooks are for inserting things in margin
+% which do not change spacing. Most everything else in fact should not be
+% executed in our scratch box for measurement, such as counter stepping.
+\ltx@ifundefined{tex_everypar:D}
+ {\let\spx@everypar\everypar}
+ {\expandafter\let\expandafter\spx@everypar\csname tex_everypar:D\endcsname}
+%
+% If the max width exceeds the linewidth by more than verbatimmaxoverfull
+% character widths, or if the min width plus verbatimmaxunderfull character
+% widths is inferior to linewidth, then we apply the "force wrapping" with
+% potential line break at each character, else we don't.
+\long\def\spx@verb@DecideIfWillDoForceWrap{%
+ \global\let\spx@verb@maxwidth\z@
+ \global\let\spx@verb@minwidth\linewidth
+ \setbox\spx@tempboxa
+ \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
+ \doublehyphendemerits\z@\finalhyphendemerits\z@
+ \spx@everypar{}\noindent\strut\FV@Line\strut\spx@par
+ \spx@verb@getwidths}%
+ \ifdim\spx@verb@maxwidth>
+ \dimexpr\linewidth+\spx@opt@verbatimmaxoverfull\fontcharwd\font`X \relax
+% The \expandafter is due to \spx@verb@wrapPYG requiring to "see" the TeX tokens
+% from the pygmentize output.
+ \def\spx@verb@FV@Line{\expandafter\spx@verb@wrapPYG\FV@Line\spx@verb@wrapPYG}%
+ \else
+ \ifdim\spx@verb@minwidth<
+ \dimexpr\linewidth-\spx@opt@verbatimmaxunderfull\fontcharwd\font`X \relax
+ \def\spx@verb@FV@Line{\expandafter\spx@verb@wrapPYG\FV@Line\spx@verb@wrapPYG}%
+ \fi
+ \fi
+}%
+% auxiliary paragraph dissector to get max and min widths
+% but minwidth must not take into account the last line
+\def\spx@verb@getwidths {%
+ \unskip\unpenalty
+ \setbox\spx@tempboxb\lastbox
+ \ifvoid\spx@tempboxb
+ \else
+ \setbox\spx@tempboxb\hbox{\unhbox\spx@tempboxb}%
+ \ifdim\spx@verb@maxwidth<\wd\spx@tempboxb
+ \xdef\spx@verb@maxwidth{\number\wd\spx@tempboxb sp}%
+ \fi
+ \expandafter\spx@verb@getwidths@loop
+ \fi
+}%
+\def\spx@verb@getwidths@loop {%
+ \unskip\unpenalty
+ \setbox\spx@tempboxb\lastbox
+ \ifvoid\spx@tempboxb
+ \else
+ \setbox\spx@tempboxb\hbox{\unhbox\spx@tempboxb}%
+ \ifdim\spx@verb@maxwidth<\wd\spx@tempboxb
+ \xdef\spx@verb@maxwidth{\number\wd\spx@tempboxb sp}%
+ \fi
+ \ifdim\spx@verb@minwidth>\wd\spx@tempboxb
+ \xdef\spx@verb@minwidth{\number\wd\spx@tempboxb sp}%
+ \fi
+ \expandafter\spx@verb@getwidths@loop
+ \fi
+}%
+% auxiliary macros to implement "cut long line even in middle of word"
+\catcode`Z=3 % safe delimiter
+\def\spx@verb@wrapPYG{%
+ \futurelet\spx@nexttoken\spx@verb@wrapPYG@i
+}%
+\def\spx@verb@wrapPYG@i{%
+ \ifx\spx@nexttoken\spx@verb@wrapPYG\let\next=\@gobble\else
+ \ifx\spx@nexttoken\PYG\let\next=\spx@verb@wrapPYG@PYG@onebyone\else
+ \discretionary{}{\sphinxafterbreak}{}%
+ \let\next\spx@verb@wrapPYG@ii
+ \fi\fi
+ \next
+}%
+% Let's recognize active characters. We don't support utf8x only utf8.
+% And here #1 should not have picked up (non empty) braced contents
+\long\def\spx@verb@wrapPYG@ii#1{%
+ \ifcat\noexpand~\noexpand#1\relax% active character
+ \expandafter\spx@verb@wrapPYG@active
+ \else % non-active character, control sequence such as \PYGZdl, or empty
+ \expandafter\spx@verb@wrapPYG@one
+ \fi {#1}%
+}%
+\long\def\spx@verb@wrapPYG@active#1{%
+% Let's hope expansion of active character does not really require arguments,
+% as we certainly don't want to go into expanding upfront token stream anyway.
+ \expandafter\spx@verb@wrapPYG@iii#1{}{}{}{}{}{}{}{}{}Z#1%
+}%
+\long\def\spx@verb@wrapPYG@iii#1#2Z{%
+ \ifx\UTFviii@four@octets#1\let\next=\spx@verb@wrapPYG@four\else
+ \ifx\UTFviii@three@octets#1\let\next=\spx@verb@wrapPYG@three\else
+ \ifx\UTFviii@two@octets#1\let\next=\spx@verb@wrapPYG@two\else
+ \let\next=\spx@verb@wrapPYG@one
+ \fi\fi\fi
+ \next
+}%
+\long\def\spx@verb@wrapPYG@one #1{#1\futurelet\spx@nexttoken\spx@verb@wrapPYG@i}%
+\long\def\spx@verb@wrapPYG@two #1#2{#1#2\futurelet\spx@nexttoken\spx@verb@wrapPYG@i}%
+\long\def\spx@verb@wrapPYG@three #1#2#3{#1#2#3\futurelet\spx@nexttoken\spx@verb@wrapPYG@i}%
+\long\def\spx@verb@wrapPYG@four #1#2#3#4{#1#2#3#4\futurelet\spx@nexttoken\spx@verb@wrapPYG@i}%
+% Replace \PYG by itself applied one character at a time! This way breakpoints
+% can be inserted.
+\def\spx@verb@wrapPYG@PYG@onebyone#1#2#3{% #1 = \PYG, #2 = highlight spec, #3 = tokens
+ \def\spx@verb@wrapPYG@PYG@spec{{#2}}%
+ \futurelet\spx@nexttoken\spx@verb@wrapPYG@PYG@i#3Z%
+}%
+\def\spx@verb@wrapPYG@PYG@i{%
+ \ifx\spx@nexttokenZ\let\next=\spx@verb@wrapPYG@PYG@done\else
+ \discretionary{}{\sphinxafterbreak}{}%
+ \let\next\spx@verb@wrapPYG@PYG@ii
+ \fi
+ \next
+}%
+\def\spx@verb@wrapPYG@PYG@doneZ{\futurelet\spx@nexttoken\spx@verb@wrapPYG@i}%
+\long\def\spx@verb@wrapPYG@PYG@ii#1{%
+ \ifcat\noexpand~\noexpand#1\relax% active character
+ \expandafter\spx@verb@wrapPYG@PYG@active
+ \else % non-active character, control sequence such as \PYGZdl, or empty
+ \expandafter\spx@verb@wrapPYG@PYG@one
+ \fi {#1}%
+}%
+\long\def\spx@verb@wrapPYG@PYG@active#1{%
+% Let's hope expansion of active character does not really require arguments,
+% as we certainly don't want to go into expanding upfront token stream anyway.
+ \expandafter\spx@verb@wrapPYG@PYG@iii#1{}{}{}{}{}{}{}{}{}Z#1%
+}%
+\long\def\spx@verb@wrapPYG@PYG@iii#1#2Z{%
+ \ifx\UTFviii@four@octets#1\let\next=\spx@verb@wrapPYG@PYG@four\else
+ \ifx\UTFviii@three@octets#1\let\next=\spx@verb@wrapPYG@PYG@three\else
+ \ifx\UTFviii@two@octets#1\let\next=\spx@verb@wrapPYG@PYG@two\else
+ \let\next=\spx@verb@wrapPYG@PYG@one
+ \fi\fi\fi
+ \next
+}%
+\long\def\spx@verb@wrapPYG@PYG@one#1{%
+ \expandafter\PYG\spx@verb@wrapPYG@PYG@spec{#1}%
+ \futurelet\spx@nexttoken\spx@verb@wrapPYG@PYG@i
+}%
+\long\def\spx@verb@wrapPYG@PYG@two#1#2{%
+ \expandafter\PYG\spx@verb@wrapPYG@PYG@spec{#1#2}%
+ \futurelet\spx@nexttoken\spx@verb@wrapPYG@PYG@i
+}%
+\long\def\spx@verb@wrapPYG@PYG@three#1#2#3{%
+ \expandafter\PYG\spx@verb@wrapPYG@PYG@spec{#1#2#3}%
+ \futurelet\spx@nexttoken\spx@verb@wrapPYG@PYG@i
+}%
+\long\def\spx@verb@wrapPYG@PYG@four#1#2#3#4{%
+ \expandafter\PYG\spx@verb@wrapPYG@PYG@spec{#1#2#3#4}%
+ \futurelet\spx@nexttoken\spx@verb@wrapPYG@PYG@i
+}%
+\catcode`Z 11 %
+%
+\g@addto@macro\FV@SetupFont{%
+ \sbox\sphinxcontinuationbox {\spx@opt@verbatimcontinued}%
+ \sbox\sphinxvisiblespacebox {\spx@opt@verbatimvisiblespace}%
+}%
+\newenvironment{sphinxVerbatim}{%
+ % first, let's check if there is a caption
+ \ifx\sphinxVerbatimTitle\empty
+ \sphinxvspacefixafterfrenchlists
+ \parskip\z@skip
+ \vskip\sphinxverbatimsmallskipamount
+ % there was no caption. Check if nevertheless a label was set.
+ \ifx\sphinxLiteralBlockLabel\empty\else
+ % we require some space to be sure hyperlink target from \phantomsection
+ % will not be separated from upcoming verbatim by a page break
+ \needspace{\sphinxliteralblockwithoutcaptionneedspace}%
+ \phantomsection\sphinxLiteralBlockLabel
+ \fi
+ \else
+ \parskip\z@skip
+ \if t\spx@opt@literalblockcappos
+ \vskip\spx@abovecaptionskip
+ \def\sphinxVerbatim@Before
+ {\sphinxVerbatim@Title\nointerlineskip
+ \kern\dimexpr-\dp\strutbox+\sphinxbelowcaptionspace
+ % if no frame (code-blocks inside table cells), remove
+ % the top padding (better visually)
+ \ifspx@opt@verbatimwithframe\else
+ % but we must now check if there is a background color
+ % MEMO: "fcolorbox@setup" will have been done by time of use
+ \ifspx@boxes@withbackgroundcolor\else-\spx@boxes@padding@top\fi
+ \fi
+ % caption package adds \abovecaptionskip vspace, remove it
+ \spx@ifcaptionpackage{-\abovecaptionskip}{}\relax}%
+ \else
+ \vskip\sphinxverbatimsmallskipamount
+ \def\sphinxVerbatim@After
+ {\nointerlineskip\kern\dimexpr\dp\strutbox
+ \ifspx@opt@verbatimwithframe\else
+ % but we must now check if there is a background color
+ % MEMO: "fcolorbox@setup" will have been done by time of use
+ \ifspx@boxes@withbackgroundcolor\else-\spx@boxes@padding@bottom\fi
+ \fi
+ \spx@ifcaptionpackage{-\abovecaptionskip}{}\relax
+ \sphinxVerbatim@Title}%
+ \fi
+ \def\@captype{literalblock}%
+ \capstart
+ % \sphinxVerbatimTitle must reset color
+ \setbox\sphinxVerbatim@TitleBox
+ \hbox{\begin{minipage}{\linewidth}%
+ % caption package may detect wrongly if top or bottom, so we help it
+ \spx@ifcaptionpackage
+ {\caption@setposition{\spx@opt@literalblockcappos}}{}%
+ \sphinxVerbatimTitle
+ \end{minipage}}%
+ \fi
+ \global\let\sphinxLiteralBlockLabel\empty
+ \global\let\sphinxVerbatimTitle\empty
+ % the "FrameCommand"'s are also responsible to attach the "Title".
+ \let\FrameCommand \sphinxVerbatim@FrameCommand
+ % those will also check status of the pre_box-decoration-break option
+ \let\FirstFrameCommand\sphinxVerbatim@FirstFrameCommand
+ \let\MidFrameCommand \sphinxVerbatim@MidFrameCommand
+ \let\LastFrameCommand \sphinxVerbatim@LastFrameCommand
+ %
+ \ifspx@opt@verbatimhintsturnover\else
+ \let\sphinxVerbatim@Continued\@empty
+ \let\sphinxVerbatim@Continues\@empty
+ \fi
+ % initialization for \spx@boxes@fcolorbox from sphinxpackageboxes.sty
+ % it will take into account status of verbatimwithframe Boolean
+ \spx@verb@boxes@fcolorbox@setup
+ \ifspx@opt@verbatimwrapslines
+ % deep hack into fancyvrb's internal processing of input lines
+ \let\FV@@PreProcessLine\spx@verb@@PreProcessLine
+ % space character will allow line breaks
+ \let\FV@Space\spx@verbatim@space
+ % allow breaks at special characters using \PYG... macros.
+ \sphinxbreaksatspecials
+ % breaks at punctuation characters . , ; ? ! and / (needs catcode activation)
+ \fvset{codes*=\sphinxbreaksviaactive}%
+ \fi
+ \let\FancyVerbFormatLine\sphinxFancyVerbFormatLine
+ \VerbatimEnvironment
+ % workaround to fancyvrb's check of current list depth
+ \def\@toodeep {\advance\@listdepth\@ne}%
+ % The list environment is needed to control perfectly the vertical space.
+ % Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt.
+ % - if caption: distance from last text baseline to caption baseline is
+ % A+(B-F)+\ht\strutbox, A = \abovecaptionskip (default 10pt), B =
+ % \baselineskip, F is the framed.sty \FrameHeightAdjust macro, default 6pt.
+ % Formula valid for F < 10pt.
+ % - distance of baseline of caption to top of frame is like for tables:
+ % \sphinxbelowcaptionspace (=0.5\baselineskip)
+ % - if no caption: distance of last text baseline to code frame is S+(B-F),
+ % with S = \sphinxverbatimtopskip (=\smallskip)
+ % - and distance from bottom of frame to next text baseline is
+ % \baselineskip+\parskip.
+ % The \trivlist is used to avoid possible "too deeply nested" error.
+ \itemsep \z@skip
+ \topsep \z@skip
+ \partopsep \z@skip
+ % trivlist will set \parsep to \parskip (which itself is set to zero above)
+ % \leftmargin will be set to zero by trivlist
+ \rightmargin\z@
+ \parindent \z@% becomes \itemindent. Default zero, but perhaps overwritten.
+ \trivlist\item\relax
+ \ifspx@inframed\setbox\sphinxVerbatim@ContentsBox\vbox\bgroup
+ \@setminipage\hsize\linewidth
+ % use bulk of minipage paragraph shape restores (this is needed
+ % in indented contexts, at least for some)
+ \textwidth\hsize \columnwidth\hsize \@totalleftmargin\z@
+ \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
+ \else
+ \ifsphinxverbatimwithminipage\noindent\begin{minipage}{\linewidth}\fi
+ \MakeFramed {% adapted over from framed.sty's snugshade environment
+ \advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage
+ }%
+ \fi
+ % For grid placement from \strut's in \FancyVerbFormatLine
+ \lineskip\z@skip
+ % active comma should not be overwritten by \@noligs
+ \ifspx@opt@verbatimwrapslines
+ \let\verbatim@nolig@list \sphinx@verbatim@nolig@list
+ \fi
+ % optimization: as codelines will be handled inside boxes, \everypar is
+ % never reset, and it issues \@minipagefalse repeatedly (from \@setminipage).
+ % As fancyvrb Verbatim will do \@minipagefalse itself, let's simplify things.
+ \everypar{}%
+ \color@begingroup % protect against color leaks (upstream framed.sty bug)
+ \ifspx@pre@withtextcolor\color{VerbatimTextColor}\fi % mostly shadowed by
+ % Pygments highlighting anyhow
+ \spx@pre@TeXextras
+ % will fetch its optional arguments if any
+ \OriginalVerbatim
+}%
+{%
+ \endOriginalVerbatim
+ \color@endgroup % matches the \color@begingroup
+ \ifspx@inframed
+ \egroup % finish \sphinxVerbatim@ContentsBox vbox
+ \nobreak % update page totals
+%%%%
+% MEMO (2022/07/09, while preparing 5.1.0 LaTeX CSS-style sphinxsetup options)
+% This test will systematically cause to abandon framing if the code-block
+% is near bottom of a warning-type notice which TeX has not yet decided whether
+% it fits on current page and which is near bottom of page. Indeed the
+% \pagetotal will already be very near \pagegoal. This is probably a not
+% intended behaviour, and perhaps the whole thing should be removed? Indeed
+% the result is surprising then because the notice will be split, code-block
+% will be on page 2 and will have no background-color, no border.
+ \ifdim\dimexpr
+ \ht\sphinxVerbatim@ContentsBox+
+ \dp\sphinxVerbatim@ContentsBox+
+ \ht\sphinxVerbatim@TitleBox+
+ \dp\sphinxVerbatim@TitleBox+
+ % 6.2.0 uses here the dimen registers from sphinxpackageboxes.sty,
+ % they got setup by \spx@verb@boxes@fcolorbox@setup
+ \spx@boxes@padding@top+
+ \spx@boxes@padding@bottom+
+ \ifspx@opt@verbatimwithframe \spx@boxes@border@top+
+ \spx@boxes@border@bottom+\fi
+ % try to account for external frame parameters
+ % MEMO: this is because the sphinxheavybox (for warning admonitions)
+ % environment sets \FrameSep and \FrameRule
+ % TODO: fix this bad implicit dependency
+ \FrameSep+\FrameRule+
+ % Usage here of 2 baseline distances is empirical.
+ % In border case where code-block fits barely in remaining space,
+ % it gets framed and looks good but the outer frame may continue
+ % on top of next page and give (if no contents after code-block)
+ % an empty framed line, as testing showed.
+ 2\baselineskip+
+ % now add all to accumulated page totals and compare to \pagegoal
+ \pagetotal+\pagedepth>\pagegoal
+ % long contents: do not \MakeFramed. Do make a caption (either before or
+ % after) if title exists. Continuation hints across pagebreaks dropped.
+ % FIXME? a bottom caption may end up isolated at top of next page
+ % (no problem with a top caption, which is default)
+ \spx@opt@verbatimwithframefalse
+ \def\sphinxVerbatim@Title{\noindent\box\sphinxVerbatim@TitleBox\par}%
+ \sphinxVerbatim@Before
+ \noindent\unvbox\sphinxVerbatim@ContentsBox\par
+ \sphinxVerbatim@After
+ \else
+ % short enough contents: use \MakeFramed. As it is nested, this requires
+ % minipage encapsulation.
+ \noindent\begin{minipage}{\linewidth}%
+ \MakeFramed {% Use it now with the fetched contents
+ \advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage
+ }%
+ \unvbox\sphinxVerbatim@ContentsBox
+ % the \@minipagefalse is superfluous, actually.
+ \par\unskip\@minipagefalse\endMakeFramed
+ \end{minipage}%
+ \fi
+ \else % non-nested \MakeFramed
+ \par\unskip\@minipagefalse\endMakeFramed % from framed.sty snugshade
+ \ifsphinxverbatimwithminipage\end{minipage}\fi
+ \fi
+ \endtrivlist
+}
+\newenvironment {sphinxVerbatimNoFrame}
+ {\spx@opt@verbatimwithframefalse
+ \VerbatimEnvironment
+ \begin{sphinxVerbatim}}
+ {\end{sphinxVerbatim}}
+\newenvironment {sphinxVerbatimintable}
+ {% don't use a frame if in a table cell
+ \spx@opt@verbatimwithframefalse
+ \sphinxverbatimwithminipagetrue
+ % the literal block caption uses \sphinxcaption which is wrapper of \caption,
+ % but \caption must be modified because longtable redefines it to work only
+ % for the own table caption, and tabulary has multiple passes
+ \let\caption\sphinxfigcaption
+ % reduce above caption skip
+ \def\spx@abovecaptionskip{\sphinxverbatimsmallskipamount}%
+ \VerbatimEnvironment
+ \begin{sphinxVerbatim}}
+ {\end{sphinxVerbatim}}
+
+
+%% PARSED LITERALS
+% allow long lines to wrap like they do in code-blocks
+
+% this should be kept in sync with definitions in sphinx.util.texescape
+\newcommand*\sphinxbreaksattexescapedchars{%
+ \def\do##1##2% put potential break point before character
+ {\def##1{\discretionary{}{\sphinxafterbreak\char`##2}{\char`##2}}}%
+ \do\{\{\do\textless\<\do\#\#\do\%\%\do\$\$% {, <, #, %, $
+ \def\do##1##2% put potential break point after character
+ {\def##1{\discretionary{\char`##2}{\sphinxafterbreak}{\char`##2}}}%
+ \do\_\_\do\}\}\do\textasciicircum\^\do\&\&% _, }, ^, &,
+ \do\textgreater\>\do\textasciitilde\~% >, ~
+ \do\textbackslash\\% \
+}
+\newcommand*\sphinxbreaksviaactiveinparsedliteral{%
+ \sphinxbreaksviaactive % by default handles . , ; ? ! /
+ \lccode`\~`\~ %
+ % update \dospecials as it is used by \url
+ % but deactivation will already have been done hence this is unneeded:
+ % \expandafter\def\expandafter\dospecials\expandafter{\dospecials
+ % \sphinxbreaksbeforeactivelist\sphinxbreaksafteractivelist\do\-}%
+}
+\newcommand*\sphinxbreaksatspaceinparsedliteral{%
+ \lccode`~32 \lowercase{\let~}\spx@verbatim@space\lccode`\~`\~
+}
+\newcommand*{\sphinxunactivateextras}{\let\do\@makeother
+ \sphinxbreaksbeforeactivelist\sphinxbreaksafteractivelist}%
+% the \catcode13=5\relax (deactivate end of input lines) is left to callers
+\newcommand*{\sphinxunactivateextrasandspace}{\catcode32=10\relax
+ \sphinxunactivateextras}%
+% alltt uses a monospace font and linebreaks at dashes (which are escaped
+% to \sphinxhyphen{} which expands to -\kern\z@) are inhibited with pdflatex.
+% Not with xelatex (cf \defaultfontfeatures in latex writer), so:
+\newcommand*{\sphinxhypheninparsedliteral}{\sphinxhyphennobreak}
+% now for the modified alltt environment
+\newenvironment{sphinxalltt}
+{% at start of next line to workaround Emacs/AUCTeX issue with this file
+\begin{alltt}%
+ \ifspx@opt@parsedliteralwraps
+ \sbox\sphinxcontinuationbox {\spx@opt@verbatimcontinued}%
+ \sbox\sphinxvisiblespacebox {\spx@opt@verbatimvisiblespace}%
+ \let\sphinxhyphen\sphinxhypheninparsedliteral
+ \sphinxbreaksattexescapedchars
+ \sphinxbreaksviaactiveinparsedliteral
+ \sphinxbreaksatspaceinparsedliteral
+% alltt takes care of the ' as derivative ("prime") in math mode
+ \everymath\expandafter{\the\everymath\sphinxunactivateextrasandspace
+ \catcode`\<=12\catcode`\>=12\catcode`\^=7\catcode`\_=8 }%
+% not sure if displayed math (align,...) can end up in parsed-literal, anyway
+ \everydisplay\expandafter{\the\everydisplay
+ \catcode13=5 \sphinxunactivateextrasandspace
+ \catcode`\<=12\catcode`\>=12\catcode`\^=7\catcode`\_=8 }%
+ \fi }
+{\end{alltt}}
+
+
+%% INLINE MARK-UP
+%
+
+% Protect \href's first argument in contexts such as sphinxalltt (or
+% \sphinxcode). Sphinx uses \#, \%, \& ... always inside \sphinxhref.
+\protected\def\sphinxhref#1#2{{%
+ \sphinxunactivateextrasandspace % never do \scantokens with active space!
+% for the \endlinechar business, https://github.com/latex3/latex2e/issues/286
+ \endlinechar\m@ne\everyeof{{\endlinechar13 #2}}% keep catcode regime for #2
+ \scantokens{\href{#1}}% normalise it for #1 during \href expansion
+}}
+% Same for \url. And also \nolinkurl for coherence.
+\protected\def\sphinxurl#1{{%
+ \sphinxunactivateextrasandspace\everyeof{}% (<- precaution for \scantokens)
+ \endlinechar\m@ne\scantokens{\url{#1}}%
+}}
+\protected\def\sphinxnolinkurl#1{{%
+ \sphinxunactivateextrasandspace\everyeof{}%
+ \endlinechar\m@ne\scantokens{\nolinkurl{#1}}%
+}}
+
+% \sphinxupquote
+% to obtain straight quotes we execute \@noligs as patched by upquote, and
+% \scantokens is needed in cases where it would be too late for the macro to
+% first set catcodes and then fetch its argument. We also make the contents
+% breakable at non-escaped . , ; ? ! / using \sphinxbreaksviaactive,
+% and also at \ character (which is escaped to \textbackslash{}).
+\protected\def\sphinxtextbackslashbreakbefore
+ {\discretionary{}{\sphinxafterbreak\sphinx@textbackslash}{\sphinx@textbackslash}}
+\protected\def\sphinxtextbackslashbreakafter
+ {\discretionary{\sphinx@textbackslash}{\sphinxafterbreak}{\sphinx@textbackslash}}
+\let\sphinxtextbackslash\sphinxtextbackslashbreakafter
+% - is escaped to \sphinxhyphen{} and this default ensures no linebreak
+% behaviour (also with a non monospace font, or with xelatex)
+\newcommand*{\sphinxhyphenininlineliteral}{\sphinxhyphennobreak}
+% the macro must be protected if it ends up used in moving arguments,
+% in 'alltt' \@noligs is done already, and the \scantokens must be avoided.
+\protected\def\sphinxupquote#1{{\def\@tempa{alltt}%
+ \ifx\@tempa\@currenvir\else
+ \let\sphinxhyphen\sphinxhyphenininlineliteral
+ \ifspx@opt@inlineliteralwraps
+ % break at . , ; ? ! /
+ \sphinxbreaksviaactive
+ % break also at \
+ \setbox8=\hbox{\textbackslash}%
+ \def\sphinx@textbackslash{\copy8}%
+ \let\textbackslash\sphinxtextbackslash
+ % by default, no continuation symbol on next line but may be added
+ \let\sphinxafterbreak\sphinxafterbreakofinlineliteral
+ % do not overwrite the comma set-up
+ \let\verbatim@nolig@list\sphinx@literal@nolig@list
+ \fi
+ % fix a space-gobbling issue due to LaTeX's original \do@noligs
+% TODO: using \@noligs as patched by upquote.sty is now unneeded because
+% either ` and ' are escaped (non-unicode engines) or they don't build
+% ligatures (unicode engines). Thus remove this and unify handling of `, <, >,
+% ' and - with the characters . , ; ? ! / as handled via
+% \sphinxbreaksviaactive.
+% Hence \sphinx@do@noligs will be removed, or rather replaced with code
+% inserting discretionaries, as they allow a continuation symbol on start of
+% next line to achieve common design with code-blocks.
+% TODO: do the above TODO!
+% Extend \sphinxunactivateextras for \sphinxhref as the latter may
+% actually be in the scope of \sphinxupquote and does a \scantokens
+% of its own.
+ \expandafter\def\expandafter\sphinxunactivateextras\expandafter
+ {\sphinxunactivateextras\verbatim@nolig@list}%
+ \let\do@noligs\sphinx@do@noligs
+ \@noligs\endlinechar\m@ne\everyeof{}% (<- in case inside \sphinxhref)
+ \expandafter\scantokens
+ \fi {{#1}}}}% extra brace pair to fix end-space gobbling issue...
+\def\sphinx@do@noligs #1{\catcode`#1\active\begingroup\lccode`\~`#1\relax
+ \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1 }}}
+\def\sphinx@literal@nolig@list {\do\`\do\<\do\>\do\'\do\-}%
+\let\sphinxafterbreakofinlineliteral\empty
+
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexnumfig.sty b/sphinx/texinputs/sphinxlatexnumfig.sty
new file mode 100644
index 0000000..6d72961
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexnumfig.sty
@@ -0,0 +1,122 @@
+%% NUMBERING OF FIGURES, TABLES, AND LITERAL BLOCKS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexnumfig.sty}[2021/01/27 numbering]
+
+% Requires: remreset (old LaTeX only)
+% relates to numfig and numfig_secnum_depth configuration variables
+
+% LaTeX 2018-04-01 and later provides \@removefromreset
+\ltx@ifundefined{@removefromreset}
+ {\RequirePackage{remreset}}
+ {}% avoid warning
+% Everything is delayed to \begin{document} to allow hyperref patches into
+% \newcounter to solve duplicate label problems for internal hyperlinks to
+% code listings (literalblock counter). User or extension re-definitions of
+% \theliteralblock, et al., thus have also to be delayed. (changed at 3.5.0)
+\AtBeginDocument{%
+\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
+}% end of big \AtBeginDocument
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexobjects.sty b/sphinx/texinputs/sphinxlatexobjects.sty
new file mode 100644
index 0000000..5d9b69b
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexobjects.sty
@@ -0,0 +1,365 @@
+%% MODULE RELEASE DATA AND OBJECT DESCRIPTIONS
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexobjects.sty}[2023/07/23 documentation environments]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+%
+% - environments
+%
+% - fulllineitems
+% - productionlist
+% - optionlist
+% - DUlineblock (also "lineblock")
+%
+% - macros
+%
+% - \DUrole
+% - various legacy support macros related to author and release
+% data of documented objects and modules.
+
+% \moduleauthor{name}{email}
+\newcommand{\moduleauthor}[2]{}
+
+% \sectionauthor{name}{email}
+\newcommand{\sectionauthor}[2]{}
+
+% Allow the release number to be specified independently of the
+% \date{}. This allows the date to reflect the document's date and
+% release to specify the release that is documented.
+%
+\newcommand{\py@release}{\releasename\space\version}
+\newcommand{\version}{}% part of \py@release, used by title page and headers
+% \releaseinfo is used on titlepage (sphinxmanual.cls, sphinxhowto.cls)
+\newcommand{\releaseinfo}{}
+\newcommand{\setreleaseinfo}[1]{\renewcommand{\releaseinfo}{#1}}
+% this is inserted via template and #1=release config variable
+\newcommand{\release}[1]{\renewcommand{\version}{#1}}
+% this is defined by template to 'releasename' latex_elements key
+\newcommand{\releasename}{}
+% Fix issue in case release and releasename deliberately left blank
+\newcommand{\sphinxheadercomma}{, }% used in fancyhdr header definition
+\newcommand{\sphinxifemptyorblank}[1]{%
+% test after one expansion of macro #1 if contents is empty or spaces
+ \if&\expandafter\@firstofone\detokenize\expandafter{#1}&%
+ \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}%
+\AtBeginDocument {%
+ \sphinxifemptyorblank{\releasename}
+ {\sphinxifemptyorblank{\version}{\let\sphinxheadercomma\empty}{}}
+ {}%
+}%
+
+% Allow specification of the author's address separately from the
+% author's name. This can be used to format them differently, which
+% is a good thing.
+%
+\newcommand{\py@authoraddress}{}
+\newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
+
+% {fulllineitems} is the main environment for object descriptions.
+%
+% With 4.0.0 \pysigline (and \pysiglinewithargsret), used in a fulllineitems
+% environment the #1 will already be of the width which is computed here, i.e.
+% the available width on line, so the \makebox becomes a bit superfluous
+\newcommand{\py@itemnewline}[1]{% macro used as \makelabel in fulllineitems
+% Memo: this presupposes \itemindent is 0pt
+ \kern\labelsep % because \@labels core latex box does \hskip-\labelsep
+ \makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}%
+ \kern-\labelsep % because at end of \@labels box there is \hskip\labelsep
+}
+
+\newenvironment{fulllineitems}{%
+ \begin{list}{}{\labelwidth \leftmargin
+ \rightmargin \z@ \topsep -\parskip \partopsep \parskip
+ \itemsep -\parsep
+ \let\makelabel=\py@itemnewline}%
+}{\end{list}}
+
+% Signatures, possibly multi-line
+%
+% For legacy reasons Sphinx uses LaTeX \list and \item's for signatures
+% This is delicate:
+% - the actual item label is not typeset immediately by \item but later as part
+% of the \everypar which will be triggered by either next paragraph or a manual
+% \leavevmode, or if nothing in-between by the next \item,
+% - \begingroup <set-up>\item[foo] <setup>\endgroup leads to errors,
+% - vertical space depends on \parskip and \itemsep values in somewhat
+% subtle manners.
+%
+% Since the 2022/01/13 version things are simpler as \parskip is simply set
+% to zero during execution of \pysigline/\pysiglinewithargsret
+%
+% Parameter for separation via \itemsep of multiple signatures with common desc
+\newlength\sphinxsignaturesep
+\setlength\sphinxsignaturesep{\smallskipamount}
+% latex.py outputs mark-up like this:
+% \pysigstartsignatures <signatures> \pysigstopsignatures <actual desc>
+\newcommand{\pysigstartsignatures}{%
+ % store current \parskip and \itemsep
+ \edef\pysig@restore@itemsep@and@parskip{%
+ \itemsep\the\itemsep\relax
+ \parskip\the\parskip\relax
+ }%
+ % set them to control the spacing between signatures sharing common desc
+ \parskip\z@skip
+ \itemsep\sphinxsignaturesep
+}
+\newcommand{\pysigstopsignatures}{%
+% 1) encourage a pagebreak in an attempt to try to avoid last
+% signature ending up separated from description (due to voodoo next)
+\penalty-100
+% 2) some voodoo to separate last signature from description in a manner
+% robust with respect to the latter being itself a LaTeX list object
+\leavevmode\par\kern-\baselineskip\item[\strut]
+%
+ \leavevmode
+ % it is important \leavevmode was issued before the \parskip reset, and
+ % it is also needed for the case of an object desc itself a LaTeX \list
+ % now restore \itemsep and \parskip
+ \pysig@restore@itemsep@and@parskip
+}
+% Each signature is rendered as NAME<SPACE>[TPLIST]<SPACE>(ARGLIST) where the
+% size of <SPACE> is parametrized by \sphinxsignaturelistskip (0pt by default).
+\newlength\sphinxsignaturelistskip
+\setlength\sphinxsignaturelistskip{0pt}
+\newcommand{\pysigtypelistopen}{\hskip\sphinxsignaturelistskip\sphinxcode{[}}
+\newcommand{\pysigtypelistclose}{\sphinxcode{]}}
+\newcommand{\pysigarglistopen}{\hskip\sphinxsignaturelistskip\sphinxcode{(}}
+\newcommand{\pysigarglistclose}{\sphinxcode{)}}
+%
+% Use a \parbox to accommodate long argument list in signatures
+% LaTeX did not imagine that an \item label could need multi-line rendering
+\newlength{\py@argswidth}
+\newcommand{\py@sigparams}[2]{%
+ % The \py@argswidth has been computed in \pysiglinewithargsret to make the
+ % argument list use full available width
+ \parbox[t]{\py@argswidth}{\raggedright #1\pysigarglistclose#2\strut}%
+ % final strut is to help get correct vertical separation
+}
+\newcommand{\py@sigparamswithtypelist}[3]{%
+ % similar to \py@sigparams but with different delimiters and an additional
+ % type parameters list given as #1, the argument list as #2 and the return
+ % annotation as #3
+ \parbox[t]{\py@argswidth}{%
+ \raggedright #1\pysigtypelistclose%
+ \pysigarglistopen#2\pysigarglistclose%
+ #3\strut}%
+}
+
+\newcommand{\pysigline}[1]{%
+ % as \py@argswidth is available, we use it but no "args" here
+ % the \relax\relax is because \py@argswidth is a "skip" variable
+ % this will make the label occupy the full available linewidth
+ \py@argswidth=\dimexpr\linewidth+\labelwidth\relax\relax
+ \item[{\parbox[t]{\py@argswidth}{\raggedright #1\strut}}]
+ \pysigadjustitemsep
+}
+\newcommand{\pysiglinewithargsret}[3]{%
+ % as #1 may contain a footnote using \label we need to make \label
+ % a no-op here to avoid LaTeX complaining about duplicates
+\let\spx@label\label\let\label\@gobble
+ \settowidth{\py@argswidth}{#1\pysigarglistopen}%
+\let\label\spx@label
+ \py@argswidth=\dimexpr\linewidth+\labelwidth-\py@argswidth\relax\relax
+ \item[{#1\pysigarglistopen\py@sigparams{#2}{#3}\strut}]
+ \pysigadjustitemsep
+}
+\newcommand{\pysiglinewithargsretwithtypelist}[4]{
+% #1 = name, #2 = typelist, #3 = arglist, #4 = retann
+\let\spx@label\label\let\label\@gobble
+ \settowidth{\py@argswidth}{#1\pysigtypelistopen}%
+\let\label\spx@label
+ \py@argswidth=\dimexpr\linewidth+\labelwidth-\py@argswidth\relax\relax
+ \item[{#1\pysigtypelistopen\py@sigparamswithtypelist{#2}{#3}{#4}\strut}]
+ \pysigadjustitemsep
+}
+
+\def\sphinxoptionalextraspace{0.5mm}
+\newcommand{\pysigwithonelineperarg}[3]{%
+ % render each argument on its own line
+ \item[#1\pysigarglistopen\strut]
+ \leavevmode\par\nopagebreak
+ % this relies on \pysigstartsignatures having set \parskip to zero
+ \begingroup
+ \let\sphinxparamcomma\sphinxparamcommaoneperline
+ \def\sphinxoptionalhook{\ifvmode\else\kern\sphinxoptionalextraspace\relax\fi}%
+ % The very first \sphinxparam should not emit a \par hence a complication
+ % with a group and global definition here as it may occur in a \sphinxoptional
+ \global\let\spx@sphinxparam\sphinxparam
+ \gdef\sphinxparam{\gdef\sphinxparam{\par\spx@sphinxparam}\spx@sphinxparam}%
+ #2\par
+ \endgroup
+ \global\let\sphinxparam\spx@sphinxparam
+ % fulllineitems sets \labelwidth to be like \leftmargin
+ \nopagebreak\noindent\kern-\labelwidth\pysigarglistclose{#3}
+ \pysigadjustitemsep
+}
+\newcommand{\pysigwithonelineperargwithonelinepertparg}[4]{
+ % #1 = name, #2 = typelist, #3 = arglist, #4 = retann
+ % render each type parameter and argument on its own line
+ \item[#1\pysigtypelistopen\strut]
+ \leavevmode\par\nopagebreak
+ \begingroup
+ \let\sphinxparamcomma\sphinxparamcommaoneperline
+ % \sphinxtypeparam is treated similarly to \sphinxparam but since
+ % \sphinxoptional is not accepted in a type parameters list, we do
+ % not need the hook or the global definition
+ \let\spx@sphinxtypeparam\sphinxtypeparam
+ \def\sphinxtypeparam{\def\sphinxtypeparam{\par\spx@sphinxtypeparam}\spx@sphinxtypeparam}%
+ #2\par
+ \endgroup
+ \nopagebreak\noindent\kern-\labelwidth\pysigtypelistclose%
+ % render the rest of the signature like in \pysigwithonelineperarg
+ \pysigarglistopen\strut\par\nopagebreak
+ \begingroup
+ \let\sphinxparamcomma\sphinxparamcommaoneperline
+ \def\sphinxoptionalhook{\ifvmode\else\kern\sphinxoptionalextraspace\relax\fi}%
+ \global\let\spx@sphinxparam\sphinxparam
+ \gdef\sphinxparam{\gdef\sphinxparam{\par\spx@sphinxparam}\spx@sphinxparam}%
+ #3\par
+ \endgroup
+ \global\let\sphinxparam\spx@sphinxparam
+ \nopagebreak\noindent\kern-\labelwidth\pysigarglistclose{#4}
+ \pysigadjustitemsep
+}
+\newcommand{\pysiglinewithargsretwithonelinepertparg}[4]{
+ % #1 = name, #2 = typelist, #3 = arglist, #4 = retann
+ % render each type parameter on its own line but the arguments list inline
+ \item[#1\pysigtypelistopen\strut]
+ \leavevmode\par\nopagebreak
+ \begingroup
+ \let\sphinxparamcomma\sphinxparamcommaoneperline
+ % \sphinxtypeparam is treated similarly to \sphinxparam but since
+ % \sphinxoptional is not accepted in a type parameters list, we do
+ % not need the hook or the global definition
+ \let\spx@sphinxtypeparam\sphinxtypeparam
+ \def\sphinxtypeparam{\def\sphinxtypeparam{\par\spx@sphinxtypeparam}\spx@sphinxtypeparam}%
+ #2\par
+ \endgroup
+ \nopagebreak\noindent\kern-\labelwidth\pysigtypelistclose%
+ % render the arguments list on one line
+ \pysigarglistopen#3\pysigarglistclose#4\strut
+ \pysigadjustitemsep
+}
+\newcommand{\pysigwithonelineperargwithtypelist}[4]{
+ % #1 = name, #2 = typelist, #3 = arglist, #4 = retann
+ % render the type parameters list on one line, but each argument is rendered on its own line
+\let\spx@label\label\let\label\@gobble
+ \settowidth{\py@argswidth}{#1\pysigtypelistopen}%
+\let\label\spx@label
+ \py@argswidth=\dimexpr\linewidth+\labelwidth-\py@argswidth\relax\relax
+ \item[{#1\pysigtypelistopen\parbox[t]{\py@argswidth}{%
+ \raggedright #2\pysigtypelistclose\pysigarglistopen\strut}\strut}]
+ % render the rest of the signature like in \pysigwithonelineperarg
+ \begingroup
+ \let\sphinxparamcomma\sphinxparamcommaoneperline
+ \def\sphinxoptionalhook{\ifvmode\else\kern\sphinxoptionalextraspace\relax\fi}%
+ \global\let\spx@sphinxparam\sphinxparam
+ \gdef\sphinxparam{\gdef\sphinxparam{\par\spx@sphinxparam}\spx@sphinxparam}%
+ #3\par
+ \endgroup
+ \global\let\sphinxparam\spx@sphinxparam
+ \nopagebreak\noindent\kern-\labelwidth\pysigarglistclose{#4}
+ \pysigadjustitemsep
+}
+\newcommand{\pysigadjustitemsep}{%
+ % adjust \itemsep to control the separation with the next signature
+ % sharing common description
+ \ifsphinxsigismultiline
+ % inside a multiline signature, no extra vertical spacing
+ % ("multiline" here does not refer to possibly long
+ % list of arguments, but to a cpp domain feature)
+ \itemsep\z@skip
+ \else
+ \itemsep\sphinxsignaturesep
+ \fi
+}
+\newif\ifsphinxsigismultiline
+\newcommand{\pysigstartmultiline}{\sphinxsigismultilinetrue}%
+\newcommand{\pysigstopmultiline}{\sphinxsigismultilinefalse\itemsep\sphinxsignaturesep}%
+
+% Production lists
+%
+\newenvironment{productionlist}{%
+% \def\sphinxoptional##1{{\Large[}##1{\Large]}}
+ \def\production##1##2{\\\sphinxcode{\sphinxupquote{##1}}&::=&\sphinxcode{\sphinxupquote{##2}}}%
+ \def\productioncont##1{\\& &\sphinxcode{\sphinxupquote{##1}}}%
+ \parindent=2em
+ \indent
+ \setlength{\LTpre}{0pt}%
+ \setlength{\LTpost}{0pt}%
+ \begin{longtable}[l]{lcl}
+}{%
+ \end{longtable}
+}
+
+% Definition lists; requested by AMK for HOWTO documents. Probably useful
+% elsewhere as well, so keep in in the general style support.
+%
+\newenvironment{definitions}{%
+ \begin{description}%
+ \def\term##1{\item[{##1}]\mbox{}\\*[0mm]}%
+}{%
+ \end{description}%
+}
+
+%% FROM DOCTUTILS LATEX WRITER
+%
+% The following is stuff copied from docutils' latex writer.
+%
+\newcommand{\optionlistlabel}[1]{\normalfont\bfseries #1 \hfill}% \bf deprecated
+\newenvironment{optionlist}[1]
+{\begin{list}{}
+ {\setlength{\labelwidth}{#1}%
+ \setlength{\rightmargin}{1cm}%
+ \setlength{\leftmargin}{\rightmargin}%
+ \addtolength{\leftmargin}{\labelwidth}%
+ \addtolength{\leftmargin}{\labelsep}%
+ \renewcommand{\makelabel}{\optionlistlabel}}%
+}{\end{list}}
+
+\newlength{\lineblockindentation}
+\setlength{\lineblockindentation}{2.5em}
+\newenvironment{lineblock}[1]
+{\begin{list}{}
+ {\setlength{\partopsep}{\parskip}%
+ \addtolength{\partopsep}{\baselineskip}%
+ \topsep0pt\itemsep0.15\baselineskip\parsep0pt
+ \leftmargin#1\relax}%
+ \raggedright}
+{\end{list}}
+
+% From docutils.writers.latex2e
+% inline markup (custom roles)
+% \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ \ifcsname DUrole\detokenize{#1}\endcsname
+ \csname DUrole\detokenize{#1}\endcsname{#2}%
+ \else% backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole\detokenize{#1}\endcsname
+ \csname docutilsrole\detokenize{#1}\endcsname{#2}%
+ \else
+ #2%
+ \fi
+ \fi
+}
+
+\providecommand*{\DUprovidelength}[2]{%
+ \ifdefined#1\else\newlength{#1}\setlength{#1}{#2}\fi
+}
+
+\DUprovidelength{\DUlineblockindent}{2.5em}
+\ifdefined\DUlineblock\else
+ \newenvironment{DUlineblock}[1]{%
+ \list{}{\setlength{\partopsep}{\parskip}%
+ \addtolength{\partopsep}{\baselineskip}%
+ \setlength{\topsep}{0pt}%
+ \setlength{\itemsep}{0.15\baselineskip}%
+ \setlength{\parsep}{0pt}%
+ \setlength{\leftmargin}{#1}}%
+ \raggedright
+ }
+ {\endlist}
+\fi
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexshadowbox.sty b/sphinx/texinputs/sphinxlatexshadowbox.sty
new file mode 100644
index 0000000..a2a1a0e
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexshadowbox.sty
@@ -0,0 +1,116 @@
+%% TOPIC AND CONTENTS BOXES
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexshadowbox.sty}[2023/03/19 sphinxShadowBox]
+
+% Provides support for this output mark-up from Sphinx latex writer:
+%
+% - sphinxShadowBox (environment)
+%
+% Dependencies (they do not need to be defined at time of loading):
+%
+% - of course the various colour and dimension options handled via sphinx.sty
+% - dimension register \spx@image@maxheight from sphinxlatexgraphics.sty
+% - \savenotes/\spewnotes from sphinxpackagefootnote
+% - \ifspx@inframed defined in sphinx.sty
+%
+% Requires:
+\RequirePackage{framed}
+\RequirePackage{sphinxpackageboxes}
+
+% At 5.1.0 the code formerly here in a definition of \spx@ShadowFBox has been
+% refactored to hand over to a more powerful \spx@boxes@fcolorbox provided by
+% file sphinxpackageboxes.sty, it can draw rounded corners and add a background
+% color.
+
+% At 6.2.0, \spx@ShadowFBox is so much simplified that it is now not
+% separately defined but directly incorporated into the \FrameCommand
+% definition done by sphinxShadowBox environment below.
+
+% Use framed.sty \MakeFramed/\endMakeFramed to allow page breaks for topic
+% boxes. Originally Sphinx used \shadowbox from fancybox.sty but it did not
+% allow pagebreaks (which was problematic for "contents" directive if there
+% are many subsections).
+%
+% Docutils does not allow topic to be nested within topics or other body
+% elements. But the LaTeX code here does allow it:
+%
+% - a topic inside another topic would be rendered in a minipage (thus not
+% allowing pagebreaks). Its external frame would adapt perfectly to
+% the *current (smaller) width for text*.
+%
+% - a topic inside (nested) lists or quote environments would have its frame
+% take the *full width* of the page, but its text contents on the other hand
+% would obey exactly the current indentation plus inner separation. This is
+% in contrast with the framing used for literal blocks, also based, but in a
+% more sophisticated way on usage of \MakeFramed/\endMakeFramed, and
+% adjusting to current text indentation.
+\newenvironment{sphinxShadowBox}
+ {%
+ \spx@boxes@fcolorbox@setup{topic}%
+ % we will use the dimen registers from sphinxpackageboxes.sty which now hold
+ % the values from options related to topic/contents
+ % MEMO: \spx@boxes@fcolorbox creates an \hbox but does not quit vertical
+ % mode; but in context of framed.sty's \FrameCommand TeX is already
+ % in restricted horizontal mode, so no need for a \leavevmode here.
+ \def\FrameCommand {\spx@boxes@fcolorbox}%
+ % 6.2.0 adds support for div.topic_box-decoration-break=slice.
+ % (it is yet undecided if slice style should inhibit a bottom shadow)
+ \ifspx@topic@border@open
+ \def\FirstFrameCommand
+ {\spx@boxes@fcolorbox@setup@openbottom\FrameCommand}%
+ \def\MidFrameCommand
+ {\spx@boxes@fcolorbox@setup@openboth \FrameCommand}%
+ \def\LastFrameCommand
+ {\spx@boxes@fcolorbox@setup@opentop \FrameCommand}%
+ \fi
+ \advance\spx@image@maxheight
+ -\dimexpr\spx@boxes@border@top+\spx@boxes@border@bottom
+ +\spx@boxes@padding@top+\spx@boxes@padding@bottom
+ +\ifdim\spx@boxes@shadow@yoffset<\z@-\fi\spx@boxes@shadow@yoffset
+ +\baselineskip\relax
+ % configure framed.sty not to add extra vertical spacing
+ \ltx@ifundefined{OuterFrameSep}{}{\OuterFrameSep\z@skip}%
+ % the \trivlist will add the vertical spacing on top and bottom which is
+ % typical of center environment as used in Sphinx <= 1.4.1
+ % the \noindent has the effet of an extra blank line on top, to
+ % imitate closely the layout from Sphinx <= 1.4.1; the \FrameHeightAdjust
+ % will put top part of frame on this baseline.
+ \def\FrameHeightAdjust {\baselineskip}%
+ % use package footnote to handle footnotes
+ \savenotes
+ \trivlist\item\noindent
+ % use a minipage if we are already inside a framed environment
+ \ifspx@inframed\begin{minipage}{\linewidth}\fi
+ \MakeFramed {\spx@inframedtrue
+ % framed.sty puts into "\width" the added width (padding+border widths)
+ % adjust \hsize to what the contents must use
+ \advance\hsize-\width
+ % adjust LaTeX parameters to behave properly in indented/quoted contexts
+ \FrameRestore
+ % typeset the contents as in a minipage (Sphinx <= 1.4.1 used a minipage and
+ % itemize/enumerate are therein typeset more tightly, we want to keep
+ % that). We copy-paste from LaTeX source code but don't do a real minipage.
+ \@pboxswfalse
+ \let\@listdepth\@mplistdepth \@mplistdepth\z@
+ \@minipagerestore
+ \@setminipage
+ }%
+ \color@begingroup % workaround upstream framed.sty bug
+ \ifspx@topic@withtextcolor
+ \color{sphinxtopicTextColor}%
+ \fi
+ \spx@topic@TeXextras
+ }%
+ {% insert the "endminipage" code
+ \par\unskip
+ \color@endgroup % matches the \color@begingroup
+ \@minipagefalse
+ \endMakeFramed
+ \ifspx@inframed\end{minipage}\fi
+ \endtrivlist
+ % output the stored footnotes
+ \spewnotes
+ }
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexstyleheadings.sty b/sphinx/texinputs/sphinxlatexstyleheadings.sty
new file mode 100644
index 0000000..b5e9c85
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexstyleheadings.sty
@@ -0,0 +1,86 @@
+%% TITLES
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexstyleheadings.sty}[2023/02/11 headings]
+
+\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! ...........................|}}%
+ \sphinxbuildwarning{badtitlesec}%
+ \fi
+ }%
+ }{}
+
+% 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}
+\titleformat{\subsection}{\large\py@HeaderFamily}%
+ {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}
+% \normalsize added as work-around to a lualatex-ja upstream problem
+% https://osdn.net/projects/luatex-ja/ticket/47321
+\titleformat{\subsubsection}{\normalsize\py@HeaderFamily}%
+ {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}
+% By default paragraphs (and subsubsections) will not be numbered because
+% sphinxmanual.cls and sphinxhowto.cls set secnumdepth to 2
+\titleformat{\paragraph}{\normalsize\py@HeaderFamily}%
+ {\py@TitleColor\theparagraph}{0.5em}{\py@TitleColor}
+\titleformat{\subparagraph}{\normalsize\py@HeaderFamily}%
+ {\py@TitleColor\thesubparagraph}{0.5em}{\py@TitleColor}
+
+
+% 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
+
+% fix fncychap's bug which uses prematurely the \textwidth value
+\@ifpackagewith{fncychap}{Bjornstrup}
+ {\AtBeginDocument{\mylen\textwidth\advance\mylen-2\myhi}}%
+ {}% <-- "false" clause of \@ifpackagewith
+
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexstylepage.sty b/sphinx/texinputs/sphinxlatexstylepage.sty
new file mode 100644
index 0000000..4066129
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexstylepage.sty
@@ -0,0 +1,79 @@
+%% PAGE STYLING
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexstylepage.sty}[2021/01/27 page styling]
+
+% 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}}
+
+% Style parameters and macros used by most documents here
+\raggedbottom
+\sloppy
+\hbadness = 5000 % don't print trivial gripes
+
+% Require package fancyhdr except under memoir class
+\@ifclassloaded{memoir}{}{\RequirePackage{fancyhdr}}
+% 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{}
+ \fancyfoot[RO]{{\py@HeaderFamily\thepage}}
+ \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
+ \fancyhead[RO]{{\py@HeaderFamily \@title\sphinxheadercomma\py@release}}
+ \if@twoside
+ \fancyfoot[LE]{{\py@HeaderFamily\thepage}}
+ \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
+ \fancyhead[LE]{{\py@HeaderFamily \@title\sphinxheadercomma\py@release}}
+ \fi
+ \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[RO]{{\py@HeaderFamily\thepage}}
+ \if@twoside\fancyfoot[LE]{{\py@HeaderFamily\thepage}}\fi
+ \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
+ }
+
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatexstyletext.sty b/sphinx/texinputs/sphinxlatexstyletext.sty
new file mode 100644
index 0000000..d900090
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatexstyletext.sty
@@ -0,0 +1,181 @@
+%% TEXT STYLING
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatexstyletext.sty}[2023/07/23 text styling]
+
+% Basically everything here consists of macros which are part of the latex
+% markup produced by the Sphinx latex writer
+
+% But those arise rather from the default definitions of the respective
+% latex environments done in sphinxlatexadmonitions.sty
+\def\sphinxstylenotetitle #1{\sphinxstrong{#1} }
+\let\sphinxstylehinttitle \sphinxstylenotetitle % #1 holds the localized notice name
+\let\sphinxstyleimportanttitle\sphinxstylenotetitle % followed by a colon
+\let\sphinxstyletiptitle \sphinxstylenotetitle
+\let\sphinxstylewarningtitle \sphinxstylenotetitle
+\let\sphinxstylecautiontitle \sphinxstylenotetitle
+\let\sphinxstyleattentiontitle\sphinxstylenotetitle
+\let\sphinxstyledangertitle \sphinxstylenotetitle
+\let\sphinxstyleerrortitle \sphinxstylenotetitle
+\def\sphinxstyleseealsotitle#1{\sphinxstrong{#1}\par\nopagebreak}
+%
+% A utility to remove a final colon. Removing last token is not easy in
+% LaTeX, and there are additional complications:
+% - some languages will make the : "active" in document body,
+% - the generic admonition ends up using "note", so for \sphinxnotetitle to
+% use it safely, the utility has to allow an input not having any final colon.
+% - a bit far-fetched but maybe there is more than one colon inside the input
+% (possible from a generic admonition title).
+% Hence the scary code.
+\def\sphinxremovefinalcolon#1{% #1 is the "active" : TeX token
+\protected\def\sphinxremovefinalcolon ##1{%
+ % complications due to : possibly "active"
+ \begingroup\ifnum\catcode`:=\active
+ \def\x####1#1\relax{####1}%
+ \else\def\x####1:\relax{####1}\fi
+ \expandafter\endgroup\x##1\relax
+ % trick to let \x work also if input ##1 has no ending colon
+ \@gobblefour#1\relax:\relax\relax\relax
+ }%
+}% end of wrapper to inject active :
+\begingroup\catcode`:\active\expandafter\endgroup\sphinxremovefinalcolon:
+% See doc/latex.rst for an example.
+
+% Some custom font markup commands.
+\protected\def\sphinxstrong#1{\textbf{#1}}
+\protected\def\sphinxcode#1{\texttt{#1}}
+\protected\def\sphinxbfcode#1{\textbf{\sphinxcode{#1}}}
+\protected\def\sphinxemail#1{\textsf{#1}}
+\protected\def\sphinxtablecontinued#1{\textsf{#1}}
+\protected\def\sphinxtitleref#1{\emph{#1}}
+\protected\def\sphinxmenuselection#1{\emph{#1}}
+\protected\def\sphinxguilabel#1{\emph{#1}}
+\protected\def\sphinxkeyboard#1{\sphinxcode{#1}}
+\protected\def\sphinxaccelerator#1{\underline{#1}}
+\protected\def\sphinxcrossref#1{\emph{#1}}
+\protected\def\sphinxtermref#1{\emph{#1}}
+\protected\def\sphinxsamedocref#1{\emph{#1}}
+\protected\def\sphinxparam#1{\emph{#1}}
+\protected\def\sphinxtypeparam#1{\emph{#1}}
+% \optional is used for ``[, arg]``, i.e. desc_optional nodes.
+\long\protected\def\sphinxoptional#1{%
+ {\sphinxoptionalhook\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
+\let\sphinxoptionalhook\empty
+
+% additional customizable styling
+\def\sphinxstyleindexentry #1{\texttt{#1}}
+\def\sphinxstyleindexextra #1{ (\emph{#1})}
+\def\sphinxstyleindexpageref #1{, \pageref{#1}}
+\def\sphinxstyleindexpagemain#1{\textbf{#1}}
+\def\spxentry{\@backslashchar spxentry}% let to \sphinxstyleindexentry in index
+\def\spxextra{\@backslashchar spxextra}% let to \sphinxstyleindexextra in index
+\def\sphinxstyleindexlettergroup #1%
+ {{\Large\sffamily#1}\nopagebreak\vspace{1mm}}
+\def\sphinxstyleindexlettergroupDefault #1%
+ {{\Large\sffamily\sphinxnonalphabeticalgroupname}\nopagebreak\vspace{1mm}}
+\protected\def\sphinxstyletopictitle #1{\textbf{#1}\par\medskip}
+\let\sphinxstylesidebartitle\sphinxstyletopictitle
+\protected\def\sphinxstyleothertitle #1{\textbf{#1}}
+\protected\def\sphinxstylesidebarsubtitle #1{~\\\textbf{#1} \smallskip}
+% \text.. commands do not allow multiple paragraphs
+% attention, this one is not self-delimiting
+\protected\def\sphinxstyletheadfamily {\sffamily}
+\protected\def\sphinxstyleemphasis #1{\emph{#1}}
+\protected\def\sphinxstyleliteralemphasis#1{\emph{\sphinxcode{#1}}}
+\protected\def\sphinxstylestrong #1{\textbf{#1}}
+\protected\def\sphinxstyleliteralstrong#1{\sphinxbfcode{#1}}
+\protected\def\sphinxstyleabbreviation #1{\textsc{#1}}
+\protected\def\sphinxstyleliteralintitle#1{\sphinxcode{#1}}
+\newcommand*\sphinxstylecodecontinued[1]{{\footnotesize(#1)}}%
+\newcommand*\sphinxstylecodecontinues[1]{{\footnotesize(#1)}}%
+% figure legend comes after caption and may contain arbitrary body elements
+\newenvironment{sphinxlegend}{\par\small}{\par}
+% reduce hyperref "Token not allowed in a PDF string" warnings on PDF builds
+\AtBeginDocument{\pdfstringdefDisableCommands{%
+% all "protected" macros possibly ending up in section titles should be here
+% TODO: examine if \sphinxhref, \sphinxurl, \sphinnolinkurl should be handled
+ \let\sphinxstyleemphasis \@firstofone
+ \let\sphinxstyleliteralemphasis \@firstofone
+ \let\sphinxstylestrong \@firstofone
+ \let\sphinxstyleliteralstrong \@firstofone
+ \let\sphinxstyleabbreviation \@firstofone
+ \let\sphinxstyleliteralintitle \@firstofone
+ \let\sphinxupquote \@firstofone
+ \let\sphinxstrong \@firstofone
+ \let\sphinxcode \@firstofone
+ \let\sphinxbfcode \@firstofone
+ \let\sphinxemail \@firstofone
+ \let\sphinxcrossref \@firstofone
+ \let\sphinxtermref \@firstofone
+ \let\sphinxsamedocref\@firstofone
+ \let\sphinxhyphen\sphinxhyphenforbookmarks
+ \def\PYG#1#2{#2}% (can not yet appear in section titles, but perhaps in future)
+}}
+
+% Special characters
+%
+\def\sphinxparamcomma{, }% by default separate parameters with comma + space
+% If the signature is rendered with one line per param, this wil be used
+% instead (this \texttt makes the comma slightly more distinctive).
+\def\sphinxparamcommaoneperline{\texttt{,}}
+%
+% The \kern\z@ is to prevent en-dash and em-dash TeX ligatures.
+% A linebreak can occur after the dash in regular text (this is
+% normal behaviour of "-" in TeX, it is not related to \kern\z@).
+%
+% Parsed-literals and inline literals also use the \sphinxhyphen
+% but linebreaks there are prevented due to monospace font family.
+% (xelatex needs a special addition, cf. sphinxlatexliterals.sty)
+%
+% Inside code-blocks, dashes are escaped via another macro, from
+% Pygments latex output (search for \PYGZhy in sphinxlatexliterals.sty),
+% and are configured to allow linebreaks despite the monospace font.
+% (the #1 swallows the {} from \sphinxhyphen{} mark-up)
+\protected\def\sphinxhyphen#1{-\kern\z@}
+\protected\def\sphinxhyphennobreak#1{\mbox{-}}
+% The {} from texescape mark-up is kept, else -- gives en-dash in PDF bookmark
+\def\sphinxhyphenforbookmarks{-}
+
+% For curly braces inside \index macro
+\def\sphinxleftcurlybrace{\{}
+\def\sphinxrightcurlybrace{\}}
+
+% Declare Unicode characters used by linux tree command to pdflatex utf8/utf8x
+\def\spx@bd#1#2{%
+ \leavevmode
+ \begingroup
+ \ifx\spx@bd@height \@undefined\def\spx@bd@height{\baselineskip}\fi
+ \ifx\spx@bd@width \@undefined\setbox0\hbox{0}\def\spx@bd@width{\wd0 }\fi
+ \ifx\spx@bd@thickness\@undefined\def\spx@bd@thickness{.6\p@}\fi
+ \ifx\spx@bd@lower \@undefined\def\spx@bd@lower{\dp\strutbox}\fi
+ \lower\spx@bd@lower#1{#2}%
+ \endgroup
+}%
+\@namedef{sphinx@u2500}% BOX DRAWINGS LIGHT HORIZONTAL
+ {\spx@bd{\vbox to\spx@bd@height}
+ {\vss\hrule\@height\spx@bd@thickness
+ \@width\spx@bd@width\vss}}%
+\@namedef{sphinx@u2502}% BOX DRAWINGS LIGHT VERTICAL
+ {\spx@bd{\hb@xt@\spx@bd@width}
+ {\hss\vrule\@height\spx@bd@height
+ \@width \spx@bd@thickness\hss}}%
+\@namedef{sphinx@u2514}% BOX DRAWINGS LIGHT UP AND RIGHT
+ {\spx@bd{\hb@xt@\spx@bd@width}
+ {\hss\raise.5\spx@bd@height
+ \hb@xt@\z@{\hss\vrule\@height.5\spx@bd@height
+ \@width \spx@bd@thickness\hss}%
+ \vbox to\spx@bd@height{\vss\hrule\@height\spx@bd@thickness
+ \@width.5\spx@bd@width\vss}}}%
+\@namedef{sphinx@u251C}% BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ {\spx@bd{\hb@xt@\spx@bd@width}
+ {\hss
+ \hb@xt@\z@{\hss\vrule\@height\spx@bd@height
+ \@width \spx@bd@thickness\hss}%
+ \vbox to\spx@bd@height{\vss\hrule\@height\spx@bd@thickness
+ \@width.5\spx@bd@width\vss}}}%
+\protected\def\sphinxunichar#1{\@nameuse{sphinx@u#1}}%
+
+% Tell TeX about pathological hyphenation cases:
+\hyphenation{Base-HTTP-Re-quest-Hand-ler}
+
+\endinput
diff --git a/sphinx/texinputs/sphinxlatextables.sty b/sphinx/texinputs/sphinxlatextables.sty
new file mode 100644
index 0000000..9e44532
--- /dev/null
+++ b/sphinx/texinputs/sphinxlatextables.sty
@@ -0,0 +1,1246 @@
+%% TABLES (WITH SUPPORT FOR MERGED CELLS OF GENERAL CONTENTS)
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxlatextables.sty}[2022/08/15 tables]%
+
+% Provides support for this output mark-up from Sphinx latex writer
+% and table templates:
+%
+% - the tabulary and longtable environments from the eponymous packages
+% - the varwidth environment
+% - the >{} etc mark-up possible in tabularcolumns is from array package
+% which is loaded by longtable and tabulary
+% - \X, \Y, T column types; others (L, C, R, J) are from tabulary package
+% - \sphinxaftertopcaption
+% - \sphinxatlongtableend
+% - \sphinxatlongtablestart
+% - \sphinxattableend
+% - \sphinxattablestart
+% - \sphinxcapstartof
+% - \sphinxcolwidth
+% - \sphinxlongtablecapskipadjust
+% - \sphinxmultirow
+% - \sphinxstartmulticolumn
+% - \sphinxstopmulticolumn
+% - \sphinxtablestrut
+% - \sphinxthecaptionisattop
+% - \sphinxthelongtablecaptionisattop
+% - \sphinxhline
+% - \sphinxcline
+% - \sphinxvlinecrossing
+% - \sphinxfixclines
+% - \sphinxtoprule
+% - \sphinxmidrule
+% - \sphinxbottomrule
+% - \sphinxtableatstartofbodyhook
+% - \sphinxtableafterendhook
+% - \sphinxthistablewithglobalstyle
+% - \sphinxthistablewithbooktabsstyle
+% - \sphinxthistablewithborderlessstyle
+% - \sphinxthistablewithstandardstyle
+% - \sphinxthistablewithcolorrowsstyle
+% - \sphinxthistablewithnocolorrowsstyle
+% - \sphinxthistablewithvlinesstyle
+% - \sphinxthistablewithnovlinesstyle
+%
+% Executes \RequirePackage for:
+%
+% - tabulary
+% - longtable
+% - varwidth
+% - colortbl
+% - booktabs if 'booktabs' in latex_table_style
+%
+% Extends tabulary and longtable via patches and custom macros to support
+% merged cells possibly containing code-blocks in complex tables
+
+\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
+% sphinxpackagemulticell.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-\spx@arrayrulewidth)*#1/#2-\tw@\tabcolsep-\spx@arrayrulewidth\relax}}
+\newcolumntype{\Y}[1]{p{\dimexpr
+ #1\dimexpr\linewidth-\spx@arrayrulewidth\relax-\tw@\tabcolsep-\spx@arrayrulewidth\relax}}
+% \spx@arrayrulewidth is used internally and its meaning will be set according
+% to the table type; no extra user code should modify it. In particular any
+% \setlength{\spx@arrayrulewidth}{...} may break all of LaTeX... (really...)
+\def\spx@arrayrulewidth{\arrayrulewidth}% 5.3.0, to be adjusted by each table
+% 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{\@nobreakfalse % latex3/latex2e#173
+ \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}}%
+}%
+
+% NOTA BENE: since the multicolumn and multirow code was written Sphinx
+% decided to prefix non public internal macros by \spx@ and in fact all
+% such macros here should now be prefixed by \spx@table@, but doing the
+% update is delayed to later. (written at 5.3.0)
+
+%%%%%%%%%%%%%%%%%%%%%
+% --- MULTICOLUMN ---
+% standard LaTeX's \multicolumn
+% 1. does not allow verbatim contents,
+% 2. interacts very poorly with tabulary.
+%
+% It is needed to write own macros for Sphinx: to allow code-blocks in merged
+% cells rendered by tabular/longtable, and to allow multi-column cells with
+% paragraphs to be taken into account sanely by tabulary algorithm for column
+% widths.
+%
+% This requires quite a bit of hacking. First, in Sphinx, the multi-column
+% contents will *always* be wrapped in a varwidth environment. The issue
+% becomes to pass it the correct target width. We must trick tabulary into
+% believing the multicolumn is simply separate columns, else tabulary does not
+% incorporate the contents in its algorithm. But then we must clear the
+% vertical rules...
+%
+% configuration of tabulary
+\setlength{\tymin}{3\fontcharwd\font`0 }% minimal width of "squeezed" columns
+\setlength{\tymax}{10000pt}% allow enough room for paragraphs to "compete"
+% we need access to tabulary's final computed width. \@tempdima is too volatile
+% to hope it has kept tabulary's value when \sphinxcolwidth needs it.
+\newdimen\sphinx@TY@tablewidth
+\def\tabulary{%
+ \def\TY@final{\sphinx@TY@tablewidth\@tempdima\tabular}%
+ \let\endTY@final\endtabular
+ \TY@tabular}%
+% next hack is needed only if user has set latex_use_latex_multicolumn to True:
+% it fixes tabulary's bug with \multicolumn defined "short" in first pass. (if
+% upstream tabulary adds a \long, our extra one causes no harm)
+\def\sphinx@tempa #1\def\multicolumn#2#3#4#5#6#7#8#9\sphinx@tempa
+ {\def\TY@tab{#1\long\def\multicolumn####1####2####3{\multispan####1\relax}#9}}%
+\expandafter\sphinx@tempa\TY@tab\sphinx@tempa
+%
+% TN. 1: as \omit is never executed, Sphinx multicolumn does not need to worry
+% like standard multicolumn about |l| vs l|. On the other hand it assumes
+% columns are separated by a | ... (if not it will add extraneous
+% \arrayrulewidth space for each column separation in its estimate of available
+% width).
+%
+% Update at 5.3.0: code uses \spx@arrayrulewidth which is kept in sync with the
+% table column specification (aka preamble):
+% - no | in preamble: \spx@arrayrulewidth -> \z@
+% - at least a | in the preamble: \spx@arrayrulewidth -> \arrayrulewidth
+% This is used for computation of merged cells widths. Mixed preambles using
+% at least a | but not using it for all columns (as can be obtained via the
+% tabularcolumns directive) may cause some merged cells contents to be slightly
+% shifted to the left as they assume merged columns are | separated where in
+% fact they perhaps are not.
+%
+% TN. 1b: as Sphinx multicolumn uses neither \omit nor \span, it can not
+% (easily) get rid of extra macros from >{...} or <{...} between columns. At
+% least, it has been made compatible with colortbl's \columncolor.
+%
+% TN. 2: tabulary's second pass is handled like tabular/longtable's single
+% pass, with the difference that we hacked \TY@final to set in
+% \sphinx@TY@tablewidth the final target width as computed by tabulary. This is
+% needed only to handle columns with a "horizontal" specifier: "p" type columns
+% (inclusive of tabulary's LJRC) holds the target column width in the
+% \linewidth dimension.
+%
+% TN. 3: use of \begin{sphinxmulticolumn}...\end{sphinxmulticolumn} mark-up
+% would need some hacking around the fact that groups can not span across table
+% cells (the code does inserts & tokens, see TN1b). It was decided to keep it
+% simple with \sphinxstartmulticolumn...\sphinxstopmulticolumn.
+%
+% MEMO about nesting: if sphinxmulticolumn is encountered in a nested tabular
+% inside a tabulary it will think to be at top level in the tabulary. But
+% Sphinx generates no nested tables, and if some LaTeX macro uses internally a
+% tabular this will not have a \sphinxstartmulticolumn within it!
+%
+% 5.3.0 adds a check for multirow as single-row multi-column will allow a row
+% colour but multi-row multi-column should not.
+% Attention that this assumes \sphinxstartmulticolumn is always followed
+% in latex mark-up either by \sphinxmultirow or \begin (from \begin{varwidth}).
+\def\sphinxstartmulticolumn#1#2{%
+ \ifx\sphinxmultirow#2%
+ \gdef\spx@table@hackCT@inmergedcell{\spx@table@hackCT@nocolor}%
+ \else
+ \global\let\spx@table@hackCT@inmergedcell\spx@@table@hackCT@inmergedcell
+ \fi
+ \sphinx@startmulticolumn{#1}#2%
+}%
+\def\sphinx@startmulticolumn{%
+ \ifx\equation$% $ tabulary's first pass
+ \expandafter\sphinx@TYI@start@multicolumn
+ \else % either not tabulary or tabulary's second pass
+ \expandafter\sphinx@start@multicolumn
+ \fi
+}%
+\def\sphinxstopmulticolumn{%
+ \ifx\equation$% $ tabulary's first pass
+ \expandafter\sphinx@TYI@stop@multicolumn
+ \else % either not tabulary or tabulary's second pass
+ \ignorespaces
+ \fi
+}%
+\def\sphinx@TYI@start@multicolumn#1{%
+ % use \gdef always to avoid stack space build up
+ \gdef\sphinx@tempa{#1}\begingroup\setbox\z@\hbox\bgroup
+}%
+\def\sphinx@TYI@stop@multicolumn{\egroup % varwidth was used with \tymax
+ \xdef\sphinx@tempb{\the\dimexpr\wd\z@/\sphinx@tempa}% per column width
+ \endgroup
+ \expandafter\sphinx@TYI@multispan\expandafter{\sphinx@tempa}%
+}%
+\def\sphinx@TYI@multispan #1{%
+ \kern\sphinx@tempb\ignorespaces % the per column occupied width
+ \ifnum#1>\@ne % repeat, taking into account subtleties of TeX's & ...
+ \expandafter\sphinx@TYI@multispan@next\expandafter{\the\numexpr#1-\@ne\expandafter}%
+ \fi
+}%
+\def\sphinx@TYI@multispan@next{&\relax\sphinx@TYI@multispan}%
+%
+% Now the branch handling either the second pass of tabulary or the single pass
+% of tabular/longtable. This is the delicate part where we gather the
+% dimensions from the p columns either set-up by tabulary or by user p column
+% or Sphinx \X, \Y columns. The difficulty is that to get the said width, the
+% template must be inserted (other hacks would be horribly complicated except
+% if we rewrote crucial parts of LaTeX's \@array !) and we can not do
+% \omit\span like standard \multicolumn's easy approach. Thus we must cancel
+% the \vrule separators. Also, perhaps the column specifier is of the l, c, r
+% type, then we attempt an ad hoc rescue to give varwidth a reasonable target
+% width.
+\def\sphinx@start@multicolumn#1{%
+ \gdef\sphinx@multiwidth{0pt}\gdef\sphinx@tempa{#1}\sphinx@multispan{#1}%
+}%
+\def\sphinx@multispan #1{%
+ \ifnum#1=\@ne\expandafter\sphinx@multispan@end
+ \else\expandafter\sphinx@multispan@next
+ \fi {#1}%
+}%
+\def\sphinx@multispan@next #1{%
+ % trick to recognize L, C, R, J or p, m, b type columns
+ \ifdim\baselineskip>\z@
+ \gdef\sphinx@tempb{\linewidth}%
+ \else
+ % if in an l, r, c type column, try and hope for the best
+ \xdef\sphinx@tempb{\the\dimexpr(\ifx\TY@final\@undefined\linewidth\else
+ \sphinx@TY@tablewidth\fi-\spx@arrayrulewidth)/\sphinx@tempa
+ -\tw@\tabcolsep-\spx@arrayrulewidth\relax}%
+ \fi
+ \noindent\kern\sphinx@tempb\relax
+ \xdef\sphinx@multiwidth
+ {\the\dimexpr\sphinx@multiwidth+\sphinx@tempb+\tw@\tabcolsep+\spx@arrayrulewidth}%
+ \spx@table@hackCT@fixcolorpanel
+ % silence a | column separator in our merged cell
+ \spx@table@hackCT@inhibitvline
+ % prevent column colours to interfere with our multi-column but allow row
+ % colour (we can't obey a \cellcolor as it has not be seen yet at this stage)
+ \spx@table@hackCT@inmergedcell&\relax
+ % repeat
+ \expandafter\sphinx@multispan\expandafter{\the\numexpr#1-\@ne}%
+}%
+\def\sphinx@multispan@end#1{%
+ % first, trace back our steps horizontally
+ \noindent\kern-\dimexpr\sphinx@multiwidth\relax
+ % and now we set the final computed width for the varwidth environment
+ \ifdim\baselineskip>\z@
+ \xdef\sphinx@multiwidth{\the\dimexpr\sphinx@multiwidth+\linewidth}%
+ \else
+ \xdef\sphinx@multiwidth{\the\dimexpr\sphinx@multiwidth+
+ (\ifx\TY@final\@undefined\linewidth\else
+ \sphinx@TY@tablewidth\fi-\spx@arrayrulewidth)/\sphinx@tempa
+ -\tw@\tabcolsep-\spx@arrayrulewidth\relax}%
+ \fi
+ % last cell of the multi-column
+ \aftergroup\spx@table@hackCT@fixcolorpanel
+ \aftergroup\spx@table@hackCT@inmergedcell
+}%
+\newcommand*\sphinxcolwidth[2]{%
+ % this dimension will always be used for varwidth, and serves as maximum
+ % width when cells are merged either via multirow or multicolumn or both,
+ % as always their contents is wrapped in varwidth environment.
+ \ifnum#1>\@ne % multi-column (and possibly also multi-row)
+ % we wrote our own multicolumn code especially to handle that (and allow
+ % verbatim contents)
+ \ifx\equation$%$
+ \tymax % first pass of tabulary (cf MEMO above regarding nesting)
+ \else % the \@gobble thing is for compatibility with standard \multicolumn
+ \sphinx@multiwidth\@gobble{#1/#2}%
+ \fi
+ \else % single column multirow
+ \ifx\TY@final\@undefined % not a tabulary.
+ \ifdim\baselineskip>\z@
+ % in a p{..} type column, \linewidth is the target box width
+ \linewidth
+ \else
+ % l, c, r columns. Do our best.
+ \dimexpr(\linewidth-\spx@arrayrulewidth)/#2-
+ \tw@\tabcolsep-\spx@arrayrulewidth\relax
+ \fi
+ \else % in tabulary
+ \ifx\equation$%$% first pass
+ \tymax % it is set to a big value so that paragraphs can express themselves
+ \else
+ % second pass.
+ \ifdim\baselineskip>\z@
+ \linewidth % in a L, R, C, J column or a p, \X, \Y ...
+ \else
+ % we have hacked \TY@final to put in \sphinx@TY@tablewidth the table width
+ \dimexpr(\sphinx@TY@tablewidth-\spx@arrayrulewidth)/#2-
+ \tw@\tabcolsep-\spx@arrayrulewidth\relax
+ \fi
+ \fi
+ \fi
+ \fi
+}%
+% fallback default in case user has set latex_use_latex_multicolumn to True:
+% \sphinxcolwidth will use this only inside LaTeX's standard \multicolumn
+\def\sphinx@multiwidth #1#2{\dimexpr % #1 to gobble the \@gobble (!)
+ (\ifx\TY@final\@undefined\linewidth\else\sphinx@TY@tablewidth\fi
+ -\spx@arrayrulewidth)*#2-\tw@\tabcolsep-\spx@arrayrulewidth\relax}%
+
+% \spx@table@hackCT@inhibitvline
+% packages like colortbl add group levels, we need to "climb back up" to be
+% able to hack the \vline and also the colortbl inserted tokens. The hack
+% sets the \arrayrulewidth to \z@ to inhibit a | separator at right end
+% of the cell, if present (our code does not use \omit so can not avoid the
+% \vline insertion, but setting its width to zero makes it do nothing).
+% Some subtlety with colour panels must be taken care of.
+\def\spx@table@hackCT@inhibitvline{\ifnum\currentgrouptype=6\relax
+ \kern\spx@arrayrulewidth % will be compensated by extra colour panel left overhang
+ \arrayrulewidth\z@% trick to inhibit the {\vrule width \arrayrulewidth}
+ \else\aftergroup\spx@table@hackCT@inhibitvline\fi}%
+
+% hacking around colour matters
+% Sphinx 1.6 comment:
+% It turns out \CT@row@color is not expanded contrarily to \CT@column@color
+% during LaTeX+colortbl preamble preparation, hence it would be possible for
+% \CT@setup to discard only the column color and choose to obey or not
+% row color and cell color. It would even be possible to propagate cell color
+% to row color for the duration of the Sphinx multicolumn... the (provisional?)
+% choice has been made to cancel the colortbl colours for the multicolumn
+% duration.
+% Sphinx 5.3.0 comment:
+% - colortbl has no mechanism to disable colour background in a given cell:
+% \cellcolor triggers one more \color, but has no possibility to revert
+% a previously emitted \color, only to override it via an additional \color
+% - prior to 5.3.0, Sphinx did not officially support colour in tables,
+% but it did have a mechanism to protect merged cells from being partly
+% covered by colour panels at various places. At 5.3.0 this mechanism
+% is relaxed a bit to allow row colour for a single-row merged cell.
+%
+% fixcolorpanel
+\def\spx@table@hackCT@fixcolorpanel{\ifnum\currentgrouptype=6\relax
+ \edef\spx@table@leftcolorpanelextra
+ % \edef as \arrayrulewidth will be set to \z@ next,
+ % hence also \spx@arrayrulewidth...
+ {\sphinxcolorpanelextraoverhang+\the\spx@arrayrulewidth}%
+ \else\aftergroup\spx@table@hackCT@fixcolorpanel\fi}%
+%
+% inmergedcell
+% \spx@table@hackCT@inmergedcell will be locally set to either this
+% \spx@@table@hackCT@inmergedcell or to \spx@table@hackCT@nocolor
+% "\let\spx@original@CT@setup\CT@setup" is done after loading colortbl
+\def\spx@@table@hackCT@inmergedcell{\ifnum\currentgrouptype=6\relax
+ \let\CT@setup\spx@CT@setup@inmergedcell
+ \else\aftergroup\spx@@table@hackCT@inmergedcell\fi
+}%
+\newif\ifspx@table@inmergedcell
+\def\spx@CT@setup@inmergedcell #1\endgroup{%
+ % - obey only row color and disable effect of \sphinxcolorblend
+ % - turn on the inmergedcell boolean to signal to \CT@row@color
+ \spx@original@CT@setup
+ \spx@table@inmergedcelltrue % needed by \CT@row@color
+ % deactivate effect of \sphinxcolorblend if it happened at all
+ \ifdefined\blendcolors\blendcolors{}\fi
+ \CT@row@color
+ \CT@do@color
+ \global\let\CT@cell@color\relax
+ \endgroup
+}%
+%
+% nocolor
+\def\spx@table@hackCT@nocolor{\ifnum\currentgrouptype=6\relax
+% sadly \CT@column@color is possibly already expanded so we can't
+% simply do \let\CT@column@color\relax etc...
+% admittedly we could perhaps hack \CT@color but well
+ \let\CT@setup\spx@CT@setup@nocolor
+ \else\aftergroup\spx@table@hackCT@nocolor\fi
+}
+\def\spx@CT@setup@nocolor#1\endgroup{%
+ \global\let\CT@cell@color\relax
+ % the above fix was added at 5.3.0
+ % formerly a \cellcolor added by a raw latex directive in the merged cell
+ % would have caused colour to apply to the *next* cell after the merged
+ % one; we don't support \cellcolor from merged cells contents anyhow.
+ \endgroup}
+%
+% norowcolor
+\def\spx@table@hackCT@norowcolor{%
+% a bit easier although merged cells complicate the matter as they do need
+% to keep the rowcolor; and we can't know yet if we are in a merged cell
+ \ifnum\currentgrouptype=6\relax
+ \ifx\CT@row@color\relax
+ \else
+ \let\spx@saved@CT@row@color\CT@row@color
+ \def\CT@row@color{%
+ \ifspx@table@inmergedcell\expandafter\spx@saved@CT@row@color\fi
+ }%
+ \fi
+ \else\aftergroup\spx@table@hackCT@norowcolor\fi
+}
+%
+% \sphinxcolorblend
+\def\spx@table@hackCT@colorblend{%
+ \ifnum\currentgrouptype=6\relax
+ \expandafter\blendcolors\spx@colorblendparam
+ % merged cells will do a \blendcolors{} to cancel the effet
+ % we can not know here yet if in merged cell as the boolean
+ % \ifspx@table@inmergedcell is not yet updated
+ \else
+ \aftergroup\spx@table@hackCT@colorblend
+ \fi
+}
+\def\sphinxcolorblend#1{\gdef\spx@colorblendparam{{#1}}\spx@table@hackCT@colorblend}
+% Either xcolor.sty exists on user system and has been loaded by sphinx.sty,
+% or it does not exist, so we can use \@ifpackageloaded without delaying.
+\@ifpackageloaded{xcolor}%
+ {}%
+ {\def\sphinxcolorblend#1{%
+\PackageWarning{sphinx}{This table uses \string\sphinxcolorblend\space
+ but xcolor is not in\MessageBreak
+ the TeX/LaTeX installation, the command will be\MessageBreak
+ ignored in this and the next tables}%
+ \global\let\sphinxcolorblend\@gobble
+ \sphinxbuildwarning{colorblend}%
+ }%
+ }
+
+
+%%%%%%%%%%%%%%%%%%
+% --- MULTIROW ---
+% standard \multirow
+% 1. does not allow verbatim contents,
+% 2. does not allow blank lines in its argument,
+% 3. its * specifier means to typeset "horizontally" which is very
+% bad for paragraph content. 2016 version has = specifier but it
+% must be used with p type columns only, else results are bad,
+% 4. it requires manual intervention if the contents is too long to fit
+% in the asked-for number of rows.
+% 5. colour panels (either from \rowcolor or \columncolor) will hide
+% the bottom part of multirow text, hence manual tuning is needed
+% to put the multirow insertion at the _bottom_.
+%
+% The Sphinx solution consists in always having contents wrapped
+% in a varwidth environment so that it makes sense to estimate how many
+% lines it will occupy, and then ensure by insertion of suitable struts
+% that the table rows have the needed height. The needed mark-up is done
+% by LaTeX writer, which has its own id for the merged cells.
+%
+% The colour issue is "solved" by clearing colour panels in all cells,
+% whether or not the multirow is single-column or multi-column.
+%
+% MEMO at 5.3.0: to allow a multirow cell in a single column to react to
+% \columncolor correctly, it seems only way is that the contents
+% are inserted by bottom cell (this is mentioned in multirow.sty doc, too).
+% Sphinx could at Python level "move" the contents to that cell. But the
+% mechanism used here via \sphinxtablestrut to enlarge rows to make room for
+% the contents if needed becomes more challenging yet, because \sphinxtablestrut
+% mark-up will be parsed by TeX *before* it sees the contents of the merged
+% cell.. So it seems the best way would be to actually store the contents into
+% some owned-by-Sphinx box storage which needs to be globally allocated to
+% that usage ; then we need multiple such boxes, say at least 5 to cover
+% 99% or use case. Or perhaps some trick with storing in a \vbox and recovering
+% via some \vsplit but this becomes complicated... perhaps in future.
+%
+% In passing we obtain baseline alignements across rows (only if
+% \arraystretch is 1, as LaTeX's does not obey \arraystretch in "p"
+% multi-line contents, only first and last line...)
+%
+% TODO: examine the situation with \arraystretch > 1. The \extrarowheight
+% is hopeless for multirow anyhow, it makes baseline alignment strictly
+% impossible.
+\newcommand\sphinxmultirow[2]{\begingroup
+ % #1 = nb of spanned rows, #2 = Sphinx id of "cell", #3 = contents
+ % but let's fetch #3 in a way allowing verbatim contents !
+ \def\sphinx@nbofrows{#1}\def\sphinx@cellid{#2}%
+ \afterassignment\sphinx@multirow\let\next=
+}%
+\def\sphinx@multirow {%
+ \setbox\z@\hbox\bgroup\aftergroup\sphinx@@multirow\strut
+}%
+\def\sphinx@@multirow {%
+% MEMO: we could check status of \CT@cell@color here, but unfortunately we
+% can't know the exact height which will be covered by the cells in total
+% (it may be more than our \box\z@ dimensions). We could use an \fcolorbox
+% wrapper on \box\z@ but this will not extend precisely to the bottom rule.
+%
+% Only solution if we want to obey a raw \cellcolor, or a \columncolor, seems
+% to delay unboxing the gathered contents as part of the bottom row with
+% a suitable vertical adjustment...
+%
+ % The contents, which is a varwidth environment, has been captured in
+ % \box0 (a \hbox).
+ % We have with \sphinx@cellid an assigned unique id. The goal is to give
+ % about the same height to all the involved rows.
+ % For this Sphinx will insert a \sphinxtablestrut{cell_id} mark-up
+ % in LaTeX file and the expansion of the latter will do the suitable thing.
+ \dimen@\dp\z@
+ \dimen\tw@\ht\@arstrutbox
+ \advance\dimen@\dimen\tw@
+ \advance\dimen\tw@\dp\@arstrutbox
+ \count@=\dimen@ % type conversion dim -> int
+ \count\tw@=\dimen\tw@
+ \divide\count@\count\tw@ % TeX division truncates
+ \advance\dimen@-\count@\dimen\tw@
+ % 1300sp is about 0.02pt. For comparison a rule default width is 0.4pt.
+ % (note that if \count@ holds 0, surely \dimen@>1300sp)
+ \ifdim\dimen@>1300sp \advance\count@\@ne \fi
+ % now \count@ holds the count L of needed "lines"
+ % and \sphinx@nbofrows holds the number N of rows
+ % we have L >= 1 and N >= 1
+ % if L is a multiple of N, ... clear what to do !
+ % else write L = qN + r, 1 <= r < N and we will
+ % arrange for each row to have enough space for:
+ % q+1 "lines" in each of the first r rows
+ % q "lines" in each of the (N-r) bottom rows
+ % for a total of (q+1) * r + q * (N-r) = q * N + r = L
+ % It is possible that q == 0.
+ \count\tw@\count@
+ % the TeX division truncates
+ \divide\count\tw@\sphinx@nbofrows\relax
+ \count4\count\tw@ % q
+ \multiply\count\tw@\sphinx@nbofrows\relax
+ \advance\count@-\count\tw@ % r
+ \expandafter\xdef\csname sphinx@tablestrut_\sphinx@cellid\endcsname
+ {\noexpand\sphinx@tablestrut{\the\count4}{\the\count@}{\sphinx@cellid}}%
+ \dp\z@\z@
+ % this will use the real height if it is >\ht\@arstrutbox
+ \sphinxtablestrut{\sphinx@cellid}\box\z@
+ \endgroup % group was opened in \sphinxmultirow
+}%
+\newcommand*\sphinxtablestrut[1]{%
+ % #1 is a "cell_id", i.e. the id of a merged group of table cells
+ \csname sphinx@tablestrut_#1\endcsname
+}%
+% LaTeX typesets the table row by row, hence each execution can do
+% an update for the next row.
+\newcommand*\sphinx@tablestrut[3]{\begingroup
+ % #1 = q, #2 = (initially) r, #3 = cell_id, q+1 lines in first r rows
+ % if #2 = 0, create space for max(q,1) table lines
+ % if #2 > 0, create space for q+1 lines and decrement #2
+ \leavevmode
+ \count@#1\relax
+ \ifnum#2=\z@
+ \ifnum\count@=\z@\count@\@ne\fi
+ \else
+ % next row will be with a #2 decremented by one
+ \expandafter\xdef\csname sphinx@tablestrut_#3\endcsname
+ {\noexpand\sphinx@tablestrut{#1}{\the\numexpr#2-\@ne}{#3}}%
+ \advance\count@\@ne
+ \fi
+ \vrule\@height\ht\@arstrutbox
+ \@depth\dimexpr\count@\ht\@arstrutbox+\count@\dp\@arstrutbox-\ht\@arstrutbox\relax
+ \@width\z@
+ \endgroup
+ % we need this to avoid colour panels hiding bottom parts of multirow text
+ \spx@table@hackCT@nocolor
+}%
+
+%%%%%%%%%%%%%%%%%%
+% --- STYLING ---
+%
+
+%
+% Support for colour in table
+%
+% Core LaTeX package (very old, part of texlive-latex-base on Debian distr.)
+% providing \columncolor, \rowcolor, \cellcolor and \arrayrulecolor.
+\RequirePackage{colortbl}
+\let\spx@original@CT@setup\CT@setup
+
+% LaTeX's \cline has **strong** deficiencies
+% ******************************************
+% We work around them via an added \sphinxfixclines{number of columns} in the
+% table mark-up, and also extra mark-up \sphinxvlinecrossing{col no} for
+% crossings not contiguous to any cline. To fix the gap at left extremity of a
+% \cline, we redefine the core LaTeX \c@line because this avoids adjoining a
+% small square with potential PDF viewer anti-aliasing issues. We waited
+% after loading colortbl because it also redefines \c@line for it to obey the
+% colour set by \arrayrulecolor.
+% MEMO: booktabs package does *not* redefine \@cline so we are safe here.
+\def\@cline#1-#2\@nil{%
+ \omit
+ \@multicnt#1%
+ \advance\@multispan\m@ne
+ \ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
+ \@multicnt#2%
+ \advance\@multicnt-#1%
+ \advance\@multispan\@ne
+ {\CT@arc@
+% start of Sphinx modification
+ \ifnum#1>\@ne\kern-\spx@arrayrulewidth\fi% fix gap at join with vertical lines
+% end of Sphinx modification
+% Comments:
+%
+% If we had the information whether the previous column ended with a | or
+% not, we could decide what to do here. Alternatively the mark-up could
+% use either original \cline or the one modified as here depending on case.
+% One wonders why LaTeX does not provide itself the alternative as a
+% complement to \cline, to use on case by case basis.
+% Here we handle both at same time via using the \spx@arrayrulewidth which
+% will be \z@ if no | at all so will induce here nothing.
+%
+% As a result Sphinx basically supports well only tables having either all
+% columns |-separated, or no | at all, as it uses \spx@arrayrrulewidth in
+% all columns (here and in multicolumn code).
+%
+% We also considered a method not modifying \c@line but it requires too
+% much extra mark-up from Python LaTeX writer and/or extra LaTeX coding.
+% back to LaTeX+colortbl code
+ \leaders\hrule\@height\arrayrulewidth\hfill}%
+ \cr
+% the last one will need to be compensated, this is job of \sphinxclines
+ \noalign{\vskip-\arrayrulewidth}%
+}
+\def\spx@table@fixvlinejoin{%
+ {\CT@arc@ % this is the color command set up by \arrayrulecolor
+ \vrule\@height\arrayrulewidth
+% side remark: LaTeX has only a single \arrayrulewidth for all kinds
+% for cell borders in table, horizontal or vertical...
+ \@depth\z@
+ \@width\spx@arrayrulewidth
+ }%
+}
+% Sphinx LaTeX writer issues one such for each vertical line separating two
+% contiguous multirow cells; i.e. those crossings which can are not already
+% taken care of by our modified at left extremity \cline.
+% One could imagine a more \...crossingS (plural) receiving a comma delimited
+% list, which would simplify the mark-up but this would complexify both the
+% Python and the LaTeX coding.
+\def\sphinxtablevlinecrossing#1{%
+ \sphinxtabledecrementrownum
+ \omit
+ \@multispan{#1}%
+ \hfill
+ \spx@table@fixvlinejoin
+ \cr
+ \noalign{\vskip-\arrayrulewidth}%
+}
+% This "fixclines" is also needed if no \sphinxcline emitted and is useful
+% even in extreme case with no \sphinxvlinecrossing either, to give correct
+% height to multirow extending across all table width assuming other rows are
+% separated generally by an \hline, so as to keep coherent line spacing.
+%
+% It is designed to work ok even if no | separators are in the table (because
+% \spx@table@fixvlinejoin uses \spx@arrayrulewidth which is \z@ in that case).
+\def\sphinxtablefixclines#1{% #1 is the number of columns of the table
+ \sphinxtabledecrementrownum
+ \omit
+ \spx@table@fixvlinejoin% unneeded if first \cline started at column 1 but does
+ % not hurt; fills small gap at left-bordered table
+ \@multispan{#1}%
+ \hfill
+ \spx@table@fixvlinejoin% fill small gap at right-bordered table
+ \cr
+ % this final one does NO \vskip-\arrayrulewidth... that's the whole point
+}
+%%%% end of \cline workarounds
+
+%
+% - passing option "table" to xcolor also loads colortbl but we needed to
+% load color or xcolor prior to the handling of the options
+%
+% - the \rowcolors command from [table]{xcolor} has various problems:
+%
+% * it is rigid and does not out-of-the-box allow a more complex scheme
+% such as colorA+colorB+colorC+colorB+colorC+colorB+colorC... suitable to
+% distinguish a header row.
+%
+% * its code does not export the used colour, an information which we may
+% need for example to colourize the rule via \arrayrulecolor in the
+% appropriate manner, for example to colourize the booktabs induced vertical
+% whitespace to avoid gaps (if one wants to).
+%
+% * incompatibility with tabulary: the output depends on parity of total
+% number of rows!
+%
+% * problems with longtable: the caption will receive a background colour
+% panel, if we do not deactivate the \rowcolors action during definition of
+% the headers and footers; this requires extra mark-up. Besides if we
+% deactivate using \hiderowcolors during header and footer formation, the
+% parity of the body rows is shifted, \rownum is even, not odd, at first body
+% row. And setting \rownum at start of first body row is too late for
+% influencing the colour.
+%
+% * it has a global impact and must be reset at each table. We can not
+% issue it only once and it provides no public interface (without @) to
+% cancel its effect conveniently (\hiderowcolors can only be used from
+% *inside* a table.)
+%
+% * its core mechanism which increments the row count is triggered
+% if a \cline is encountered... so this offsets the alternating colours...
+% ... or not if there are two \cline's in the row...
+% (as we will use same mechanism we have to correct this increment).
+%
+% So we need our own code.
+
+% Provide \rownum and rownum LaTeX counter (code copied from colortbl v1.0f)
+\ltx@ifundefined{rownum}{%
+ \ltx@ifundefined{c@rownum}%
+ {\newcount\rownum\let\c@rownum\rownum}%
+ {\let\rownum\c@rownum}%
+ }%
+{\let\c@rownum\rownum}
+\providecommand\therownum{\arabic{rownum}}
+
+% extra overhang for color panels to avoid visual artifacts in pdf viewers
+% (particularly if borderless)
+\def\sphinxcolorpanelextraoverhang{0.1pt}
+\def\spx@table@leftcolorpanelextra {\sphinxcolorpanelextraoverhang}
+\def\spx@table@rightcolorpanelextra{\sphinxcolorpanelextraoverhang}
+% the macro to which \CT@row@color will be set for coloured rows, serves both
+% in header and body, the colours must have been defined at time of use
+\def\spx@table@CT@row@color{\ifspx@table@inmergedcell
+ \CT@color{sphinxTableMergeColor}%
+ \else
+ \CT@color{sphinxTableRowColor}%
+ \fi
+ \@tempdimb\dimexpr\col@sep+\spx@table@leftcolorpanelextra\relax
+ \@tempdimc\dimexpr\col@sep+\spx@table@rightcolorpanelextra\relax
+ }%
+% used by itself this will influence a single row if \CT@everycr is the
+% colortbl one, to influences all rows the \CT@everycr must be modified (see
+% below)
+\def\sphinxrowcolorON {\global\let\CT@row@color\spx@table@CT@row@color}%
+% this one turns off row colours until the next \sphinxrowcolorON
+\def\sphinxrowcolorOFF{\global\let\CT@row@color\relax}%
+% this one inhibits the row colour in one cell only (can be used as
+% >{\sphinxnorowcolor} for turning off row colours in a given column)
+\def\sphinxnorowcolor{\spx@table@hackCT@norowcolor}%
+
+% \sphinxtoprule (or rather \sphinxtabletoprulehook) will be modified by
+% the colorrows class to execute this one:
+\def\spx@table@@toprule@rowcolorON{%
+ \noalign{%
+ % Because of tabulary 2-pass system, the colour set-up at end of table
+ % would contaminate the header colours at start of table, so must reset
+ % them here. We want all header rows to obey same colours, so we don't
+ % use original \CT@everycr which sets \CT@row@color to \relax.
+ \global\CT@everycr{\the\everycr}%
+ \global\sphinxcolorlet{sphinxTableRowColor}{sphinxTableRowColorHeader}%
+ \global\sphinxcolorlet{sphinxTableMergeColor}{\sphinxTableMergeColorHeader}%
+ \sphinxrowcolorON
+ }%
+}%
+
+% \sphinxtableatstartofbodyhook will be modified by colorrows class to
+% execute this one; it starts the alternating colours and triggers increment
+% or \rownum count at each new row (the xcolor base method for \rowcolors)
+\def\spx@table@@startbodycolorrows{%
+ \noalign{%
+ \global\CT@everycr{% Nota Bene: in a longtable with \hline the \everycr is
+ % done two extra times! but 2 is even, so this is ok
+ \noalign{\global\advance\rownum\@ne % the xcolor \rowcolors base trick
+% MEMO: colortbl \CT@row@color is expanded *after* the cell contents have been
+% gathered and measured, so it can't be used to expose e.g. the colour to the
+% cell contents macro code. Of course if it is known how the colour is chosen
+% the procedure could be done from inside the cell. Simpler to expose the colour
+% in a public name sphinxTableRowColor at start of the row in this \noalign.
+ \sphinxSwitchCaseRowColor\rownum
+ }%
+ \the\everycr
+ }%
+ \global\rownum\@ne % is done from inside table so ok with tabulary two passes
+ \sphinxSwitchCaseRowColor\rownum % set up color for the first body row
+ \sphinxrowcolorON % has been done from \sphinxtoprule location but let's do
+ % it again in case \sphinxtabletoprulehook has been used
+ % to inhibit colours in the header rows
+ }% end of noalign contents
+}
+% set the colours according to row parity; a priori #1 is \rownum, but
+% the macro has been designed to be usable in user level added code
+\def\sphinxSwitchCaseRowColor#1{%
+ \ifodd#1\relax
+ \global\sphinxcolorlet{sphinxTableRowColor}{sphinxTableRowColorOdd}%
+ \global\sphinxcolorlet{sphinxTableMergeColor}{\sphinxTableMergeColorOdd}%
+ \else
+ \global\sphinxcolorlet{sphinxTableRowColor}{sphinxTableRowColorEven}%
+ \global\sphinxcolorlet{sphinxTableMergeColor}{\sphinxTableMergeColorEven}%
+ \fi
+}
+
+% each \cline or \cmidrule (booktabs) consumes one \cr, offsetting the \rownum
+% parity; so this macro serves to compensate and must be added to each such
+% \cline or \cmidrule (see below)
+\def\spx@table@@decrementrownum{\noalign{\global\advance\rownum\m@ne}}
+\let\sphinxtabledecrementrownum\@empty
+
+% \sphinxtableafterendhook will be modified by colorrows class to execute
+% this after the table
+\def\spx@table@resetcolortbl{%
+ \sphinxrowcolorOFF
+ \spx@table@reset@CTeverycr
+% this last bit is done in order for the \sphinxbottomrule from the "foot"
+% longtable template to be able to use same code as the \sphinxbottomrule
+% at end of table body; see \sphinxbooktabsspecialbottomrule code
+ \global\rownum\z@
+}
+\def\spx@table@reset@CTeverycr{%
+% we should probably be more cautious and not hard-code here the colortbl
+% set-up; so the macro is defined without @ to fac
+ \global\CT@everycr{\noalign{\global\let\CT@row@color\relax}\the\everycr}%
+}
+
+% At last the style macros \sphinxthistablewithstandardstyle etc...
+
+% They are executed before the table environments in a scope limiting
+% wrapper "savenotes" environment.
+%
+% 0) colour support is enacted via adding code to three hooks:
+% - \sphinxtabletoprulehook (implicit from \sphinxtoprule expansion)
+% - \sphinxtableatstartofbodyhook (explicit from table templates)
+% - \sphinxtableafterendhook (explicit from table templates)
+% additionally special adjustment must be made in \sphinxcline
+%
+\def\sphinxtoprule{\spx@toprule\sphinxtabletoprulehook}
+% \spx@toprule is what is defined by the standard, booktabs and borderless
+% styles.
+% The colorrows class will prepend \spx@table@toprule@rowcolorON into
+% \sphinxtabletoprulehook which a priori is \@empty but can contain user added
+% extra code, and is executed after \spx@toprule.
+\let\sphinxtabletoprulehook \@empty
+\let\sphinxtableatstartofbodyhook\@empty
+\let\sphinxtableafterendhook \@empty
+%
+% 1) we manage these three hooks in a way allowing a custom user extra wrapper
+% environment from a container class to use them as entry point for some
+% custom code. The container code is done first, prior to table templates.
+% So, the style macros will *prepend* the needed color-code to the existing
+% custom user code, so the custom user code can override them. The custom
+% user code should not redefine any of the 3 \sphinxtable...hook macros via a
+% \global\def, but their contents can use \gdef. In fact they probably need
+% to for the first two hooks which are executed from inside the table and
+% a priori need their code to be in a \noalign which limits scope.
+%
+% 2) the table templates and LaTeX writer code make it so that only
+% one of either
+% \sphinxthistablewithcolorrowsstyle,
+% or \sphinxthistablewithnocolorrowsstyle
+% will be inserted explicitly depending on local :class: for table.
+% The global 'colorrows' style in latex_table_style translates at bottom
+% of this file into code for inserting \sphinxthistablewithcolorrowsstyle
+% at end of \sphinxthistablewithglobalstyle. So it is impossible
+% to have first \sphinxthistablewithnocolorrowsstyle, then
+% \sphinxthistablewithcolorrowsstyle. Nevertheless we have written
+% the code so that in this case colorrows would indeed activate (except
+% if it was already executed before as it self-annihilates).
+
+% standard style
+\def\sphinxthistablewithstandardstyle{%
+ % Those two are produced by the latex writer
+ \def\sphinxhline {\hline}%
+ % \sphinxtabledecrementrownum is a no-op which is redefined by colorrows
+ % to correct the \rownum increment induced by \cline in colorrows regime
+ \def\sphinxcline {\sphinxtabledecrementrownum\cline}%
+ % LaTeX's \cline needs fixing
+ \let\sphinxvlinecrossing\sphinxtablevlinecrossing
+ \let\sphinxfixclines \sphinxtablefixclines
+ % Those three are inserted by the table templates
+ \def\spx@toprule {\hline}%
+ \def\sphinxmidrule {\hline}%
+ \def\sphinxbottomrule {\hline}%
+ % Do not tamper with this internal
+ \def\spx@arrayrulewidth{\arrayrulewidth}%
+}
+
+% booktabs style
+% The \@xcmidrule patch below will do beyond its main stuff
+% \sphinxadjustcmidrulebelowsep
+% Indeed the poor booktabs spacing with \cmidrule (if \sphinxbooktabscmidrule
+% defined below is overwritten to use it) is quite awful. Do
+% \let\sphinxadjustcmidrulebelowsep\empty
+% if you prefer booktabs defaults.
+\def\sphinxadjustcmidrulebelowsep{\belowrulesep=\aboverulesep}
+\AtBeginDocument{% patch booktabs to avoid extra vertical space from
+ % consecutive \sphinxcline, if defined to use \cmidrule
+ \ifdefined\@xcmidrule
+ \let\spx@original@@xcmidrule\@xcmidrule
+ \def\@xcmidrule{\sphinxadjustcmidrulebelowsep
+ % if we don't do that, two \sphinxcline in the same row
+ % will cause the second short rule to be shifted down
+ \ifx\@tempa\sphinxcline\let\@tempa\cmidrule\fi
+ \spx@original@@xcmidrule}%
+ \fi
+}
+% wrappers to allow customization, e.g. via a container class
+% the top, mid, bottom definitions are in fact overwritten (later, below)
+% byt more complex ones needed to handle booktabs+colorrows context
+\def\sphinxbooktabstoprule {\toprule}
+\def\sphinxbooktabsmidrule {\midrule}
+\def\sphinxbooktabsbottomrule{\bottomrule}
+%
+\let\sphinxbooktabscmidrule \@gobble % i.e. draw no short rules at all!
+% You can redefine this to use \cmidrule with various options, such
+% as \cmidrule(lr), but:
+% Attention, if you want this to use \cmidrule (or \cline) you must,
+% if the table uses row colours,
+% also include the \sphinxtabledecrementrownum token like e.g. this
+% \def\sphinxbooktabscmidrule{\sphinxtabledecrementrownum\cmidrule(lr)}
+% and it must be first due to internals of the \cmidrule usage of \futurelet.
+
+\def\sphinxthistablewithbooktabsstyle{%
+ \let\sphinxhline\@empty % there is no wrapper macro here so if you want to change that
+ % you will have to redefine \sphinxthistablewithbooktabsstyle
+ \def\sphinxcline {\sphinxbooktabscmidrule}% defaults to give \@gobble
+ \let\sphinxvlinecrossing\@gobble % no | in a booktabs-style table !
+ \let\sphinxfixclines \@gobble % should not be used with booktabs + \cmidrule
+ \def\spx@toprule {\sphinxbooktabstoprule}%
+ \def\sphinxmidrule {\sphinxbooktabsmidrule}%
+ \def\sphinxbottomrule{\sphinxbooktabsbottomrule}%
+ \def\spx@arrayrulewidth{\z@}%
+}
+\AtBeginDocument{\@ifpackageloaded{booktabs}%
+ {}%
+ {\def\sphinxthistablewithbooktabsstyle{%
+ \PackageWarning{sphinx}{%
+Add \string\usepackage{booktabs} to the preamble to allow\MessageBreak
+local use of booktabs table style}%
+ \sphinxbuildwarning{booktabs}%
+ \sphinxthistablewithstandardstyle
+ }}%
+}%
+
+% borderless style
+\def\sphinxthistablewithborderlessstyle{%
+ \let\sphinxhline \@empty
+ \let\sphinxcline \@gobble
+ \let\sphinxvlinecrossing\@gobble
+ \let\sphinxfixclines \@gobble
+ \let\spx@toprule \@empty
+ \let\sphinxmidrule \@empty
+ \let\sphinxbottomrule \@empty
+ \def\spx@arrayrulewidth{\z@}%
+}%
+
+% colorrows style
+%
+\let\sphinxifthistablewithcolorrowsTF\@secondoftwo
+\def\sphinxthistablewithcolorrowsstyle{%
+ \let\sphinxifthistablewithcolorrowsTF\@firstoftwo
+% this is defined to auto-silence itself (in the surrounding scope-limiting
+% environment) after one execution ("colorrows" can never follow "nocolorrows")
+ \let\sphinxthistablewithcolorrowsstyle\@empty
+%
+ \let\spx@table@toprule@rowcolorON \spx@table@@toprule@rowcolorON
+ \let\spx@table@startbodycolorrows \spx@table@@startbodycolorrows
+ \let\sphinxtabledecrementrownum \spx@table@@decrementrownum
+% Is it the best choice to "prepend" to existing code there?
+ \spx@prepend\spx@table@toprule@rowcolorON\to\sphinxtabletoprulehook
+ \spx@prepend\spx@table@startbodycolorrows\to\sphinxtableatstartofbodyhook
+%
+% this one is not set to \@empty by nocolorrows, because it looks harmless
+% to execute it always, as it simply resets to standard colortbl state after
+% the table; so we don't need an @@ version for this one
+ \spx@prepend\spx@table@resetcolortbl\to\sphinxtableafterendhook
+}
+\def\spx@prepend#1\to#2{% attention about using this only with #2 "storage macro"
+ \toks@{#1}%
+ \toks@\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks@#2}%
+ \edef#2{\the\toks@}%
+}%
+
+\def\sphinxthistablewithnocolorrowsstyle{%
+ \let\sphinxifthistablewithcolorrowsTF\@secondoftwo
+% rather than trying to remove the code added by 'colorrows' style, we
+% simply make it no-op, without even checking if really it was activated.
+ \let\spx@table@toprule@rowcolorON\@empty
+ \let\spx@table@startbodycolorrows\@empty
+ \let\sphinxtabledecrementrownum \@empty
+% we don't worry about \sphinxtableafterendhook as the \spx@table@resetcolortbl
+% done at end can not do harm; and we could also have not bothered with the
+% \sphinxtabledecrementrownum as its \rownum decrement, if active, is harmless
+% in non-colorrows context
+}
+
+% (not so easy) implementation of the booktabscolorgaps option. This option
+% defaults to true and is not officially documented, as already colorrows is
+% only opt-in, so it is there only as a "turn-off" switch, but if nobody
+% complains in next few months, it will probably be removed altogether at
+% 6.0.0. The reason it exists is because of longtable aspeces described
+% below.
+%
+% As it is used via \sphinxsetup booktabscolorgaps status is not known here
+% and may change locally. So it must be implemented via delayed or
+% conditional code.
+%
+% We do not know the order of execution of \sphinxthistablewithbooktabsstyle
+% versus \sphinxthistablewithcolorrows: if booktabs is global option it
+% will be executed first; but if colorrows is global option and not booktabs
+% then colorrows will be executed first via \sphinxthistablewithglobalstyle
+%
+% Modifying things from locations such as \sphinxtabletoprulehook which are
+% executed within the table is not convenient as it must use \global
+% but then we would have to undo this after the table.
+%
+% So what we do is to prepare booktabs specific macros to incorporate
+% a conditional to check the colorrows status. We must each time check
+% both if colorrows is activated and if colorgaps is. We do this via
+% macros without @ so they can be used easily in customization code.
+% When and if booktabscolorgaps option is removed, we can then replace
+% \sphinxifbooktabswithcolorgapsTF by \sphinxifthistablewithcolorrowsTF
+\def\sphinxifbooktabswithcolorgapsTF{%
+ \if1\ifspx@opt@booktabscolorgaps
+ \sphinxifthistablewithcolorrowsTF{1}{0}%
+ \else0\fi
+ \expandafter\@firstoftwo
+ \else\expandafter\@secondoftwo
+ \fi
+}
+% as this is done without "@" it can be relatively easily be overwritten
+% by user in customization code
+\def\sphinxbooktabstoprule{%
+ \sphinxifbooktabswithcolorgapsTF
+ {\sphinxbooktabsspecialtoprule}%
+ {\toprule}%
+}%
+\def\sphinxbooktabscolorgapsoverhang{0.1pt}% avoid pixel/rounding effects
+% auxiliary fork
+\long\def\spx@table@crazyfork
+ #1\endfirsthead\endhead\sphinxtableatstartofbodyhook#2#3\@nil{#2}
+% we fetch the next token to check if there is a header or not
+% this is a bit fragile as it relies on the table templates
+% and it assumes this token #1 is never braced...
+% let's make this \long in case #1 is \par (should not be)
+\long\def\sphinxbooktabsspecialtoprule\sphinxtabletoprulehook#1{%
+ \specialrule{\heavyrulewidth}{\abovetopsep}{\z@}%
+ % this macro contains colour init code (and defines sphinxTableRowColor)
+ \sphinxtabletoprulehook
+ % unfortunately colortbl provides no way to save/restore the
+ % \arrayrulecolor status, we have to code it ourselves
+ \noalign{\global\let\spx@@saved@CT@arc@\CT@arc@
+% \@declaredcolor is not \long. Although #1 can probably never be \par with
+% our templates, let's be cautious and not use the creazyfork inside the \color
+ \spx@table@crazyfork
+% this crazy code checks if #1 is one of \endfirsthead, \endhead or
+% \sphinxtableatstartofbodyhook, as criterion for table with no header
+ #1\endhead\sphinxtableatstartofbodyhook\@secondoftwo
+ \endfirsthead#1\sphinxtableatstartofbodyhook\@secondoftwo
+ \endfirsthead\endhead#1\@secondoftwo
+ \endfirsthead\endhead\sphinxtableatstartofbodyhook\@firstoftwo
+ \@nil
+ {\gdef\CT@arc@{\color{sphinxTableRowColor}}}%
+ {\gdef\CT@arc@{\color{sphinxTableRowColorOdd}}}%
+ }% end of \noalign
+ % \specialrule uses \noalign itself
+ \specialrule{\dimexpr\belowrulesep+\sphinxbooktabscolorgapsoverhang\relax}%
+ {\z@}{-\sphinxbooktabscolorgapsoverhang}%
+ \noalign{\global\let\CT@arc@\spx@@saved@CT@arc@}%
+ #1% let's not forget to re-insert this #1 in token stream
+ % fortunately longtable's \endfirsthead/\endhead are not delimiters but
+ % are really tokens awaiting expansion...
+}%
+\def\sphinxbooktabsmidrule{%
+ \sphinxifbooktabswithcolorgapsTF
+ {\sphinxbooktabsspecialmidrule}%
+ {\midrule}%
+}%
+\def\sphinxbooktabsspecialmidrule{%
+ \noalign{\global\let\spx@@saved@CT@arc@\CT@arc@
+ \gdef\CT@arc@{\color{sphinxTableRowColor}}% this is RowColorHeader
+ }%
+ \specialrule{\dimexpr\aboverulesep+\sphinxbooktabscolorgapsoverhang\relax\relax}%
+ {-\sphinxbooktabscolorgapsoverhang}{\z@}%
+ \noalign{\global\let\CT@arc@\spx@@saved@CT@arc@}%
+ \specialrule{\lightrulewidth}{\z@}{\z@}%
+ \noalign{\gdef\CT@arc@{\color{sphinxTableRowColorOdd}}}%
+ \specialrule{\dimexpr\belowrulesep+\sphinxbooktabscolorgapsoverhang\relax\relax}%
+ {\z@}{-\sphinxbooktabscolorgapsoverhang}%
+ \noalign{\global\let\CT@arc@\spx@@saved@CT@arc@}%
+}%
+\def\sphinxbooktabsbottomrule{%
+ \sphinxifbooktabswithcolorgapsTF
+ {\sphinxbooktabsspecialbottomrule}%
+ {\bottomrule}%
+}%
+% The colour here is already updated because of the \\ before so we must
+% execute again the colour selection code, but this is not too complicated.
+% What is annoying though is that \sphinxbottomrule in the longtable context
+% appears both in the "foot" part and after the last body row. For the first
+% occurrence the \rownum could be arbitrary if it had not been reset by each
+% table using it via the \sphinxtableafterendhook (see above). This avoids
+% having to modify the longtable template. But as \rownum is thus 0 in the
+% "foot", the \sphinxSwitchCaseRowColor has to know how to handle negative
+% inputs (in fact the -1 value), the Sphinx definition has no issue with that
+% but any redefinition must be aware of this constraint.
+\def\sphinxbooktabsspecialbottomrule{%
+ \noalign{\global\let\spx@@saved@CT@arc@\CT@arc@
+ \sphinxSwitchCaseRowColor{\numexpr\rownum-\@ne\relax}%
+ \gdef\CT@arc@{\color{sphinxTableRowColor}}%
+ }%
+ \specialrule{\dimexpr\aboverulesep+\sphinxbooktabscolorgapsoverhang\relax}%
+ {-\sphinxbooktabscolorgapsoverhang}{\z@}%
+ \noalign{\global\let\CT@arc@\spx@@saved@CT@arc@}%
+ \specialrule{\heavyrulewidth}{\z@}{\belowbottomsep}%
+}%
+%
+% MEMO: with longtable \sphinxtoprule, \sphinxmidrule and \sphinxbottomrule
+% are evaluated at time of constructing the headers and footers as boxes
+% (already typeset material and expanded macros; \sphinxbottomrule is also
+% evaluated at very end of table body, i.e. "normally"). So the used colour
+% to fill the booktabs gaps is decided during the headers and footers
+% construction by longtable. Actually they are expanded twice: in firsthead
+% then in head, respectively in foot and lastfoot. But in current design the
+% header row colours are fixed, not alternating, so there is at least no
+% coherence issue there.
+
+% The \spx@arrayrulewidth is used for some complex matters of merged
+% cells size computations.
+% tabularcolumns argument will override any global or local style and
+% trigger the appropriate adjustment of \spx@arrayrulewidth.
+% Notice that this will be bad if the table uses booktabs style
+% but anyhow table with booktabs should not use any | separator.
+\def\sphinxthistablewithvlinesstyle{%
+ \def\spx@arrayrulewidth{\arrayrulewidth}%
+ \let\sphinxvlinecrossing\sphinxtablevlinecrossing
+ \let\sphinxfixclines \sphinxtablefixclines
+}%
+\def\sphinxthistablewithnovlinesstyle{%
+ \def\spx@arrayrulewidth{\z@}%
+ \let\sphinxvlinecrossing\@gobble
+ % let's not bother to modify \sphinxfixclines, it works fine and is
+ % useful in standard style + no vline (only hlines and clines);
+ % besides, only one of vline or novline style macro is executed
+}%
+
+% default is the standard style
+\def\sphinxthistablewithglobalstyle{\sphinxthistablewithstandardstyle}
+
+\ifspx@opt@booktabs
+ \RequirePackage{booktabs}
+ \def\sphinxthistablewithglobalstyle{\sphinxthistablewithbooktabsstyle}
+\fi
+\ifspx@opt@borderless
+ \def\sphinxthistablewithglobalstyle{\sphinxthistablewithborderlessstyle}
+\fi
+% colorrows appends to the current globalstyle (standard, booktabs, or borderless)
+\ifspx@opt@colorrows % let the globalstyle trigger the colorrows style on top of it
+ \expandafter\def\expandafter\sphinxthistablewithglobalstyle\expandafter
+ {\sphinxthistablewithglobalstyle
+ \sphinxthistablewithcolorrowsstyle
+ }
+\fi
+
+
+\endinput
diff --git a/sphinx/texinputs/sphinxmanual.cls b/sphinx/texinputs/sphinxmanual.cls
new file mode 100644
index 0000000..2e4b30d
--- /dev/null
+++ b/sphinx/texinputs/sphinxmanual.cls
@@ -0,0 +1,128 @@
+%
+% sphinxmanual.cls for Sphinx (https://www.sphinx-doc.org/)
+%
+
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesClass{sphinxmanual}[2019/12/01 v2.3.0 Document class (Sphinx manual)]
+
+% chapters starting at odd pages (overridden by 'openany' document option)
+\PassOptionsToClass{openright}{\sphinxdocclass}
+
+% 'oneside' option overriding the 'twoside' default
+\newif\if@oneside
+\DeclareOption{oneside}{\@onesidetrue}
+% Pass remaining document options to the parent class.
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}}
+\ProcessOptions\relax
+
+% Defaults two-side document
+\if@oneside
+% nothing to do (oneside is the default)
+\else
+\PassOptionsToClass{twoside}{\sphinxdocclass}
+\fi
+
+\LoadClass{\sphinxdocclass}
+
+% Set some sane defaults for section numbering depth and TOC depth. You can
+% reset these counters in your preamble.
+%
+\setcounter{secnumdepth}{2}
+\setcounter{tocdepth}{1}
+
+% Adapt \and command to the flushright context of \sphinxmaketitle, to
+% avoid ragged line endings if author names do not fit all on one single line
+\DeclareRobustCommand{\and}{%
+ \end{tabular}\kern-\tabcolsep
+ \allowbreak
+ \hskip\dimexpr1em+\tabcolsep\@plus.17fil\begin{tabular}[t]{c}%
+}%
+% If it is desired that each author name be on its own line, use in preamble:
+%\DeclareRobustCommand{\and}{%
+% \end{tabular}\kern-\tabcolsep\\\begin{tabular}[t]{c}%
+%}%
+% Change the title page to look a bit better, and fit in with the fncychap
+% ``Bjarne'' style a bit better.
+%
+\newcommand{\sphinxmaketitle}{%
+ \let\sphinxrestorepageanchorsetting\relax
+ \ifHy@pageanchor\def\sphinxrestorepageanchorsetting{\Hy@pageanchortrue}\fi
+ \hypersetup{pageanchor=false}% avoid duplicate destination warnings
+ \begin{titlepage}%
+ \let\footnotesize\small
+ \let\footnoterule\relax
+ \noindent\rule{\textwidth}{1pt}\par
+ \begingroup % for PDF information dictionary
+ \def\endgraf{ }\def\and{\& }%
+ \pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup
+ \hypersetup{pdfauthor={\@author}, pdftitle={\@title}}%
+ \endgroup
+ \begin{flushright}%
+ \sphinxlogo
+ \py@HeaderFamily
+ {\Huge \@title \par}
+ {\itshape\LARGE \py@release\releaseinfo \par}
+ \vfill
+ {\LARGE
+ \begin{tabular}[t]{c}
+ \@author
+ \end{tabular}\kern-\tabcolsep
+ \par}
+ \vfill\vfill
+ {\large
+ \@date \par
+ \vfill
+ \py@authoraddress \par
+ }%
+ \end{flushright}%\par
+ \@thanks
+ \end{titlepage}%
+ \setcounter{footnote}{0}%
+ \let\thanks\relax\let\maketitle\relax
+ %\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
+ \clearpage
+ \ifdefined\sphinxbackoftitlepage\sphinxbackoftitlepage\fi
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \sphinxrestorepageanchorsetting
+}
+
+\newcommand{\sphinxtableofcontents}{%
+ \pagenumbering{roman}%
+ \begingroup
+ \parskip \z@skip
+ \sphinxtableofcontentshook
+ \tableofcontents
+ \endgroup
+ % before resetting page counter, let's do the right thing.
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \pagenumbering{arabic}%
+}
+
+% This is needed to get the width of the section # area wide enough in the
+% library reference. Doing it here keeps it the same for all the manuals.
+%
+\newcommand{\sphinxtableofcontentshook}{%
+ \renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}}%
+ \renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}}%
+}
+
+% Fix the bibliography environment to add an entry to the Table of
+% Contents.
+% For a report document class this environment is a chapter.
+%
+\newenvironment{sphinxthebibliography}[1]{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ % \phantomsection % not needed here since TeXLive 2010's hyperref
+ \begin{thebibliography}{#1}%
+ \addcontentsline{toc}{chapter}{\bibname}}{\end{thebibliography}}
+
+% Same for the indices.
+% The memoir class already does this, so we don't duplicate it in that case.
+%
+\@ifclassloaded{memoir}
+ {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}
+ {\newenvironment{sphinxtheindex}{%
+ \if@openright\cleardoublepage\else\clearpage\fi
+ \phantomsection % needed as no chapter, section, ... created
+ \begin{theindex}%
+ \addcontentsline{toc}{chapter}{\indexname}}{\end{theindex}}}
diff --git a/sphinx/texinputs/sphinxoptionsgeometry.sty b/sphinx/texinputs/sphinxoptionsgeometry.sty
new file mode 100644
index 0000000..af5a804
--- /dev/null
+++ b/sphinx/texinputs/sphinxoptionsgeometry.sty
@@ -0,0 +1,54 @@
+%% OPTIONS FOR GEOMETRY
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxoptionsgeometry.sty}[2021/01/27 geometry]
+
+% 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
+
+\endinput
diff --git a/sphinx/texinputs/sphinxoptionshyperref.sty b/sphinx/texinputs/sphinxoptionshyperref.sty
new file mode 100644
index 0000000..b88f108
--- /dev/null
+++ b/sphinx/texinputs/sphinxoptionshyperref.sty
@@ -0,0 +1,35 @@
+%% Bookmarks and hyperlinks
+%
+% change this info string if making any custom modification
+\ProvidesFile{sphinxoptionshyperref.sty}[2021/01/27 hyperref]
+
+% 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 overridden inside 'hyperref' key
+% or by later use of \hypersetup.
+\PassOptionsToPackage{colorlinks,breaklinks,%
+ linkcolor=InnerLinkColor,filecolor=OuterLinkColor,%
+ menucolor=OuterLinkColor,urlcolor=OuterLinkColor,%
+ citecolor=InnerLinkColor}{hyperref}
+
+\endinput
diff --git a/sphinx/texinputs/sphinxpackageboxes.sty b/sphinx/texinputs/sphinxpackageboxes.sty
new file mode 100644
index 0000000..b0d3707
--- /dev/null
+++ b/sphinx/texinputs/sphinxpackageboxes.sty
@@ -0,0 +1,854 @@
+%% COLOURED BOXES
+%
+% change this info string if making any custom modification
+\ProvidesPackage{sphinxpackageboxes}[2023/03/19 v6.2.0 advanced colored boxes]
+% Optionally executes \RequirePackage for:
+%
+% - pict2e. Ideally we would like to use the v0.4a 2020/08/16 release of this
+% package as it allows dimensional arguments to its \moveto, \lineto, etc...
+% Or we could use extra package "picture". We opt for custom wrappers
+% \spx@moveto, \spx@lineto, ..., working with old versions.
+%
+% - ellipse. This package extends pict2e with elliptical arcs. Its author
+% Daan Leijen also has contributed package longfbox which is part of
+% TeXLive. Had I known about it, I would perhaps have based Sphinx CSS on
+% top of longfbox at least partly. But this would not have spared me all
+% the work in sphinx.sty, which was a long walk until 6.2.0 version.
+% Besides I don't need the breakable boxes from longfbox, as Sphinx has
+% its own rather advanced layer on top of framed. I would need to check if
+% some thorny color issues solved by Sphinx (and not by tcolorbox) at page
+% breaks are solved by longfbox as well. (I have not tested)
+
+% At 6.2.0 refactoring, we do not wait for at begin document to try to load
+% pict2e. Actually since 6.0.0 the default is for code-blocks to use
+% rounded boxes, and the only reason since then to wait "at begin document"
+% was to check if user had reverted that default and in fact pict2e was not
+% needed. But with \sphinxbox, we can not know for sure even in that case
+% that pict2e is not needed. And even back then it would have been possible
+% to user to try to employ \sphinxsetup via raw directive in document body
+% and require some rounded corners (which was thus impossible to satisfy).
+% Time to be much simpler and attempt unconditionally to load pict2e
+% immediately. This will also have advantage that we can use
+% \@ifpackageloaded{pict2e} and not have to query and save its setting later
+% at begin document.
+\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%
+ }%
+ % Formerly a \sphinxbuildwarning was issued but if we did that now it
+ % would mean that the produced PDF will always have a red banner near its
+ % end about pict2e not being available if indeed it is not available, even
+ % if user has reverted the default and dropped rounded corners. Formerly
+ % the serious warning was done after having checked at begin document that
+ % indeed a rounded corner option had been used. As we drop the check now,
+ % let's be more discrete and simply duplicate the earlier warning to make
+ % it visible near end of compilation log and console output.
+ \AtEndDocument{\PackageWarningNoLine{sphinx}{%
+ The package pict2e is required for rounded boxes.\MessageBreak
+ As it does not seem to be available on your system,\MessageBreak
+ options setting radii have all been ignored}}%
+ }%
+
+\IfFileExists{ellipse.sty}
+ {\RequirePackage{ellipse}}
+ {\PackageWarningNoLine{sphinx}{%
+ The package ellipse is required for elliptical corners.\MessageBreak
+ It does not seem to be available on your system.\MessageBreak
+ All non-straight corners will use circle arcs.%
+ }%
+ \AtEndDocument{\PackageWarningNoLine{sphinx}{%
+ The package ellipse is required for elliptical corners.\MessageBreak
+ As it does not seem to be available on your system,\MessageBreak
+ all non-straight corners have used circle arcs.}}%
+ }%
+
+% The pict2e release v0.4b of 2020/09/30 does not allocate scratch dimen
+% register \@tempdimd which ellipse package uses. Thus ellipse package is
+% broken since (written on March 20, 2023). Simply allocate the register
+% ourself to fix that, pending some upstream fix.
+\@ifpackageloaded{ellipse}{\ifdefined\@tempdimd\else\newdimen\@tempdimd\fi}{}
+
+% Provides box registers \spx@tempboxa, \spx@tempboxb usable in other places
+\newbox\spx@tempboxa
+\newbox\spx@tempboxb
+
+%%%%%%%%%%%%%%%%
+% Internal registers, conditionals, colors to be configured by each caller
+% via a preliminary "setup" call
+%
+\newif\ifspx@boxes@withshadow
+\newif\ifspx@boxes@insetshadow
+\newif\ifspx@boxes@withbackgroundcolor
+\newif\ifspx@boxes@withshadowcolor
+\newif\ifspx@boxes@withbordercolor
+\newif\ifspx@boxes@shadowinbbox
+%
+\newdimen\spx@boxes@border
+\newdimen\spx@boxes@border@top
+\newdimen\spx@boxes@border@right
+\newdimen\spx@boxes@border@bottom
+\newdimen\spx@boxes@border@left
+%
+\newdimen\spx@boxes@padding@top
+\newdimen\spx@boxes@padding@right
+\newdimen\spx@boxes@padding@bottom
+\newdimen\spx@boxes@padding@left
+%
+\newdimen\spx@boxes@shadow@xoffset
+\newdimen\spx@boxes@shadow@yoffset
+%
+\newdimen\spx@boxes@radius@topleft@x
+\newdimen\spx@boxes@radius@topright@x
+\newdimen\spx@boxes@radius@bottomright@x
+\newdimen\spx@boxes@radius@bottomleft@x
+\newdimen\spx@boxes@radius@topleft@y
+\newdimen\spx@boxes@radius@topright@y
+\newdimen\spx@boxes@radius@bottomright@y
+\newdimen\spx@boxes@radius@bottomleft@y
+%
+% These colors will be set to colors defined appropriately by caller of
+% \spx@boxes@fcolorbox@setup macro
+% spx@boxes@bordercolor
+% spx@boxes@backgroundcolor
+% spx@boxes@shadowcolor
+% spx@boxes@textcolor
+
+%%%%%%%%%%%%%%%%
+% "setup" macro
+%
+% It must be called prior to \spx@boxes@fcolorbox for parameters of the latter
+% to be initialized.
+%
+% It also prepares \spx@boxes@fcolorbox to expand to one of
+% \spx@boxes@fcolorbox@rectangle or \spx@boxes@fcolorbox@rounded depending on
+% the configuration and availability of the pict2e package.
+%
+% The #1 is one of: pre, topic, warning, danger, etc....
+%
+% We delay until here the parsing of radii options to extract x and y
+% components.
+\def\spx@boxes@setradii#1 #2 #3\@nnil#4#5{%
+ #4\dimexpr#1\relax
+ #5\dimexpr#2\relax
+ \ifdim#5=-\maxdimen#5#4\fi
+ % if one of them is zero or negative set both to zero
+ \ifdim#4>\z@\else#4\z@#5\z@\fi
+ \ifdim#5>\z@\else#4\z@#5\z@\fi
+}%
+% if ellipse.sty is not available ignore the second component of all radii
+% specifications, use circle arcs with radius the x component
+\@ifpackageloaded{ellipse}
+ {}
+ {\def\spx@boxes@setradii#1 #2 #3\@nnil#4#5{#4\dimexpr#1\relax #5#4}}
+
+% Using \dimexpr for maximal user input flexibility.
+\def\spx@boxes@fcolorbox@setup#1{%
+ \spx@boxes@border@top \dimexpr\@nameuse{spx@#1@border@top}\relax
+ \spx@boxes@border@right \dimexpr\@nameuse{spx@#1@border@right}\relax
+ \spx@boxes@border@bottom\dimexpr\@nameuse{spx@#1@border@bottom}\relax
+ \spx@boxes@border@left \dimexpr\@nameuse{spx@#1@border@left}\relax
+ \spx@boxes@border \dimexpr\@nameuse{spx@#1@border}\relax
+ %
+ \spx@boxes@padding@top \dimexpr\@nameuse{spx@#1@padding@top}\relax
+ \spx@boxes@padding@right \dimexpr\@nameuse{spx@#1@padding@right}\relax
+ \spx@boxes@padding@bottom\dimexpr\@nameuse{spx@#1@padding@bottom}\relax
+ \spx@boxes@padding@left \dimexpr\@nameuse{spx@#1@padding@left}\relax
+ %
+ \edef\spx@temp{\csname spx@#1@radius@topleft\endcsname\space}%
+ \expandafter
+ \spx@boxes@setradii
+ \spx@temp
+ {-\maxdimen}
+ \@nnil
+ \spx@boxes@radius@topleft@x\spx@boxes@radius@topleft@y
+ \edef\spx@temp{\csname spx@#1@radius@topright\endcsname\space}%
+ \expandafter
+ \spx@boxes@setradii
+ \spx@temp
+ {-\maxdimen}
+ \@nnil
+ \spx@boxes@radius@topright@x\spx@boxes@radius@topright@y
+ \edef\spx@temp{\csname spx@#1@radius@bottomright\endcsname\space}%
+ \expandafter
+ \spx@boxes@setradii
+ \spx@temp
+ {-\maxdimen}
+ \@nnil
+ \spx@boxes@radius@bottomright@x\spx@boxes@radius@bottomright@y
+ \edef\spx@temp{\csname spx@#1@radius@bottomleft\endcsname\space}%
+ \expandafter
+ \spx@boxes@setradii
+ \spx@temp
+ {-\maxdimen}
+ \@nnil
+ \spx@boxes@radius@bottomleft@x\spx@boxes@radius@bottomleft@y
+ %
+ \@nameuse{ifspx@#1@withshadow}%
+ \spx@boxes@withshadowtrue
+ \spx@boxes@shadow@xoffset \dimexpr\@nameuse{spx@#1@shadow@xoffset}\relax
+ \spx@boxes@shadow@yoffset \dimexpr\@nameuse{spx@#1@shadow@yoffset}\relax
+ \else
+ \spx@boxes@withshadowfalse
+ \fi
+ % not nesting in previous to avoid TeX conditional subtleties
+ \@nameuse{ifspx@#1@insetshadow}%
+ \spx@boxes@insetshadowtrue
+ \else
+ \spx@boxes@insetshadowfalse
+ \fi
+ %
+ \@nameuse{ifspx@#1@withbordercolor}%
+ \spx@boxes@withbordercolortrue
+ \sphinxcolorlet{spx@boxes@bordercolor}{sphinx#1BorderColor}%
+ \else
+ \spx@boxes@withbordercolorfalse
+ \fi
+ %
+ \@nameuse{ifspx@#1@withbackgroundcolor}%
+ \spx@boxes@withbackgroundcolortrue
+ \sphinxcolorlet{spx@boxes@backgroundcolor}{sphinx#1BgColor}%
+ \else
+ \spx@boxes@withbackgroundcolorfalse
+ \fi
+ %
+ \@nameuse{ifspx@#1@withshadowcolor}%
+ \spx@boxes@withshadowcolortrue
+ \sphinxcolorlet{spx@boxes@shadowcolor}{sphinx#1ShadowColor}%
+ \else
+ \spx@boxes@withshadowcolorfalse
+ \fi
+ % Display elements pre, topic, warning et al. by default do not include
+ % shadow in box (legacy; and only topic actually uses a shadow per default)
+ % This may be refactored still more in future, but this 6.2.0 extra helped
+ % reduce workload from code-blocks (pre), contents (topic) and admonitions.
+ % As this conditional is a priori false and should only be changed locally
+ % (by \sphinxbox), this line is actually superfluous.
+ \spx@boxes@shadowinbboxfalse
+ \spx@boxes@fcolorbox@setup@fcolorbox
+}
+\@ifpackageloaded{pict2e}
+{% pict2e is available and loaded
+ \def\spx@boxes@fcolorbox@setup@fcolorbox{%
+ \if1% use rounded boxes only if needed (rx>0 iff ry>0)
+ \ifdim\spx@boxes@radius@topleft@x >\z@0\fi
+ \ifdim\spx@boxes@radius@topright@x >\z@0\fi
+ \ifdim\spx@boxes@radius@bottomright@x>\z@0\fi
+ \ifdim\spx@boxes@radius@bottomleft@x >\z@0\fi
+ 1\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}%
+ \else
+ \def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rounded}%
+ \fi
+ }% end of definition of setup@fcolorbox in case of presence of pict2e
+}%
+{% pict2e could not be loaded, we must always use fcolorbox@rectangle
+ \def\spx@boxes@fcolorbox@setup@fcolorbox{%
+ \def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}%
+ }% end of definition of setup@fcolorbox in case of absence of pict2e
+}% end of "no pict2e" branch
+
+%%%%%%%%%%%%%%%%
+% Support of box-decoration-break=slice
+%
+% 6.2.0 has renamed and moved this here from sphinxlatexliterals.sty,
+% to facilitate supporting box-decoration-break=slice for all directives,
+% not only code-block.
+%
+% It also modified when these post actions are executed, in order
+% for openboth to be able to trigger usage of fcolorbox@rectangle.
+% So now openbottom and opentop also take advantage of this possible
+% optimization.
+\def\spx@boxes@fcolorbox@setup@openbottom{%
+ \spx@boxes@border@bottom \z@
+ \spx@boxes@radius@bottomright@x\z@ \spx@boxes@radius@bottomright@y\z@
+ \spx@boxes@radius@bottomleft@x \z@ \spx@boxes@radius@bottomleft@y \z@
+ \spx@boxes@fcolorbox@setup@fcolorbox
+}%
+\def\spx@boxes@fcolorbox@setup@opentop{%
+ \spx@boxes@border@top \z@
+ \spx@boxes@radius@topright@x\z@ \spx@boxes@radius@topright@y\z@
+ \spx@boxes@radius@topleft@x \z@ \spx@boxes@radius@topleft@y \z@
+ \spx@boxes@fcolorbox@setup@fcolorbox
+}%
+\def\spx@boxes@fcolorbox@setup@openboth{%
+ \spx@boxes@border@top \z@
+ \spx@boxes@border@bottom \z@
+ \spx@boxes@radius@bottomright@x\z@ \spx@boxes@radius@bottomright@y\z@
+ \spx@boxes@radius@bottomleft@x \z@ \spx@boxes@radius@bottomleft@y \z@
+ \spx@boxes@radius@topright@x\z@ \spx@boxes@radius@topright@y\z@
+ \spx@boxes@radius@topleft@x \z@ \spx@boxes@radius@topleft@y \z@
+ \def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}%
+}%
+
+%%%%%%%%%%%%%%%%
+% \sphinxbox (added at 6.2.0)
+%
+% For an inline box, possibly rounded.
+\newcommand\sphinxbox[1][]{% #1 stands for the options, they are... optional!
+ % \leavevmode makes sure TeX switches to paragraph mode, which is necessary
+ % if this is first in a paragraph or a list element. The \sphinxAtStartPar
+ % mechanism also ensures this automatically, if not redefined, but not with
+ % lualatex as then it is by default doing nothing.
+ \leavevmode
+ \begingroup
+ \ifcsname spx@boxes@sphinxbox@isnested\endcsname
+ % nested boxes reset all box options to be as the \sphinxboxsetup
+ % defaults, before applying their specific options
+ \spx@boxes@sphinxbox@reset
+ \else
+ % top layer box, toggle the nested flag
+ \csname spx@boxes@sphinxbox@isnested\endcsname
+ \fi
+ % we do not use \sphinxboxsetup as it is a user command extending the
+ % "reset" storage
+ \setkeys{sphinxbox}{#1}%
+ \spx@boxes@fcolorbox@setup{box}%
+ \spx@boxes@shadowinbboxtrue% inline sphinx boxes include shadow in bbox
+ \ifspx@box@withtextcolor\color{sphinxboxTextColor}\fi
+ %
+ % MEMO: the fcolorbox@{rectangle,rounded} draw the contents (which here
+ % will be encapsulated as \box\z@) last, i.e. after shadow, background,
+ % and border and their color commands. The \reset@color from naked
+ % top-level \color commands in argument (which can not arise from Sphinx
+ % mark-up anyhow) would end up being placed via color.sty \aftergroup core
+ % mechanism in token stream after \spx@boxes@sphinxbox@a (which is the
+ % first \aftergroup) hence after the box contents with its unbalanced
+ % color pushes is shipped to PDF. So the missing color pop specials are
+ % inserted then in correct order at correct place (after the \endgroup at
+ % end of \spx@boxes@sphinxbox@a but this is not relevant) and do not end
+ % up causing havoc in push/pop pairs (and all this happens on same page).
+ %
+ % There is thus no reason here to go to the trouble to add an extra
+ % \color@begingroup/\color@endgroup or like pair to encapsulate the caught
+ % contents in order for the \box\z@ to contain as many color pop's as it
+ % has color pushes. But as this is subtle, this comment was added for
+ % future maintenance. Actually even if the contents were not drawn last,
+ % their (purely theoretical, as Sphinx mark-up can not create it) missing
+ % color pop's would not have caused trouble I guess as long as the color
+ % insertions for shadow, background, border are correctly balanced.
+ \setbox0\hbox\bgroup\aftergroup\spx@boxes@sphinxbox@a
+ \afterassignment\spx@box@TeXextras
+ \let\next=%
+}
+\def\spx@boxes@sphinxbox@a{\spx@boxes@fcolorbox{%
+ \ifspx@opt@box@addstrut\strut\fi\box\z@}\endgroup}
+
+\newcommand\newsphinxbox[2][]{%
+ \newcommand#2[1][]{\sphinxbox[#1,##1]}%
+}
+% Let's catch \renewsphinxbox[...]{\sphinxbox} which would cause \sphinxbox
+% to fall into infinite looping on use.
+\newcommand\renewsphinxbox[2][]{%
+ \in@{#2}{\sphinxbox}%
+ \ifin@
+ \PackageWarning{sphinx}{Attempt to \string\renewsphinxbox\space
+ the \string\sphinxbox\space command\MessageBreak
+ itself. This is not allowed and will be ignored.\MessageBreak
+ Reported}%
+ \else
+ \renewcommand#2[1][]{\sphinxbox[#1,##1]}%
+ \fi
+}
+
+%%%%%%%%%%%%%%%%
+% MACROS
+%
+% \spx@boxes@fcolorbox expands either to \spx@boxes@fcolorbox@rectangle
+% or \spx@boxes@fcolorbox@rounded depending on preliminary set-up.
+%
+% This is decided by the "setup" which must have been executed by the caller.
+% Let's give it some (thus unneeded) default fall-back for clarity.
+\def\spx@boxes@fcolorbox{\spx@boxes@fcolorbox@rectangle}
+%
+% A macro \spx@boxes@fcolorbox@setuphook used to be executed at start of the
+% \hbox constructs (rectangle or rounded). This was used until 6.2.0 for the
+% support of pre_box-decoration-break option, hence was really an internal
+% non-public macro. As it is not needed anymore, with some hesitation it got
+% entirely removed at 6.2.0 on the occasion of a refactoring of interactions of
+% this file with sphinxlatexliterals.sty. Besides its name should have been
+% rather something such as \spx@boxes@fcolorbox@atstartofhbox.
+%
+% After "setup", \spx@boxes@fcolorbox expands to one of:
+%
+% - \spx@boxes@fcolorbox@rectangle (4 padding parameters, 4 border widths, 2 shadow widths,
+% and three colours: background, border and shadow; same as in CSS styling)
+%
+% It branches to one of:
+% - \spx@boxes@fcolorbox@externalshadow
+% - \spx@boxes@fcolorbox@insetshadow (same concept of "inset" as in CSS styling)
+%
+% - \spx@boxes@fcolorbox@rounded: rounded corners using the picture environment
+% and pict2e package for its low-weight interface to PDF graphics operations
+
+% MEMO: we have also successfully tested usage of tcolorbox.sty (its \tcbox) but
+% decided to use pict2e.sty for the following reasons:
+% 1- PDF build was observed to be an order of magnitude faster,
+% 2- the boxes we can do with pict2e appear to be fancy enough,
+% almost matching what one can see in HTML renderings,
+% 2- orders of magnitude smaller dependency (tcolorbox uses the pgf TeX
+% framework), although on Ubuntu it seems texlive-pictures is
+% needed which also contains the whole of pgf/TikZ... so this point
+% is a bit moot...
+
+% For code-blocks, attachments of caption and continuation hints are done
+% exactly as prior to extension of Sphinx via this package, whether the box
+% has straight or rounded corners. The vertical space occupied is the same,
+% if nothing else is changed (perhaps in future the title itself could be also
+% rendered in a rounded box?)
+
+%%%%%%%%
+%//// \spx@boxes@fcolorbox@rectangle
+%
+% This box will have the same baseline as its argument (which is typeset in
+% horizontal mode). It takes into account four border widths parameters, four
+% padding parameters, two shadow widths (each possibly negative), and three
+% colors: background, border and shadow. Its boundary box takes into account
+% border and padding. Width of shadow is taken into account if the boolean
+% \ifspx@boxes@shadowinbbox is \iftrue. The "setup" sets it to \iffalse.
+% Prior to 6.2.0, shadow size was included in bbox but the callers manually
+% removed it by extra steps. The \sphinxbox command sets it to \iftrue after
+% the "setup".
+%
+% It is up to the caller to take extra steps if the border and padding must go
+% into margin as well (see sphinxlatexliterals.sty for how this is done in
+% \spx@verb@FrameCommand).
+%
+% In usage as a "FrameCommand" with framed.sty, the argument will already be a
+% collection of TeX boxes (and interline glues).
+%
+% This was designed so that the parameters configured by "setup" are
+% interpreted as they would be as CSS properties in an HTML context.
+\long\def\spx@boxes@fcolorbox@rectangle#1{%
+ \hbox\bgroup
+ \setbox\spx@tempboxa
+ \hbox{\kern\dimexpr\spx@boxes@border@left+\spx@boxes@padding@left\relax
+ {#1}%
+ \kern\dimexpr\spx@boxes@padding@right+\spx@boxes@border@right\relax}%
+ \ht\spx@tempboxa
+ \dimexpr\ht\spx@tempboxa+\spx@boxes@border@top+\spx@boxes@padding@top\relax
+ \dp\spx@tempboxa
+ \dimexpr\dp\spx@tempboxa+\spx@boxes@padding@bottom+\spx@boxes@border@bottom\relax
+ \ifspx@boxes@insetshadow
+ \expandafter\spx@boxes@fcolorbox@insetshadow
+ \else
+ \expandafter\spx@boxes@fcolorbox@externalshadow
+ \fi
+}
+
+% external shadow
+\def\spx@boxes@fcolorbox@externalshadow{%
+ % reserve space to external shadow if on left
+ \ifspx@boxes@withshadow
+ \ifspx@boxes@shadowinbbox
+ \ifdim\spx@boxes@shadow@xoffset<\z@\kern-\spx@boxes@shadow@xoffset\fi
+ \fi
+ \fi
+ % BACKGROUND
+ % draw background and move back to reference point
+ \ifspx@boxes@withbackgroundcolor
+ {\color{spx@boxes@backgroundcolor}%
+ \vrule\@height\ht\spx@tempboxa
+ \@depth\dp\spx@tempboxa
+ \@width\wd\spx@tempboxa
+ \kern-\wd\spx@tempboxa
+ }%
+ \fi
+ % BOX SHADOW
+ % draw shadow and move back to reference point
+ \ifspx@boxes@withshadow
+ \vbox{%
+ \moveright\spx@boxes@shadow@xoffset
+ \hbox{\lower\spx@boxes@shadow@yoffset
+ \vbox{\ifspx@boxes@withshadowcolor
+ \color{spx@boxes@shadowcolor}%
+ \else
+ % 6.2.0: guard against a manually inserted \color command in
+ % contents which could leak at a page break to the shadow
+ \normalcolor
+ \fi
+ \ifdim\spx@boxes@shadow@yoffset<\z@
+ \hrule\@height-\spx@boxes@shadow@yoffset
+ \kern\spx@boxes@shadow@yoffset
+ \fi
+ \setbox\spx@tempboxb\hb@xt@\wd\spx@tempboxa{%
+ \ifdim\spx@boxes@shadow@xoffset<\z@\vrule\@width-\spx@boxes@shadow@xoffset\fi
+ \hss
+ \ifdim\spx@boxes@shadow@xoffset>\z@\vrule\@width\spx@boxes@shadow@xoffset\fi
+ }%
+ \ht\spx@tempboxb\ht\spx@tempboxa
+ \dp\spx@tempboxb\dp\spx@tempboxa
+ \box\spx@tempboxb
+ \ifdim\spx@boxes@shadow@yoffset>\z@
+ \kern-\spx@boxes@shadow@yoffset
+ \hrule\@height\spx@boxes@shadow@yoffset
+ \fi
+ \kern-\dp\spx@tempboxa
+ }% end of \vbox, attention it will have zero depth if yoffset>0
+ \kern-\wd\spx@tempboxa
+ \ifdim\spx@boxes@shadow@xoffset>\z@
+ \kern-\spx@boxes@shadow@xoffset
+ \fi
+ }% end of \hbox, attention its depth is only yoffset if yoffset>0
+ }% end of \vbox
+ \fi % end of shadow drawing, and we are back to horizontal reference point
+ % BOX BORDER
+ \vbox{\ifspx@boxes@withbordercolor
+ \color{spx@boxes@bordercolor}%
+ \else
+ % 6.2.0: guard against a \color command in contents whose effect
+ % could leak to border at a pagebreak
+ \normalcolor
+ \fi
+ \hrule\@height\spx@boxes@border@top
+ \kern-\spx@boxes@border@top
+ \setbox\spx@tempboxb\hb@xt@\wd\spx@tempboxa
+ {\vrule\@width\spx@boxes@border@left
+ \hss\vrule\@width\spx@boxes@border@right
+ }%
+ \ht\spx@tempboxb\ht\spx@tempboxa
+ \dp\spx@tempboxb\dp\spx@tempboxa
+ \box\spx@tempboxb
+ \kern-\spx@boxes@border@bottom
+ \hrule\@height\spx@boxes@border@bottom
+ \kern-\dp\spx@tempboxa
+ }% attention this box has zero depth due to \hrule at bottom
+ % step back to horizontal reference point
+ \kern-\wd\spx@tempboxa
+ % end of border drawing
+ % CONTENTS
+ % adjust the total depth to include the bottom shadow
+ \ifspx@boxes@withshadow
+ \ifdim\spx@boxes@shadow@yoffset>\z@
+ \dp\spx@tempboxa\dimexpr\dp\spx@tempboxa+\spx@boxes@shadow@yoffset\relax
+ \fi
+ \fi
+ \box\spx@tempboxa
+ % include lateral shadow in total width
+ \ifspx@boxes@withshadow
+ \ifspx@boxes@shadowinbbox
+ \ifdim\spx@boxes@shadow@xoffset>\z@\kern\spx@boxes@shadow@xoffset\fi
+ \fi
+ \fi
+ \egroup
+}
+
+% inset shadow
+%
+% The parameters signs are interpreted as in CSS styling.
+\def\spx@boxes@fcolorbox@insetshadow{%
+ % BACKGROUND
+ % draw background and move back to reference point
+ \ifspx@boxes@withbackgroundcolor
+ {\color{spx@boxes@backgroundcolor}%
+ \vrule\@height\ht\spx@tempboxa
+ \@depth\dp\spx@tempboxa
+ \@width\wd\spx@tempboxa
+ \kern-\wd\spx@tempboxa
+ }%
+ \fi
+ % BOX SHADOW
+ % draw shadow and move back to reference point
+ \ifspx@boxes@withshadow
+ \hbox{\vbox{\ifspx@boxes@withshadowcolor
+ \color{spx@boxes@shadowcolor}%
+ \else
+ % 6.2.0: guard against a manually inserted \color command in
+ % contents which could leak at a page break to the shadow
+ \normalcolor
+ \fi
+% NOTA BENE
+% We deliberately draw shadow partially under an area later covered by frame
+% with the idea to avoid anti-aliasing problems but in fact this may be a bad
+% idea with border is thin.
+% This may need some extra testing with PDF viewers... reports welcome!
+ \ifdim\spx@boxes@shadow@yoffset>\z@
+ \hrule\@height\dimexpr\spx@boxes@border@top+\spx@boxes@shadow@yoffset\relax
+ \kern-\spx@boxes@shadow@yoffset
+ \kern-\spx@boxes@border@top
+ \fi
+ \setbox\spx@tempboxb\hb@xt@\wd\spx@tempboxa{%
+ \ifdim\spx@boxes@shadow@xoffset>\z@
+ \vrule\@width\dimexpr\spx@boxes@border@left+\spx@boxes@shadow@xoffset\relax\fi
+ \hss
+ \ifdim\spx@boxes@shadow@xoffset<\z@
+ \vrule\@width\dimexpr-\spx@boxes@shadow@xoffset+\spx@boxes@border@right\relax\fi
+ }%
+ \ht\spx@tempboxb\ht\spx@tempboxa
+ \dp\spx@tempboxb\dp\spx@tempboxa
+ \box\spx@tempboxb
+ \ifdim\spx@boxes@shadow@yoffset<\z@
+ \kern\spx@boxes@shadow@yoffset
+ \kern-\spx@boxes@border@bottom
+ \hrule\@height\dimexpr-\spx@boxes@shadow@yoffset+\spx@boxes@border@bottom\relax
+ \fi
+ \kern-\dp\spx@tempboxa
+ }% end of \vbox, attention it will have zero depth if yoffset<0
+ \kern-\wd\spx@tempboxa
+ }% end of \hbox, attention its depth is only |yoffset| if yoffset<0
+ \fi % end of inset shadow drawing, and we are back to horizontal reference point
+ % BOX BORDER
+ \vbox{\ifspx@boxes@withbordercolor
+ \color{spx@boxes@bordercolor}%
+ \else
+ % 6.2.0: guard against a \color command in contents whose effect
+ % could leak to border at a pagebreak
+ \normalcolor
+ \fi
+ \hrule\@height\spx@boxes@border@top
+ \kern-\spx@boxes@border@top
+ \setbox\spx@tempboxb\hb@xt@\wd\spx@tempboxa
+ {\vrule\@width\spx@boxes@border@left
+ \hss\vrule\@width\spx@boxes@border@right
+ }%
+ \ht\spx@tempboxb\ht\spx@tempboxa
+ \dp\spx@tempboxb\dp\spx@tempboxa
+ \box\spx@tempboxb
+ \kern-\spx@boxes@border@bottom
+ \hrule\@height\spx@boxes@border@bottom
+ \kern-\dp\spx@tempboxa
+ }% attention this box has zero depth due to \hrule at bottom
+ % step back to horizontal reference point
+ \kern-\wd\spx@tempboxa
+ % end of border drawing
+ % CONTENTS
+ \box\spx@tempboxa
+ \egroup
+}
+
+% let's abort input if pict2e package could not be loaded.
+% To be extra safe we also alias @rounded to @rectangle but
+% a priori the architecture is done so that @rounded will never
+% be called in that case by other Sphinx LaTeX components.
+\@ifpackageloaded{pict2e}
+ {}
+ {\def\spx@boxes@fcolorbox@rounded{\spx@boxes@fcolorbox@rectangle}%
+ \endinput
+ }
+
+% we proceed now in the context of pict2e being available and loaded
+% (TeX being a macro-expansion based language it would have
+% swallowed all the coming definitions even if pict2e
+% had in fact not been loaded... but we aborted the input above)
+%%%%%%%%
+%//// \spx@boxes@fcolorbox@rounded
+%
+% Prior to 6.2.0, a constant border-width was applied as the border was
+% obtained as a \strokepath. This allowed 4 distinct radii but not to vary the
+% border widths. Now the border is drawn by two \fillpath operation, the first
+% one filling up to external border, the second one actually filling for the
+% background paradoxically on top of it, up to internal border path.
+%
+% This 6.2.0 abandonment of \strokepath allowed great simplification in
+% supporting opentop, openbottom and openboth situations, and it can
+% allow automatic support of openleft and openright analogs.
+%
+% And 6.2.0 also implements elliptical arcs thanks to ellipse package,
+% which extends pict2e.
+
+% Currently, inset shadow is not supported.
+%
+% Prior to 6.2.0 an inset shadow triggered the rectangle variant, so we never
+% ended here, but now it is simply ignored. This change does not appear to me
+% to be breaking, as it changes output only for conf.py's specifying both
+% rounded corners and an inset shadow and the documentation said it was
+% incompatible.
+
+% wrappers for pict2e usage if old
+% Better not to copy over 2020 pict2e definitions in case
+% something internal changes
+% However our wrappers will work ONLY with dimensional inputs
+% No need to pre-expand the arguments
+% Braces in case the expression uses parentheses
+\def\spx@moveto(#1,#2){\moveto({\strip@pt\dimexpr#1\relax},{\strip@pt\dimexpr#2\relax})}
+\def\spx@lineto(#1,#2){\lineto({\strip@pt\dimexpr#1\relax},{\strip@pt\dimexpr#2\relax})}
+% attention here the [N] becomes mandatory
+% \circlearc[<N>]{<X>}{<Y>}{<RAD>}{<ANGLE1>}{<ANGLE2>}
+\def\spx@circlearc[#1]#2#3#4%#5#6
+ {\circlearc[#1]{\strip@pt\dimexpr#2\relax}%
+ {\strip@pt\dimexpr#3\relax}%
+ {\strip@pt\dimexpr#4\relax}%
+ }
+% attention here too the [N] becomes mandatory
+% the core path macro of ellipse.sty. Thanks to Daan Leijen, author of this
+% package.
+% \elliparc [<initial>]{<center-x>}{<center-y>}{<x-rad>}{<y-rad>}{<start-angle>}{<end-angle>}
+% maybe this wrapper is unneeded but I don't have real time to check
+\def\spx@elliparc[#1]#2#3#4#5%#6#7
+ {\elliparc[#1]{\strip@pt\dimexpr#2\relax}%
+ {\strip@pt\dimexpr#3\relax}%
+ {\strip@pt\dimexpr#4\relax}%
+ {\strip@pt\dimexpr#5\relax}%
+ }
+
+% Macro whose execution prepares a path to be either stroked or filled
+% Only fill operation is used at 6.2.0. The radii are given by the set box
+% parameters, but the width and height are in \spx@width and \spx@height. A
+% \put command will be used for appropriate shifts.
+% 6.2.0 adds elliptical corners!
+% But I feel perhaps I need to think about how x-radius and y-radius should
+% interact with border-width. So consider output WIP for time being.
+\def\spx@boxes@border@defpath{%
+ \spx@moveto(\spx@boxes@radius@bottomleft@x,\z@)% our \spx@moveto is a bit rigid
+ % and we must use \z@ not 0 here
+ \spx@lineto(\spx@width-\spx@boxes@radius@bottomright@x,\z@)%
+ % x and y radii are either both positive or both zero
+ % probably not needed to actually guard against the latter case,
+ % let's do it nevertheless
+ \ifdim\spx@boxes@radius@bottomright@x>\z@
+ \ifdim\spx@boxes@radius@bottomright@x=\spx@boxes@radius@bottomright@y
+ \spx@circlearc[2]{\spx@width-\spx@boxes@radius@bottomright@x}%
+ {\spx@boxes@radius@bottomright@y}%
+ {\spx@boxes@radius@bottomright@x}{-90}{0}%
+ \else
+ \spx@elliparc[2]{\spx@width-\spx@boxes@radius@bottomright@x}%
+ {\spx@boxes@radius@bottomright@y}%
+ {\spx@boxes@radius@bottomright@x}
+ {\spx@boxes@radius@bottomright@y}{-90}{0}%
+ \fi
+ \fi
+ \spx@lineto(\spx@width,%
+ \spx@height-\spx@boxes@radius@topright@y)%
+ \ifdim\spx@boxes@radius@topright@x>\z@
+ \ifdim\spx@boxes@radius@topright@x=\spx@boxes@radius@topright@y
+ \spx@circlearc[2]{\spx@width-\spx@boxes@radius@topright@x}
+ {\spx@height-\spx@boxes@radius@topright@y}%
+ {\spx@boxes@radius@topright@x}{0}{90}%
+ \else
+ \spx@elliparc[2]{\spx@width-\spx@boxes@radius@topright@x}
+ {\spx@height-\spx@boxes@radius@topright@y}%
+ {\spx@boxes@radius@topright@x}%
+ {\spx@boxes@radius@topright@y}{0}{90}%
+ \fi
+ \fi
+ \spx@lineto(\spx@boxes@radius@topleft@x,\spx@height)%
+ \ifdim\spx@boxes@radius@topleft@x>\z@
+ \ifdim\spx@boxes@radius@topleft@x=\spx@boxes@radius@topleft@y
+ \spx@circlearc[2]{\spx@boxes@radius@topleft@x}%
+ {\spx@height-\spx@boxes@radius@topleft@y}%
+ {\spx@boxes@radius@topleft@x}{90}{180}%
+ \else
+ \spx@elliparc[2]{\spx@boxes@radius@topleft@x}%
+ {\spx@height-\spx@boxes@radius@topleft@y}%
+ {\spx@boxes@radius@topleft@x}%
+ {\spx@boxes@radius@topleft@y}{90}{180}%
+ \fi
+ \fi
+ \spx@lineto(\z@,\spx@boxes@radius@bottomleft@y)%
+ \ifdim\spx@boxes@radius@bottomleft@x>\z@
+ \ifdim\spx@boxes@radius@bottomleft@x=\spx@boxes@radius@bottomleft@y
+ \spx@circlearc[2]{\spx@boxes@radius@bottomleft@x}%
+ {\spx@boxes@radius@bottomleft@y}%
+ {\spx@boxes@radius@bottomleft@x}{180}{270}%
+ \else
+ \spx@elliparc[2]{\spx@boxes@radius@bottomleft@x}%
+ {\spx@boxes@radius@bottomleft@y}%
+ {\spx@boxes@radius@bottomleft@x}%
+ {\spx@boxes@radius@bottomleft@y}{180}{270}%
+ \fi
+ \fi
+}% end of definition of \spx@boxes@border@defpath
+
+% The customization of the various parameters must have been done via an
+% appropriate call to \spx@boxes@fcolorbox@setup, which will have set up
+% \spx@boxes@fcolorbox to expand to \spx@boxes@fcolorbox@rounded, and will
+% have set its various parameters.
+%
+\long\def\spx@boxes@fcolorbox@rounded #1{%
+ \hbox{%
+ \ifspx@boxes@withshadow
+ \ifspx@boxes@insetshadow
+ \spx@boxes@withshadowfalse % ignore inset shadow
+ \fi
+ \fi
+ % reserve space to external shadow if on left
+ \ifspx@boxes@withshadow
+ \ifspx@boxes@shadowinbbox
+ \ifdim\spx@boxes@shadow@xoffset<\z@\kern-\spx@boxes@shadow@xoffset\fi
+ \fi
+ \fi
+ \vbox{%
+ % adjust vertical bbox
+ \ifspx@boxes@withshadow
+ \ifdim\spx@boxes@shadow@yoffset<\z@
+ \kern-\spx@boxes@shadow@yoffset
+ \fi
+ \fi
+ \setlength{\unitlength}{1pt}%
+ \setbox\spx@tempboxa
+ \hbox{\kern\dimexpr\spx@boxes@border@left+\spx@boxes@padding@left\relax
+ {#1}%
+ \kern\dimexpr\spx@boxes@padding@right+\spx@boxes@border@right\relax}%
+ \ht\spx@tempboxa
+ \dimexpr\ht\spx@tempboxa+\spx@boxes@border@top+\spx@boxes@padding@top\relax
+ \dp\spx@tempboxa
+ \dimexpr\dp\spx@tempboxa+\spx@boxes@padding@bottom+\spx@boxes@border@bottom\relax
+ \edef\spx@width{\number\wd\spx@tempboxa sp}%
+ \edef\spx@height{\number\dimexpr\ht\spx@tempboxa+\dp\spx@tempboxa sp}%
+ \hbox{%
+ \begin{picture}%
+ % \strip@pt\dimexpr to work around "old" LaTeX picture limitation
+ % (we could use the "picture" package, this would add another dependency)
+ (\strip@pt\dimexpr\spx@width\relax,\strip@pt\dimexpr\spx@height\relax)%
+ \spx@boxes@border@defpath
+ \ifspx@boxes@withshadow
+ \ifspx@boxes@withshadowcolor
+ \color{spx@boxes@shadowcolor}%
+ \else
+ % 6.2.0: here and elsewhere guard against a manually inserted
+ % \color command in contents which could leak to the shadow
+ % to the shadow
+ \normalcolor
+ \fi
+ \put(\strip@pt\spx@boxes@shadow@xoffset,%
+ \strip@pt\dimexpr-\spx@boxes@shadow@yoffset\relax)
+ {\fillpath}%
+ \fi
+ \spx@boxes@border@defpath% must be redone after each \fillpath! (even if
+ % was in a \put)
+ \ifspx@boxes@withbordercolor
+ \color{spx@boxes@bordercolor}%
+ \else
+ \normalcolor
+ \fi
+ \fillpath
+ \ifspx@boxes@withbackgroundcolor
+ \color{spx@boxes@backgroundcolor}%
+ \else
+ \color{white}%
+ \fi
+ \edef\spx@width{\number\dimexpr\spx@width-\spx@boxes@border@left
+ -\spx@boxes@border@right sp}%
+ \edef\spx@height{\number\dimexpr\spx@height-\spx@boxes@border@top
+ -\spx@boxes@border@bottom sp}%
+ % redefine a path (in relative coordinates) matching the area delimited
+ % by the internal borders
+ \spx@boxes@border@defpath
+ % use \put to shift, and fill it with background color
+ \put(\strip@pt\spx@boxes@border@left,\strip@pt\spx@boxes@border@bottom)
+ {\fillpath}%
+ \end{picture}}% end of picture \hbox in \vbox
+ % back-up vertically for outputting the contents
+ \kern-\dimexpr\ht\spx@tempboxa+\dp\spx@tempboxa\relax
+ % adjust vertical bbox
+ \ifspx@boxes@withshadow
+ \ifdim\spx@boxes@shadow@yoffset>\z@
+ \dp\spx@tempboxa\dimexpr\dp\spx@tempboxa+\spx@boxes@shadow@yoffset\relax
+ \fi
+ \fi
+ % inhibit TeX's "line skip" adjustment when piling up hboxes in a vbox
+ \nointerlineskip
+ \box\spx@tempboxa
+ }% end of \vbox
+ % include lateral shadow in total width
+ \ifspx@boxes@withshadow
+ \ifspx@boxes@shadowinbbox
+ \ifdim\spx@boxes@shadow@xoffset>\z@\kern\spx@boxes@shadow@xoffset\fi
+ \fi
+ \fi
+ }% end of \hbox
+}%
+
+
+\endinput
diff --git a/sphinx/texinputs/sphinxpackagecyrillic.sty b/sphinx/texinputs/sphinxpackagecyrillic.sty
new file mode 100644
index 0000000..9aa62fc
--- /dev/null
+++ b/sphinx/texinputs/sphinxpackagecyrillic.sty
@@ -0,0 +1,55 @@
+%% CYRILLIC IN NON-CYRILLIC DOCUMENTS (pdflatex only)
+%
+% refs: https://tex.stackexchange.com/q/460271/
+\ProvidesPackage{sphinxpackagecyrillic}%
+ [2018/11/21 v2.0 support for Cyrillic in non-Cyrillic documents]
+\RequirePackage{kvoptions}
+\SetupKeyvalOptions{prefix=spx@cyropt@} % use \spx@cyropt@ prefix
+\DeclareBoolOption[false]{Xtwo}
+\DeclareBoolOption[false]{TtwoA}
+\DeclareDefaultOption{\@unknownoptionerror}
+\ProcessLocalKeyvalOptions* % ignore class options
+
+\ifspx@cyropt@Xtwo
+% original code by tex.sx user egreg (updated 2019/10/28):
+% https://tex.stackexchange.com/a/460325/
+% 159 Cyrillic glyphs as available in X2 TeX 8bit font encoding
+% This assumes inputenc loaded with utf8 option, or LaTeX release
+% as recent as 2018/04/01 which does it automatically.
+ \@tfor\next:=%
+ {Ё}{Ђ}{Є}{Ѕ}{І}{Ј}{Љ}{Њ}{Ћ}{Ў}{Џ}{А}{Б}{В}{Г}{Д}{Е}{Ж}{З}{И}{Й}%
+ {К}{Л}{М}{Н}{О}{П}{Р}{С}{Т}{У}{Ф}{Х}{Ц}{Ч}{Ш}{Щ}{Ъ}{Ы}{Ь}{Э}{Ю}%
+ {Я}{а}{б}{в}{г}{д}{е}{ж}{з}{и}{й}{к}{л}{м}{н}{о}{п}{р}{с}{т}{у}%
+ {ф}{х}{ц}{ч}{ш}{щ}{ъ}{ы}{ь}{э}{ю}{я}{ё}{ђ}{є}{ѕ}{і}{ј}{љ}{њ}{ћ}%
+ {ў}{џ}{Ѣ}{ѣ}{Ѫ}{ѫ}{Ѵ}{ѵ}{Ґ}{ґ}{Ғ}{ғ}{Ҕ}{ҕ}{Җ}{җ}{Ҙ}{ҙ}{Қ}{қ}{Ҝ}{ҝ}%
+ {Ҟ}{ҟ}{Ҡ}{ҡ}{Ң}{ң}{Ҥ}{ҥ}{Ҧ}{ҧ}{Ҩ}{ҩ}{Ҫ}{ҫ}{Ҭ}{ҭ}{Ү}{ү}{Ұ}{ұ}{Ҳ}{ҳ}%
+ {Ҵ}{ҵ}{Ҷ}{ҷ}{Ҹ}{ҹ}{Һ}{һ}{Ҽ}{ҽ}{Ҿ}{ҿ}{Ӏ}{Ӄ}{ӄ}{Ӆ}{ӆ}{Ӈ}{ӈ}{Ӌ}{ӌ}%
+ {Ӎ}{ӎ}{Ӕ}{ӕ}{Ә}{ә}{Ӡ}{ӡ}{Ө}{ө}\do
+ {%
+ \begingroup\def\IeC{\protect\DeclareTextSymbolDefault}%
+ \protected@edef\@temp{\endgroup
+ \@ifl@t@r{\fmtversion}{2019/10/01}{\csname u8:\next\endcsname}{\next}}%
+ \@temp{X2}%
+ }%
+\else
+\ifspx@cyropt@TtwoA
+% original code by tex.sx user jfbu:
+% https://tex.stackexchange.com/a/460305/
+% 63*2+1=127 Cyrillic glyphs as found in T2A 8bit TeX font-encoding
+ \@tfor\@tempa:=%
+ {ae}{a}{b}{chrdsc}{chvcrs}{ch}{c}{dje}{dze}{dzhe}{d}{erev}{ery}{e}%
+ {f}{ghcrs}{gup}{g}{hdsc}{hrdsn}{h}{ie}{ii}{ishrt}{i}{je}%
+ {kbeak}{kdsc}{kvcrs}{k}{lje}{l}{m}{ndsc}{ng}{nje}{n}{otld}{o}{p}{r}%
+ {schwa}{sdsc}{sftsn}{shch}{shha}{sh}{s}{tshe}{t}{ushrt}{u}{v}%
+ {ya}{yhcrs}{yi}{yo}{yu}{y}{zdsc}{zhdsc}{zh}{z}\do
+ {%
+ \expandafter\DeclareTextSymbolDefault\expandafter
+ {\csname cyr\@tempa\endcsname}{T2A}%
+ \expandafter\uppercase\expandafter{\expandafter
+ \def\expandafter\@tempa\expandafter{\@tempa}}%
+ \expandafter\DeclareTextSymbolDefault\expandafter
+ {\csname CYR\@tempa\endcsname}{T2A}%
+ }%
+ \DeclareTextSymbolDefault{\CYRpalochka}{T2A}%
+\fi\fi
+\endinput
diff --git a/sphinx/texinputs/sphinxpackagefootnote.sty b/sphinx/texinputs/sphinxpackagefootnote.sty
new file mode 100644
index 0000000..5590123
--- /dev/null
+++ b/sphinx/texinputs/sphinxpackagefootnote.sty
@@ -0,0 +1,433 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{sphinxpackagefootnote}%
+ [2022/08/15 v5.3.0 Sphinx custom footnotehyper package (Sphinx team)]
+%%
+%% Package: sphinxpackagefootnote
+%% Version: based on footnotehyper.sty 2021/02/04 v1.1d
+%% https://www.ctan.org/pkg/footnotehyper
+%% License: the one applying to Sphinx
+%%
+% Provides support for footnote mark-up from Sphinx latex writer:
+% - "footnote" and "footnotetext" environments allowing verbatim material
+% - "savenotes" environment for wrapping environments, such as for tables
+% which have problems with LaTeX footnotes
+% - hyperlinks
+%
+% Sphinx uses exclusively this mark-up for footnotes:
+% - \begin{footnote}[N]
+% - \begin{footnotetext}[N]
+% - \sphinxfootnotemark[N]
+% where N is a number.
+%
+%% Some small differences from upstream footnotehyper.sty:
+%% - a tabulary compatibility layer (partial but enough for Sphinx),
+%% - usage of \spx@opt@BeforeFootnote
+%% - usage of \sphinxunactivateextrasandspace from sphinx.sty,
+%% - \sphinxlongtablepatch
+%%
+%% Starting with Sphinx v4.5.0, inherited footnotehyper macros for
+%% footnote/footnotetext receive some Sphinx specific extras to
+%% implement "intelligent" footnote marks checking page numbers.
+%%
+%% All footnotes output from Sphinx are hyperlinked. With "savenotes"
+%% footnotes may appear on page distinct from footnote mark, the latter
+%% will indicate page number of the footnote.
+\newif\iffootnotehyperparse\footnotehyperparsetrue
+\DeclareOption*{\PackageWarning{sphinxpackagefootnote}{Option `\CurrentOption' is unknown}}%
+\ProcessOptions\relax
+\newbox\FNH@notes
+\newtoks\FNH@toks % 1.1c
+\newdimen\FNH@width
+\let\FNH@colwidth\columnwidth
+\newif\ifFNH@savingnotes
+\AtBeginDocument {%
+ \let\FNH@latex@footnote \footnote
+ \let\FNH@latex@footnotetext\footnotetext
+ \let\FNH@H@@footnotetext \@footnotetext
+ \let\FNH@H@@mpfootnotetext \@mpfootnotetext
+ \newenvironment{savenotes}
+ {\FNH@savenotes\ignorespaces}{\FNH@spewnotes\ignorespacesafterend}%
+ \let\spewnotes \FNH@spewnotes
+ \let\footnote \FNH@footnote
+ \let\footnotetext \FNH@footnotetext
+ \let\endfootnote \FNH@endfntext
+ \let\endfootnotetext\FNH@endfntext
+ % always True branch taken with Sphinx
+ \@ifpackageloaded{hyperref}
+ {\ifHy@hyperfootnotes
+ \let\FNH@H@@footnotetext\H@@footnotetext
+ \let\FNH@H@@mpfootnotetext\H@@mpfootnotetext
+ \else
+ \let\FNH@hyper@fntext\FNH@nohyp@fntext
+ \fi}%
+ {\let\FNH@hyper@fntext\FNH@nohyp@fntext}%
+}%
+\def\FNH@hyper@fntext{\FNH@fntext\FNH@hyper@fntext@i}%
+\def\FNH@nohyp@fntext{\FNH@fntext\FNH@nohyp@fntext@i}%
+\def\FNH@fntext #1{%
+ \ifx\ifmeasuring@\@undefined
+ \expandafter\@secondoftwo\else\expandafter\@firstofone\fi
+% these two lines modified for Sphinx (tabulary compatibility):
+ {\ifmeasuring@\expandafter\@gobbletwo\else\expandafter\@firstofone\fi}%
+ {\ifx\equation$\expandafter\@gobbletwo\fi #1}%$
+}%
+\long\def\FNH@hyper@fntext@i#1{%
+ \global\setbox\FNH@notes\vbox
+ {\unvbox\FNH@notes
+ \FNH@startnote
+ \@makefntext
+ {\rule\z@\footnotesep\ignorespaces
+ \ifHy@nesting\expandafter\ltx@firstoftwo
+ \else\expandafter\ltx@secondoftwo
+ \fi
+ {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}%
+ {\Hy@raisedlink
+ {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}%
+ {\relax}}%
+ \let\@currentHref\Hy@footnote@currentHref
+ \let\@currentlabelname\@empty
+ #1}%
+ \@finalstrut\strutbox
+ }%
+ \FNH@endnote
+ }%
+}%
+\long\def\FNH@nohyp@fntext@i#1{%
+ \global\setbox\FNH@notes\vbox
+ {\unvbox\FNH@notes
+ \FNH@startnote
+ \@makefntext{\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
+ \FNH@endnote
+ }%
+}%
+\def\FNH@startnote{%
+ \hsize\FNH@colwidth
+ \interlinepenalty\interfootnotelinepenalty
+ \reset@font\footnotesize
+ \floatingpenalty\@MM
+ \@parboxrestore
+ \protected@edef\@currentlabel{\csname p@\@mpfn\endcsname\@thefnmark}%
+ \color@begingroup
+}%
+\def\FNH@endnote{\color@endgroup}%
+\def\FNH@savenotes{%
+ \begingroup
+ \ifFNH@savingnotes\else
+ \FNH@savingnotestrue
+ \let\@footnotetext \FNH@hyper@fntext
+ \let\@mpfootnotetext \FNH@hyper@fntext
+ \let\H@@mpfootnotetext\FNH@nohyp@fntext
+ \FNH@width\columnwidth
+ \let\FNH@colwidth\FNH@width
+ \global\setbox\FNH@notes\box\voidb@x
+ \let\FNH@thempfn\thempfn
+ \let\FNH@mpfn\@mpfn
+ \ifx\@minipagerestore\relax\let\@minipagerestore\@empty\fi
+ \expandafter\def\expandafter\@minipagerestore\expandafter{%
+ \@minipagerestore
+ \let\thempfn\FNH@thempfn
+ \let\@mpfn\FNH@mpfn
+ }%
+ \fi
+}%
+\def\FNH@spewnotes {%
+ \if@endpe\ifx\par\@@par\FNH@toks{}\else
+ \FNH@toks\expandafter{\expandafter
+ \def\expandafter\par\expandafter{\par}\@endpetrue}%
+ \expandafter\expandafter\expandafter
+ \FNH@toks
+ \expandafter\expandafter\expandafter
+ {\expandafter\the\expandafter\FNH@toks
+ \expandafter\def\expandafter\@par\expandafter{\@par}}%
+ \expandafter\expandafter\expandafter
+ \FNH@toks
+ \expandafter\expandafter\expandafter
+ {\expandafter\the\expandafter\FNH@toks
+ \expandafter\everypar\expandafter{\the\everypar}}\fi
+ \else\FNH@toks{}\fi
+ \expandafter
+ \endgroup\the\FNH@toks
+ \ifFNH@savingnotes\else
+ \ifvoid\FNH@notes\else
+ \begingroup
+ \let\@makefntext\@empty
+ \let\@finalstrut\@gobble
+ \let\rule\@gobbletwo
+ \ifx\@footnotetext\@mpfootnotetext
+ \expandafter\FNH@H@@mpfootnotetext
+ \else
+ \expandafter\FNH@H@@footnotetext
+ \fi{\unvbox\FNH@notes}%
+ \endgroup
+ \fi
+ \fi
+}%
+\def\FNH@footnote@envname {footnote}%
+\def\FNH@footnotetext@envname{footnotetext}%
+\def\FNH@footnote{%
+% this line added for Sphinx:
+ \spx@opt@BeforeFootnote
+ \ifx\@currenvir\FNH@footnote@envname
+ \expandafter\FNH@footnoteenv
+ \else
+ \expandafter\FNH@latex@footnote
+ \fi
+}%
+\def\FNH@footnoteenv{%
+% this line added for Sphinx (footnotes in parsed literal blocks):
+ \catcode13=5 \sphinxunactivateextrasandspace
+ \@ifnextchar[%
+ \FNH@footnoteenv@i %]
+ {\stepcounter\@mpfn
+ \protected@xdef\@thefnmark{\thempfn}%
+ \@footnotemark
+ \def\FNH@endfntext@fntext{\@footnotetext}%
+ \FNH@startfntext}%
+}%
+\def\FNH@footnoteenv@i[#1]{%
+ \begingroup
+ % This legacy code from LaTeX core restricts #1 to be digits only
+ % This limitation could be lifted but legacy Sphinx anyhow obeys it
+ \csname c@\@mpfn\endcsname #1\relax
+ \unrestored@protected@xdef\@thefnmark{\thempfn}%
+ \endgroup
+% -- Sphinx specific:
+% currently commented out due to
+% https://github.com/sphinx-doc/sphinx/pull/10191#issuecomment-1038807448
+% Memo: memoir class detection of successive footnote marks (to separate them
+% by commas) is broken by \refstepcounter and also by \label, and some
+% mitigation such as in \sphinxfootref would be needed
+ % \global\let\spx@saved@thefnmark\@thefnmark
+ % % this is done to access robustly the page number where footnote mark is
+ % \refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
+ % % if possible, compare page numbers of mark and footnote to define \@thefnmark
+ % \ltx@ifundefined{r@\thesphinxscope.footnote.#1}%
+ % {}% one more latex run is needed
+ % {\sphinx@xdef@thefnmark{#1}}% check of page numbers possible
+% --
+ \@footnotemark
+ \def\FNH@endfntext@fntext{\@footnotetext}%
+% -- Sphinx specific:
+ % we need to reset \@thefnmark as it is used by \FNH@startfntext via
+ % \FNH@startnote to set \@currentlabel which will be used by \label
+% currently commented out (see above)
+ % \global\let\@thefnmark\spx@saved@thefnmark
+% --
+ \FNH@startfntext
+% -- again Sphinx specific
+ % \@currentlabel as needed by \label got set by \FNH@startnote
+ % insert this at start of footnote text then the label will allow
+ % to robustly know on which page the footnote text ends up
+% currently only of use for extra footnote marks so in case footnote multiply referred
+ \phantomsection\label{\thesphinxscope.footnote.#1}%
+}%
+\def\FNH@footnotetext{%
+ \ifx\@currenvir\FNH@footnotetext@envname
+ \expandafter\FNH@footnotetextenv
+ \else
+ \expandafter\FNH@latex@footnotetext
+ \fi
+}%
+\def\FNH@footnotetextenv{%
+ \@ifnextchar[%
+ \FNH@footnotetextenv@i %]
+ {\protected@xdef\@thefnmark{\thempfn}%
+ \def\FNH@endfntext@fntext{\@footnotetext}%
+ \FNH@startfntext}%
+}%
+\def\FNH@footnotetextenv@i[#1]{%
+ \begingroup
+ \csname c@\@mpfn\endcsname #1\relax
+ \unrestored@protected@xdef\@thefnmark{\thempfn}%
+ \endgroup
+ \ifFNH@savingnotes
+ \def\FNH@endfntext@fntext{\FNH@nohyp@fntext}%
+ \else
+ \def\FNH@endfntext@fntext{\FNH@H@@footnotetext}%
+ \fi
+ \FNH@startfntext
+% -- Sphinx specific addition
+ \phantomsection\label{\thesphinxscope.footnote.#1}%
+}%
+\def\FNH@startfntext{%
+ \setbox\z@\vbox\bgroup
+ \FNH@startnote
+ \FNH@prefntext
+ \rule\z@\footnotesep\ignorespaces
+}%
+\def\FNH@endfntext {%
+ \@finalstrut\strutbox
+ \FNH@postfntext
+ \FNH@endnote
+ \egroup
+ \begingroup
+ \let\@makefntext\@empty\let\@finalstrut\@gobble\let\rule\@gobbletwo
+ \FNH@endfntext@fntext {\unvbox\z@}%
+ \endgroup
+}%
+\let\FNH@prefntext\@empty
+\let\FNH@postfntext\@empty
+\AtBeginDocument{\iffootnotehyperparse\expandafter\FNH@check\fi}%
+\def\FNH@safeif#1{%
+ \iftrue\csname if#1\endcsname\csname fi\endcsname\expandafter\@firstoftwo
+ \else\csname fi\endcsname\expandafter\@secondoftwo
+ \fi
+}%
+\def\FNH@check{%
+ \ifx\@makefntextFB\@undefined\expandafter\FNH@check@
+ \else\expandafter\FNH@frenchb@
+ \fi
+}%
+\def\FNH@frenchb@{%
+ \def\FNH@prefntext{%
+ \localleftbox{}%
+ \let\FBeverypar@save\FBeverypar@quote
+ \let\FBeverypar@quote\relax
+ \FNH@safeif{FB@koma}%
+ {\FNH@safeif{FBFrenchFootnotes}%
+ {\ifx\footnote\thanks
+ \let\@@makefnmark\@@makefnmarkTH
+ \@makefntextTH{} % space as in french.ldf
+ \else
+ \let\@@makefnmark\@@makefnmarkFB
+ \@makefntextFB{} % space as in french.ldf
+ \fi
+ }{\let\@@makefnmark\@@makefnmarkORI
+ \@makefntextORI{}% no space as in french.ldf
+ }%
+ }%
+ {\FNH@safeif{FBFrenchFootnotes}%
+ {\@makefntextFB{}}%
+ {\@makefntextORI{}}%
+ }%
+ }%
+ \def\FNH@postfntext{%
+ \let\FBeverypar@quote\FBeverypar@save
+ \localleftbox{\FBeveryline@quote}%
+ }%
+}%
+\def\FNH@check@{%
+ \expandafter\FNH@check@a\@makefntext{1.2!3?4,}%
+ \FNH@@@1.2!3?4,\FNH@@@\relax
+}%
+\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{%
+ \ifx\relax#3\expandafter\FNH@checkagain@
+ \else
+ \def\FNH@prefntext{#1}\def\FNH@postfntext{#2}%
+ \expandafter\FNH@check@b
+ \fi
+}%
+\def\FNH@checkagain@{%
+ \expandafter\FNH@checkagain@a
+ \detokenize\expandafter{\@makefntext{1.2!3?4,}}\relax\FNH@@@
+}%
+\edef\FNH@temp{\noexpand\FNH@checkagain@a ##1\string{1.2!3?4,\string}}%
+\expandafter\def\FNH@temp#2#3\FNH@@@{%
+ \ifx\relax#2%
+ \def\FNH@prefntext{\@makefntext{}}%
+ \else\FNH@bad@makefntext@alert
+ \fi
+}%
+\def\FNH@check@b #1\relax{%
+ \expandafter\expandafter\expandafter\FNH@check@c
+ \expandafter\meaning\expandafter\FNH@prefntext
+ \meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax
+}%
+\def\FNH@check@c #11.2!3?4,#2#3\relax{%
+ \ifx\FNH@check@c#2\else\FNH@bad@makefntext@alert\fi
+}%
+% slight reformulation for Sphinx
+\def\FNH@bad@makefntext@alert{%
+ \sphinxbuildwarning{badfootnotes}%
+ \PackageWarningNoLine{sphinxpackagefootnote}%
+ {Footnotes will be sub-optimal, sorry. This is due to the document class or^^J
+ some package modifying macro \string\@makefntext.^^J
+ You can try to report this incompatibility at^^J
+ https://github.com/sphinx-doc/sphinx with this info:}%
+ \typeout{\meaning\@makefntext}%
+ \let\FNH@prefntext\@empty\let\FNH@postfntext\@empty
+}%
+% this macro from original footnote.sty is not used anymore by Sphinx
+% but for simplicity sake let's just keep it as is
+\def\makesavenoteenv{\@ifnextchar[\FNH@msne@ii\FNH@msne@i}%]
+\def\FNH@msne@i #1{%
+ \expandafter\let\csname FNH$#1\expandafter\endcsname %$
+ \csname #1\endcsname
+ \expandafter\let\csname endFNH$#1\expandafter\endcsname %$
+ \csname end#1\endcsname
+ \FNH@msne@ii[#1]{FNH$#1}%$
+}%
+\def\FNH@msne@ii[#1]#2{%
+ \expandafter\edef\csname#1\endcsname{%
+ \noexpand\savenotes
+ \expandafter\noexpand\csname#2\endcsname
+ }%
+ \expandafter\edef\csname end#1\endcsname{%
+ \expandafter\noexpand\csname end#2\endcsname
+ \noexpand\expandafter
+ \noexpand\spewnotes
+ \noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi
+ }%
+}%
+%
+% some extras for Sphinx :
+% \sphinxfootnotemark:
+% - if in section titles will auto-remove itself from TOC
+\def\sphinxfootnotemark [#1]%
+ {\ifx\thepage\relax\else\sphinxfootref{#1}\fi}%
+\newcounter{sphinxfootnotemark}
+\renewcommand\thesphinxfootnotemark{\number\value{sphinxfootnotemark}}
+% - compares page number of footnote mark versus the one of footnote text
+\def\sphinx@xdef@thefnmark#1{%
+ \expandafter\expandafter\expandafter\sphinx@footref@get
+ \csname r@\thesphinxscope.footnote.#1\endcsname\relax
+ \expandafter\expandafter\expandafter\sphinx@footmark@getpage
+ \csname r@footnotemark.\thesphinxfootnotemark\endcsname\thepage\relax
+ \protected@xdef\@thefnmark{%
+ \ifx\spx@footmarkpage\spx@footrefpage
+ \spx@footreflabel
+ \else
+ % the macro \sphinxthefootnotemark is in sphinx.sty
+ \sphinxthefootnotemark{\spx@footreflabel}{\spx@footrefpage}%
+ \fi
+ }%
+}%
+\def\sphinx@footref@get #1#2#3#4#5\relax{%
+ \def\spx@footreflabel{#1}%
+ \def\spx@footrefpage {#2}%
+ \def\spx@footrefHref {#4}%
+}%
+\def\sphinx@footmark@getpage #1#2#3\relax{%
+ \edef\spx@footmarkpage{#2}%
+}%
+\protected\def\sphinxfootref#1{% #1 always is explicit number in Sphinx
+ \spx@opt@BeforeFootnote
+ % each of \refstepcounter and \label interferes with memoir class detection
+ % of successive footnote marks, so we move them to inside \@makefnmark
+ \let\spx@saved@makefnmark\@makefnmark
+ \ltx@ifundefined{r@\thesphinxscope.footnote.#1}%
+ {\gdef\@thefnmark{?}% on first LaTeX run
+ \refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
+ }%
+ {\sphinx@xdef@thefnmark{#1}% also defines \spx@footrefHref
+ \def\@makefnmark{% will be used by \H@@footnotemark
+ \refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
+ \hyper@linkstart{link}{\spx@footrefHref}%
+ \spx@saved@makefnmark
+ \hyper@linkend
+ }%
+ }%
+ \H@@footnotemark
+ \let\@makefnmark\spx@saved@makefnmark
+}%
+\AtBeginDocument{%
+ % let hyperref less complain
+ \pdfstringdefDisableCommands{\def\sphinxfootnotemark [#1]{}}%
+ % to obtain hyperlinked footnotes in longtable environment we must replace
+ % hyperref's patch of longtable's patch of \@footnotetext by our own
+ \let\LT@p@ftntext\FNH@hyper@fntext
+ % this *requires* longtable to be used always wrapped in savenotes environment
+}%
+\endinput
+%%
+%% End of file `sphinxpackagefootnote.sty'.