ignore `'maxlistdepth'` if package "enumitem" in use

This commit is contained in:
jfbu 2016-10-27 09:23:40 +02:00
parent 787fffd25f
commit 4e2bdf6671
2 changed files with 24 additions and 19 deletions

View File

@ -1743,21 +1743,19 @@ These options influence LaTeX output. See further :doc:`latex`.
* Keys that don't need be overridden unless in special cases are:
``'maxlistdepth'``
For example, setting it to ``'10'`` (as a string) will allow up to 10
nested levels of list or quote environments, either numbered or not.
The default is to leave this key empty. LaTeX then allows only a
maximum of 6 nested levels, and among them at most 4 for numbered and
4 for itemized lists.
LaTeX allows by default at most 6 levels for nesting list and
quote-like environments, with at most 4 enumerated lists, and 4 bullet
lists. Setting this key for example to ``'10'`` (as a string) will
allow up to 10 nested levels (of all sorts). Leaving it to the empty
string means to obey the LaTeX default.
.. attention::
.. warning::
- This setting may likely be incompatible with LaTeX packages
modifying lists, or special document classes.
- Using this key may prove incompatible with some LaTeX packages
or special document classes which do their own list customization.
- The LaTeX package "enumitem" provides its own commands for
extending the maximal list depth. If this package is added to the
preamble, its commands should be used and ``'maxlistdepth'``
left to an empty string.
- The key setting is silently *ignored* in presence of "enumitem".
Use then rather the dedicated commands of this LaTeX package.
.. versionadded:: 1.5
``'inputenc'``

View File

@ -1010,17 +1010,17 @@
\providecommand*{\sphinxthebibliography}{\thebibliography}
\providecommand*{\sphinxtheindex}{\theindex}
% remove LaTeX's cap on nesting depth. This is a hack, intrinsically
% fragile, which works with the standard classes: it assumes \@toodeep
% is always used in "true" branches: "\if ... \@toodeep .. \else .. \fi."
% It is executed only if 'maxlistdepth' key from latex_elements is used.
% 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."
% The effect of this is to force use the "false" branch (if there is one)
% will force use the "false" branch (if there is one)
\def\spx@toodeep@hack{\fi\iffalse}
% default is to change nothing
% 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
@ -1039,6 +1039,11 @@
\expandafter\let
\csname @list\romannumeral\the\count@\expandafter\endcsname
\csname @list\romannumeral\the\numexpr\count@-\@ne\endcsname
% higher \leftmargin... needed to fix issue with babel-french (v2.6--...)
\spx@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..
@ -1074,4 +1079,6 @@
\csname labelitem\romannumeral\the\numexpr\count@-\@ne\endcsname
\advance\count@\@ne
\repeat
}
\PackageInfo{sphinx}{maximal list depth extended to \spx@opt@maxlistdepth}%
\@gobble\@nnil
}