Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sphinxlatexlists.sty « texinputs « sphinx - github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3860090c298387747b26b655923ae0239de7d19a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
%% ALPHANUMERIC LIST ITEMS
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexlists.sty}[2021/01/27 lists]

% Provides support for this output mark-up from Sphinx latex writer:
% - \sphinxsetlistlabels

% Dependencies: the \spx@opt@maxlistdepth from sphinx.sty

\newcommand\sphinxsetlistlabels[5]
{% #1 = style, #2 = enum, #3 = enumnext, #4 = prefix, #5 = suffix
 % #2 and #3 are counters used by enumerate environement e.g. enumi, enumii.
 % #1 is a macro such as \arabic or \alph
 % prefix and suffix are strings (by default empty and a dot).
 \@namedef{the#2}{#1{#2}}%
 \@namedef{label#2}{#4\@nameuse{the#2}#5}%
 \@namedef{p@#3}{\@nameuse{p@#2}#4\@nameuse{the#2}#5}%
}%


%% MAXLISTDEPTH
%
% remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.
% This is a hack, which works with the standard classes: it assumes \@toodeep
% is always used in "true" branches: "\if ... \@toodeep \else .. \fi."

% will force use the "false" branch (if there is one)
\def\spx@toodeep@hack{\fi\iffalse}

% do nothing if 'maxlistdepth' key not used or if package enumitem loaded.
\ifnum\spx@opt@maxlistdepth=\z@\expandafter\@gobbletwo\fi
\AtBeginDocument{%
\@ifpackageloaded{enumitem}{\remove@to@nnil}{}%
  \let\spx@toodeepORI\@toodeep
  \def\@toodeep{%
    \ifnum\@listdepth<\spx@opt@maxlistdepth\relax
      \expandafter\spx@toodeep@hack
    \else
      \expandafter\spx@toodeepORI
    \fi}%
% define all missing \@list... macros
  \count@\@ne
  \loop
     \ltx@ifundefined{@list\romannumeral\the\count@}
       {\iffalse}{\iftrue\advance\count@\@ne}%
  \repeat
  \loop
     \ifnum\count@>\spx@opt@maxlistdepth\relax\else
       \expandafter\let
         \csname @list\romannumeral\the\count@\expandafter\endcsname
         \csname @list\romannumeral\the\numexpr\count@-\@ne\endcsname
       % workaround 2.6--3.2d babel-french issue (fixed in 3.2e; no change needed)
       \ltx@ifundefined{leftmargin\romannumeral\the\count@}
       {\expandafter\let
         \csname leftmargin\romannumeral\the\count@\expandafter\endcsname
         \csname leftmargin\romannumeral\the\numexpr\count@-\@ne\endcsname}{}%
     \advance\count@\@ne
  \repeat
% define all missing enum... counters and \labelenum... macros and \p@enum..
  \count@\@ne
  \loop
     \ltx@ifundefined{c@enum\romannumeral\the\count@}
       {\iffalse}{\iftrue\advance\count@\@ne}%
  \repeat
  \loop
     \ifnum\count@>\spx@opt@maxlistdepth\relax\else
       \newcounter{enum\romannumeral\the\count@}%
       \expandafter\def
         \csname labelenum\romannumeral\the\count@\expandafter\endcsname
         \expandafter
         {\csname theenum\romannumeral\the\numexpr\count@\endcsname.}%
       \expandafter\def
         \csname p@enum\romannumeral\the\count@\expandafter\endcsname
         \expandafter
         {\csname p@enum\romannumeral\the\numexpr\count@-\@ne\expandafter
          \endcsname\csname theenum\romannumeral\the\numexpr\count@-\@ne\endcsname.}%
     \advance\count@\@ne
  \repeat
% define all missing labelitem... macros
  \count@\@ne
  \loop
     \ltx@ifundefined{labelitem\romannumeral\the\count@}
     {\iffalse}{\iftrue\advance\count@\@ne}%
  \repeat
  \loop
     \ifnum\count@>\spx@opt@maxlistdepth\relax\else
       \expandafter\let
         \csname labelitem\romannumeral\the\count@\expandafter\endcsname
         \csname labelitem\romannumeral\the\numexpr\count@-\@ne\endcsname
     \advance\count@\@ne
  \repeat
  \PackageInfo{sphinx}{maximal list depth extended to \spx@opt@maxlistdepth}%
\@gobble\@nnil
}

\endinput