1%% ALPHANUMERIC LIST ITEMS
2%
3% change this info string if making any custom modification
4\ProvidesFile{sphinxlatexlists.sty}[2021/01/27 lists]
5
6% Provides support for this output mark-up from Sphinx latex writer:
7% - \sphinxsetlistlabels
8
9% Dependencies: the \spx@opt@maxlistdepth from sphinx.sty
10
11\newcommand\sphinxsetlistlabels[5]
12{% #1 = style, #2 = enum, #3 = enumnext, #4 = prefix, #5 = suffix
13 % #2 and #3 are counters used by enumerate environment e.g. enumi, enumii.
14 % #1 is a macro such as \arabic or \alph
15 % prefix and suffix are strings (by default empty and a dot).
16 \@namedef{the#2}{#1{#2}}%
17 \@namedef{label#2}{#4\@nameuse{the#2}#5}%
18 \@namedef{p@#3}{\@nameuse{p@#2}#4\@nameuse{the#2}#5}%
19}%
20
21
22%% MAXLISTDEPTH
23%
24% remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.
25% This is a hack, which works with the standard classes: it assumes \@toodeep
26% is always used in "true" branches: "\if ... \@toodeep \else .. \fi."
27
28% will force use the "false" branch (if there is one)
29\def\spx@toodeep@hack{\fi\iffalse}
30
31% do nothing if 'maxlistdepth' key not used or if package enumitem loaded.
32\ifnum\spx@opt@maxlistdepth=\z@\expandafter\@gobbletwo\fi
33\AtBeginDocument{%
34\@ifpackageloaded{enumitem}{\remove@to@nnil}{}%
35  \let\spx@toodeepORI\@toodeep
36  \def\@toodeep{%
37    \ifnum\@listdepth<\spx@opt@maxlistdepth\relax
38      \expandafter\spx@toodeep@hack
39    \else
40      \expandafter\spx@toodeepORI
41    \fi}%
42% define all missing \@list... macros
43  \count@\@ne
44  \loop
45     \ltx@ifundefined{@list\romannumeral\the\count@}
46       {\iffalse}{\iftrue\advance\count@\@ne}%
47  \repeat
48  \loop
49     \ifnum\count@>\spx@opt@maxlistdepth\relax\else
50       \expandafter\let
51         \csname @list\romannumeral\the\count@\expandafter\endcsname
52         \csname @list\romannumeral\the\numexpr\count@-\@ne\endcsname
53       % workaround 2.6--3.2d babel-french issue (fixed in 3.2e; no change needed)
54       \ltx@ifundefined{leftmargin\romannumeral\the\count@}
55       {\expandafter\let
56         \csname leftmargin\romannumeral\the\count@\expandafter\endcsname
57         \csname leftmargin\romannumeral\the\numexpr\count@-\@ne\endcsname}{}%
58     \advance\count@\@ne
59  \repeat
60% define all missing enum... counters and \labelenum... macros and \p@enum..
61  \count@\@ne
62  \loop
63     \ltx@ifundefined{c@enum\romannumeral\the\count@}
64       {\iffalse}{\iftrue\advance\count@\@ne}%
65  \repeat
66  \loop
67     \ifnum\count@>\spx@opt@maxlistdepth\relax\else
68       \newcounter{enum\romannumeral\the\count@}%
69       \expandafter\def
70         \csname labelenum\romannumeral\the\count@\expandafter\endcsname
71         \expandafter
72         {\csname theenum\romannumeral\the\numexpr\count@\endcsname.}%
73       \expandafter\def
74         \csname p@enum\romannumeral\the\count@\expandafter\endcsname
75         \expandafter
76         {\csname p@enum\romannumeral\the\numexpr\count@-\@ne\expandafter
77          \endcsname\csname theenum\romannumeral\the\numexpr\count@-\@ne\endcsname.}%
78     \advance\count@\@ne
79  \repeat
80% define all missing labelitem... macros
81  \count@\@ne
82  \loop
83     \ltx@ifundefined{labelitem\romannumeral\the\count@}
84     {\iffalse}{\iftrue\advance\count@\@ne}%
85  \repeat
86  \loop
87     \ifnum\count@>\spx@opt@maxlistdepth\relax\else
88       \expandafter\let
89         \csname labelitem\romannumeral\the\count@\expandafter\endcsname
90         \csname labelitem\romannumeral\the\numexpr\count@-\@ne\endcsname
91     \advance\count@\@ne
92  \repeat
93  \PackageInfo{sphinx}{maximal list depth extended to \spx@opt@maxlistdepth}%
94\@gobble\@nnil
95}
96
97\endinput
98