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