Merge pull request #3104 from jfbu/latex_keyvalueoptions

``'sphinxpackageoptions'`` for key=value styling of Sphinx LaTeX
This commit is contained in:
Jean-François B
2016-11-01 19:25:49 +01:00
committed by GitHub
7 changed files with 491 additions and 219 deletions

View File

@@ -55,6 +55,7 @@ latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
latex_logo = '_static/sphinx.png'
latex_elements = {
'fontpkg': '\\usepackage{palatino}',
'passoptionstopackages': '\\PassOptionsToPackage{svgnames}{xcolor}',
}
latex_show_urls = 'footnote'

View File

@@ -1694,9 +1694,15 @@ These options influence LaTeX output. See further :doc:`latex`.
example ``100px=1in``, one can use ``'0.01in'`` but it is more precise
to use ``'47363sp'``. To obtain ``72px=1in``, use ``'1bp'``.
.. versionadded:: 1.5
``'sphinxpackageoptions'``
A comma separated list of ``key=value`` package options for the Sphinx
LaTeX style, default empty. See :doc:`latex`.
.. versionadded:: 1.5
``'passoptionstopackages'``
"PassOptionsToPackage" call, default empty.
A string which will be positioned early in the preamble, designed to
contain ``\\PassOptionsToPackage{options}{foo}`` commands. Default empty.
.. versionadded:: 1.4
``'geometry'``

View File

@@ -11,8 +11,25 @@ LaTeX customization
The *latex* target does not benefit from pre-prepared themes like the
*html* target does (see :doc:`theming`).
Basic customization is available from ``conf.py`` via usage of the
:ref:`latex-options` as described in :doc:`config`. For example::
.. raw:: latex
\begingroup
\sphinxsetup{verbatimwithframe=false,%
VerbatimColor={named}{OldLace}, TitleColor={named}{DarkGoldenrod},%
hintBorderColor={named}{LightCoral}, attentionBgColor={named}{LightPink},%
attentionborder=3pt, attentionBorderColor={named}{Crimson},%
noteBorderColor={named}{Olive}, noteborder=2pt,%
cautionBorderColor={named}{Cyan}, cautionBgColor={named}{LightCyan},%
cautionborder=3pt}
\relax
Basic customization
-------------------
It is available from ``conf.py`` via usage of the
:ref:`latex-options` as described in :doc:`config` (backslashes must be doubled
in Python string literals to reach latex.) For example::
# inside conf.py
latex_engine = 'xelatex'
@@ -36,32 +53,277 @@ Basic customization is available from ``conf.py`` via usage of the
.. the above was tested on Sphinx's own 1.5a2 documentation with good effect !
.. highlight:: latex
More advanced customization will be obtained via insertion into the LaTeX
preamble of relevant ``\renewcommand``, ``\renewenvironment``, ``\setlength``,
or ``\definecolor`` commands. The ``'preamble'`` key of
:confval:`latex_elements` will serve for inserting these commands. If they are
numerous, it may prove more convenient to assemble them into a specialized
file :file:`mycustomizedmacros.tex` and then use::
file :file:`mystyle.tex` and then use::
'preamble': '\\makeatletter\\input{mycustomizedmacros.tex}\\makeatother',
'preamble': r'\makeatletter\input{mystyle.tex}\makeatother',
More advanced LaTeX users will set up a style file
:file:`mycustomizedmacros.sty`, which can then be loaded via::
or, better, to set up a style file
:file:`mystyle.sty` which can then be loaded via::
'preamble': '\\usepackage{mycustomizedmacros}',
'preamble': r'\usepackage{mystyle}',
The :ref:`build configuration file <build-config>` file for the project needs
to have its variable :confval:`latex_additional_files` appropriately
configured, for example::
latex_additional_files = ["mycustomizedmacros.sty"]
latex_additional_files = ["mystyle.sty"]
Such *LaTeX Sphinx theme* files could possibly be contributed in the
future by advanced users for wider use.
The Sphinx LaTeX style package options
--------------------------------------
Let us list here some examples of macros, lengths, colors, which are inherited
from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
:file:`sphinxmanual.cls`, and can be customized.
The ``'sphinxpackageoptions'`` key to :confval:`latex_elements` provides a
more convenient interface to various style parameters. It is a comma separated
string of ``key=value`` instructions::
key1=value1,key2=value2, ...
- if a key is repeated, it is its last occurence which counts,
- spaces around the commas and equal signs are ignored.
If non-empty, it will be passed as argument to the ``\sphinxsetup`` command::
\usepackage{sphinx}
\sphinxsetup{key1=value1,key2=value2,...}
.. versionadded:: 1.5
.. note::
- Most options described next could also have been positioned as
:file:`sphinx.sty` package options. But for those where the key value
contains some LaTeX code the use of ``\sphinxsetup`` is mandatory. Hence
the whole ``'sphinxpackageoptions'`` string is passed as argument to
``\sphinxsetup``.
- As an alternative to the ``'sphinxpackageoptions'`` key, it is possibly
to insert explicitely the ``\\sphinxsetup{key=value,..}`` inside the
``'preamble'`` key. It is even possible to use the ``\sphinxsetup`` in
the body of the document, via the :rst:dir:`raw` directive, to modify
dynamically the option values: this is actually what we did for the
duration of this chapter for the PDF output, which is styled using::
verbatimwithframe=false,
VerbatimColor={named}{OldLace}, TitleColor={named}{DarkGoldenrod},
hintBorderColor={named}{LightCoral}, attentionBgColor={named}{LightPink},
attentionborder=3pt, attentionBorderColor={named}{Crimson},
noteBorderColor={named}{Olive}, noteborder=2pt,
cautionBorderColor={named}{Cyan}, cautionBgColor={named}{LightCyan},
cautionborder=3pt
and with the ``svgnames`` option having been passed to "xcolor" package::
latex_elements = {
'passoptionstopackages': r'\PassOptionsToPackage{svgnames}{xcolor}',
}
Here are the currently available options together with their default values.
.. caution::
These options correspond to what has been so far the default LaTeX
rendering by Sphinx; if in future Sphinx offers various *themes* for LaTeX,
the interface may change.
``verbatimwithframe``
default ``true``. Boolean to specify if :rst:dir:`code-block`\ s and literal
includes are framed. Setting it to ``false`` does not deactivate use of
package "framed", because it is still in use for the optional background
colour (see below).
.. attention::
LaTeX requires ``true`` or ``false`` to be specified in *lowercase*.
``verbatimwrapslines``
default ``true``. Tells whether long lines in :rst:dir:`code-block`\ s
should be wrapped.
.. (comment) It is theoretically possible to customize this even
more and decide at which characters a line-break can occur and whether
before or after, but this is accessible currently only by re-defining some
macros with complicated LaTeX syntax from :file:`sphinx.sty`.
``verbatimvisiblespace``
default ``\textcolor{red}{\textvisiblespace}``. When a long code line is
split, space characters located at end of the line before the break are
displayed using this code.
``verbatimcontinued``
The default is::
\makebox[2\fontcharwd\font`\x][r]{\textcolor{red}{\tiny$\hookrightarrow$}}
It is printed at start of continuation lines. This rather formidable
expression reserves twice the width of a typical character in the current
(monospaced) font and puts there a small red hook pointing to the right.
.. versionchanged:: 1.5
The breaking of long code lines was introduced at 1.4.2. The space
reserved to the continuation symbol was changed at 1.5 to obey the
current font characteristics (this was needed as Sphinx 1.5 LaTeX
allows code-blocks in footnotes which use a smaller font size).
.. hint::
This specification gives the same spacing as before 1.5::
\normalfont\normalsize\makebox[3ex][r]{\textcolor{red}{\tiny$\hookrightarrow$}
``TitleColor``
default ``{rgb}{0.126,0.263,0.361}``. The colour for titles (as configured
via use of package "titlesec".) It must obey the syntax of the
``\definecolor`` command. Check the documentation of packages ``color`` or
``xcolor``.
``InnerLinkColor``
default ``{rgb}{0.208,0.374,0.486}``. A colour passed to ``hyperref`` as
value of ``linkcolor`` and ``citecolor``.
``OuterLinkColor``
default ``{rgb}{0.216,0.439,0.388}``. A colour passed to ``hyperref`` as
value of ``filecolor``, ``menucolor``, and ``urlcolor``.
``VerbatimColor``
default ``{rgb}{1,1,1}``. The background colour for
:rst:dir:`code-block`\ s. The default is white.
``VerbatimBorderColor``
default ``{rgb}{0,0,0}``. The frame color, defaults to black.
``verbatimsep``
default ``\fboxsep``. The separation between code lines and the frame.
``verbatimborder``
default ``\fboxrule``. The width of the frame around
:rst:dir:`code-block`\ s.
``shadowsep``
default ``5pt``. The separation between contents and frame for
:dudir:`contents` and :dudir:`topic` boxes.
``shadowsize``
default ``4pt``. The width of the lateral "shadow" to the right.
``shadowrule``
default ``\fboxrule``. The width of the frame around :dudir:`topic` boxes.
``noteBorderColor``
default ``{rgb}{0,0,0}``. The colour for the two horizontal rules used by
Sphinx in LaTeX for styling a
:dudir:`note` admonition. Defaults to black.
.. note::
The actual name of the colour as declared to "color" or "xcolor" is
``sphinxnoteBorderColor``. The same "sphinx" prefix applies to all
colours for notices and admonitions.
``hintBorderColor``
default ``{rgb}{0,0,0}``. id.
``importantBorderColor``
default ``{rgb}{0,0,0}``. id.
``tipBorderColor``
default ``{rgb}{0,0,0}``. id.
``noteborder``
default ``0.5pt``. The width of the two horizontal rules.
``hintborder``
default ``0.5pt``. id.
``importantborder``
default ``0.5pt``. id.
``tipborder``
default ``0.5pt``. id.
``warningBorderColor``
default ``{rgb}{0,0,0}``. The colour of the frame for :dudir:`warning` type
admonitions. Defaults to black.
``cautionBorderColor``
default ``{rgb}{0,0,0}``. id.
``attentionBorderColor``
default ``{rgb}{0,0,0}``. id.
``dangerBorderColor``
default ``{rgb}{0,0,0}``. id.
``errorBorderColor``
default ``{rgb}{0,0,0}``. id.
``warningBgColor``
default ``{rgb}{1,1,1}``. The background colour for :dudir:`warning` type
admonition, defaults to white.
``cautionBgColor``
default ``{rgb}{1,1,1}``. id.
``attentionBgColor``
default ``{rgb}{1,1,1}``. id.
``dangerBgColor``
default ``{rgb}{1,1,1}``. id.
``errorBgColor``
default ``{rgb}{1,1,1}``. id.
``warningborder``
default ``1pt``. The width of the frame.
``cautionborder``
default ``1pt``. id.
``attentionborder``
default ``1pt``. id.
``dangerborder``
default ``1pt``. id.
``errorborder``
default ``1pt``. id.
``AtStartFootnote``
default ``\mbox{ }``. LaTeX macros inserted at the start of the footnote
text at bottom of page, after the footnote number.
``BeforeFootnote``
default ``\leavevmode\unskip``. LaTeX macros inserted before the footnote
mark. The default removes possible space before it.
It can be set to empty (``BeforeFootnote={},``) to recover the earlier
behaviour of Sphinx, or alternatively contain a ``\nobreak\space`` or a
``\thinspace`` after the ``\unskip`` to insert some chosen
(non-breakable) space.
.. versionadded:: 1.5
formerly, footnotes from explicit mark-up were
preceded by a space (hence a linebreak there was possible), but
automatically generated footnotes had no such space.
``HeaderFamily``
default ``\sffamily\bfseries``. Sets the font used by headings.
As seen above, key values may even be used for LaTeX commands. But don't
forget to double the backslashes if not using "raw" Python strings.
The LaTeX environments defined by Sphinx
----------------------------------------
Let us now list some macros from the package file
:file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
:file:`sphinxmanual.cls`, which can be entirely redefined, if desired.
- text styling commands (they have one argument): ``\sphinx<foo>`` with
``<foo>`` being one of ``strong``, ``bfcode``, ``email``, ``tablecontinued``,
@@ -84,38 +346,22 @@ from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
.. versionadded:: 1.5
the new macros are wrappers of the formerly hard-coded ``\texttt``,
``\emph``, ... The default definitions can be found near the end of
``\emph``, ... The default definitions can be found in
:file:`sphinx.sty`.
- parameters for paragraph level environments: with ``<foo>`` one of
:dudir:`warning`, :dudir:`caution`, :dudir:`attention`,
:dudir:`danger`, :dudir:`error`, the colours
*sphinx<foo>bordercolor* and *sphinx<foo>bgcolor* can be
re-defined using ``\definecolor`` command. The
``\sphinx<foo>border`` is a command (not a LaTeX length) which
specifies the thickness of the frame (default ``1pt``) and can be
``\renewcommand`` 'd. The same applies with ``<foo>`` one of
:dudir:`note`, :dudir:`hint`, :dudir:`important`, :dudir:`tip`, but
the background colour is not implemented by the default environments
and the top and bottom rule thickness default is ``0.5pt``.
.. versionchanged:: 1.5
customizability of the parameters for each type of admonition.
- paragraph level environments: for each admonition as in the previous item, the
- paragraph level environments: for each admonition type ``<foo>``, the
used environment is named ``sphinx<foo>``. They may be ``\renewenvironment``
'd individually, and must then be defined with one argument (it is the heading
of the notice, for example ``Warning:`` for :dudir:`warning` directive, if
English is the document language). Their default definitions use either the
*sphinxheavybox* (for the first listed directives) or the *sphinxlightbox*
environments, configured to use the parameters (colours, border thickness)
specific to each type, as mentioned in the previous item.
specific to each type, which can be set via ``'sphinxpackageoptions'`` string.
.. versionchanged:: 1.5
use of public environment names, separate customizability of the parameters.
- the :dudir:`contents` directive (with ``:local:`` option) and the
:dudir:`topic` directive are implemented by environment ``sphinxShadowBox``.
Its default definition obeys three LaTeX lengths (not commands) as parameters:
``\sphinxshadowsep`` (distance from contents), ``\sphinxshadowsize`` (width of
lateral shadow), ``\sphinxshadowrule`` (thickness of the frame).
See above for the three dimensions associated with it.
.. versionchanged:: 1.5
use of public names for the three lengths. The environment itself was
@@ -124,8 +370,7 @@ from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
implemented using ``sphinxVerbatim`` environment which is a wrapper of
``Verbatim`` environment from package ``fancyvrb.sty``. It adds the handling
of the top caption and the wrapping of long lines, and a frame which allows
pagebreaks. The LaTeX lengths (not commands) ``\sphinxverbatimsep`` and
``\sphinxverbatimborder`` customize the framing. Inside tables the used
pagebreaks. Inside tables the used
environment is ``sphinxVerbatimintable`` (it does not draw a frame, but
allows a caption).
@@ -134,9 +379,10 @@ from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
which is the one of ``OriginalVerbatim`` too), and custom one is called
``sphinxVerbatim``. Also, earlier version of Sphinx used
``OriginalVerbatim`` inside tables (captions were lost, long code lines
were not wrapped), they now use ``sphinxVerbatimintable``.
were not wrapped), it now uses there ``sphinxVerbatimintable``.
.. versionadded:: 1.5
the two customizable lengths, the ``sphinxVerbatimintable``.
the two customizable lengths, the ``sphinxVerbatimintable``, the boolean
toggles described above.
- by default the Sphinx style file ``sphinx.sty`` includes the command
``\fvset{fontsize=\small}`` as part of its configuration of
``fancyvrb.sty``. The user may override this for example via
@@ -145,30 +391,6 @@ from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
.. versionadded:: 1.5
formerly, the use of ``\small`` for code listings was not customizable.
- miscellaneous colours: *InnerLinkColor*, *OuterLinkColor* (used in
``hyperref`` options), *TitleColor* (used for titles via ``titlesec``),
*VerbatimColor* (background colour) and *VerbatimBorderColor* (used for
displaying source code examples).
- the ``\sphinxAtStartFootnote`` is inserted between footnote numbers and their
texts, by default it does ``\mbox{ }``.
- the ``\sphinxBeforeFootnote`` command is executed before each footnote, its
default definition is::
\newcommand*{\sphinxBeforeFootnote}{\leavevmode\unskip}
You can ``\renewcommand`` it to do nothing in order to recover the earlier
behaviour of Sphinx, or alternatively add a ``\nobreak\space`` or a
``\thinspace`` after the ``\unskip`` in the definition to insert some
(non-breakable) space.
.. versionadded:: 1.5
formerly, footnotes from explicit mark-up were preceded by a space
allowing a linebreak, but automatically generated footnotes had no such
space.
- use ``\sphinxSetHeaderFamily`` to set the font used by headings
(default is ``\sffamily\bfseries``).
.. versionadded:: 1.5
- the section, subsection, ... headings are set using *titlesec*'s
``\titleformat`` command. Check :file:`sphinx.sty` for the definitions.
- for the ``'sphinxmanual'`` class (corresponding to the fifth element of
@@ -196,12 +418,7 @@ from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
.. versionchanged:: 1.5
formerly, the original environments were modified by Sphinx.
.. note::
It is impossible to revert or prevent the loading of a package that results
from a ``\usepackage`` executed from inside the :file:`sphinx.sty` style
file. Sphinx aims at loading as few packages as are really needed for its
default design.
- the list is not exhaustive: refer to :file:`sphinx.sty` for more.
.. hint::
@@ -211,3 +428,7 @@ from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
will be changed in future version.
.. versionadded:: 1.5
.. raw:: latex
\endgroup

View File

@@ -1,6 +1,5 @@
%% Generated by Sphinx.
\def\sphinxdocclass{<%= docclass %>}
<%= passoptionstosphinx %>
\documentclass[<%= papersize %>,<%= pointsize %><%= classoptions %>]{<%= wrapperclass %>}
\ifdefined\pdfpxdimen
\let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
@@ -16,7 +15,8 @@
<%= fontpkg %>
<%= fncychap %>
<%= longtable %>
\usepackage{sphinx}
\usepackage<%= sphinxpkgoptions %>{sphinx}
<%= sphinxsetup %>
\usepackage{multirow}
\usepackage{eqparbox}
<%= usepackages %>

View File

@@ -1,6 +1,6 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{footnotehyper-sphinx}%
[2016/10/16 v0.9f hyperref aware footnote.sty for sphinx (JFB)]
[2016/10/27 v0.9f hyperref aware footnote.sty for sphinx (JFB)]
%%
%% Package: footnotehyper-sphinx
%% Version: based on footnotehyper.sty v0.9f (2016/10/03)
@@ -12,17 +12,7 @@
%% 2. no need to check if footnote.sty was loaded,
%% 3. a special tabulary compatibility layer added, (partial but enough for
%% Sphinx),
%% 4. the \sphinxfootnotemark command is added. Its rôle is to silently remove
%% footnote marks from locations like the tables of contents, or page headers,
%% and to be compatible with hyperref constructions of bookmarks, and survive
%% to \MakeUppercase command or such which may be used to typeset chapter
%% titles for example.
%% 5. the \sphinxBeforeFootnote is added: reST syntax implies that a space token
%% is needed before footnote mark-up like [#]_ and it goes to latex file (and
%% a line break can happen before the footnote mark), but for generated
%% footnotes from latex_show_urls = 'footnote' there is no such space. The
%% hook normalizes this, and by default uses no space.
%%
%% 4. \sphinxfootnotemark, and use of \spx@opt@BeforeFootnote from sphinx.sty.
%% Note: with \footnotemark[N]/\footnotetext[N] syntax, hyperref
%% does not insert an hyperlink. This is _not_ improved here.
%%
@@ -99,8 +89,8 @@
\if@savingnotes\expandafter\fn@fntext\else\expandafter\H@@footnotetext\fi
{\unvbox\z@}\endgroup
}%
%% \sphinxBeforeFootnote added 2016/10/16
\def\FNH@fixed@footnote {\sphinxBeforeFootnote\ifx\@currenvir\fn@footnote
%% \spx@opt@BeforeFootnote is defined in sphinx.sty
\def\FNH@fixed@footnote {\spx@opt@BeforeFootnote\ifx\@currenvir\fn@footnote
\expandafter\FNH@footnoteenv\else\expandafter\fn@latex@@footnote\fi }%
\def\FNH@footnoteenv {\@ifnextchar[\FNH@xfootnoteenv%]
{\stepcounter\@mpfn
@@ -154,15 +144,13 @@
\typeout{\meaning\@makefntext}%
\let\fn@prefntext\@empty\let\fn@postfntext\@empty
}%
%% \sphinxfootnotemark: usable in section titles and silently removed from TOCs
%% \sphinxfootnotemark: usable in section titles and silently removed from
%% TOCs.
\def\sphinxfootnotemark [#1]%
{\ifx\thepage\relax\else \protect\sphinxBeforeFootnote
{\ifx\thepage\relax\else \protect\spx@opt@BeforeFootnote
\protect\footnotemark[#1]\fi}%
\AtBeginDocument
\AtBeginDocument % let hyperref less complain
{\pdfstringdefDisableCommands{\def\sphinxfootnotemark [#1]{}}}%
%% before 1.5, Sphinx left a (breakable) space before user generated footnotes
%% but no space before automatically generated footnotes.
\def\sphinxBeforeFootnote {\leavevmode\unskip}%
\endinput
%%
%% End of file `footnotehyper-sphinx.sty'.

View File

@@ -6,30 +6,10 @@
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2016/10/26 v1.5 LaTeX package (Sphinx markup)]
\ProvidesPackage{sphinx}[2016/10/29 v1.5 LaTeX package (Sphinx markup)]
% Handle package options via "kvoptions" (later loaded by hyperref anyhow)
\RequirePackage{kvoptions}
\SetupKeyvalOptions{prefix=spx@opt@} % use \spx@opt@ prefix
\DeclareBoolOption{dontkeepoldnames} % \ifspx@opt@dontkeepoldnames = \iffalse
\DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
% this is the \ltx@ifundefined of ltxcmds.sty, which is loaded by
% hyperref.sty, but we need it before, and the first release of
% ltxcmds.sty as in TL2009/Debian has wrong definition.
\newcommand{\spx@ifundefined}[1]{%
\ifcsname #1\endcsname
\expandafter\ifx\csname #1\endcsname\relax
\expandafter\expandafter\expandafter\@firstoftwo
\else
\expandafter\expandafter\expandafter\@secondoftwo
\fi
\else
\expandafter\@firstoftwo
\fi
}
% we delay handling of options to after having loaded packages, because
% of the need to use \definecolor.
\RequirePackage{graphicx}
\@ifclassloaded{memoir}{}{\RequirePackage{fancyhdr}}
@@ -53,7 +33,7 @@
\fvset{fontsize=\small}
% For table captions.
\RequirePackage{threeparttable}
% For hyperlinked footnotes in tables; also for gathering footnotes from
% For hyperlinked footnotes in tables; also for gathering footnotes from
% topic and warning blocks. Also to allow code-blocks in footnotes.
\RequirePackage{footnotehyper-sphinx}
\makesavenoteenv{tabulary}
@@ -72,15 +52,122 @@
% Display "real" single quotes in literal blocks.
\RequirePackage{upquote}
% Redefine these colors to your liking in the preamble.
\definecolor{TitleColor}{rgb}{0.126,0.263,0.361}
\definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486}
\definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388}
% Redefine these colors to something if you want to have colored
% background and border for code examples.
\definecolor{VerbatimColor}{rgb}{1,1,1}
\definecolor{VerbatimBorderColor}{rgb}{0,0,0}
% Handle options via "kvoptions" (later loaded by hyperref anyhow)
\RequirePackage{kvoptions}
\SetupKeyvalOptions{prefix=spx@opt@} % use \spx@opt@ prefix
\DeclareBoolOption{dontkeepoldnames} % \ifspx@opt@dontkeepoldnames = \iffalse
\DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
% dimensions, we declare the \dimen registers here.
\newdimen\sphinxverbatimsep
\newdimen\sphinxverbatimborder
\newdimen\sphinxshadowsep
\newdimen\sphinxshadowsize
\newdimen\sphinxshadowrule
% \DeclareStringOption is not convenient for the handling of these dimensions
% because we want to assign the values to the corresponding registers. Even if
% we added the code to the key handler it would be too late for the initial
% set-up and we would need to do initial assignments explicitely. We end up
% using \define@key directly.
% verbatim
\sphinxverbatimsep=\fboxsep
\define@key{sphinx}{verbatimsep}{\sphinxverbatimsep\dimexpr #1\relax}
\sphinxverbatimborder=\fboxrule
\define@key{sphinx}{verbatimborder}{\sphinxverbatimborder\dimexpr #1\relax}
% topic boxes
\sphinxshadowsep =5pt
\define@key{sphinx}{shadowsep}{\sphinxshadowsep\dimexpr #1\relax}
\sphinxshadowsize=4pt
\define@key{sphinx}{shadowsize}{\sphinxshadowsize\dimexpr #1\relax}
\sphinxshadowrule=\fboxrule
\define@key{sphinx}{shadowrule}{\sphinxshadowrule\dimexpr #1\relax}
% verbatim
\DeclareBoolOption[true]{verbatimwithframe}
\DeclareBoolOption[true]{verbatimwrapslines}
% \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}
% notices/admonitions
% the dimensions for notices/admonitions are kept as macros and assigned to
% \spx@notice@border at time of use, hence \DeclareStringOption is ok for this
\newdimen\spx@notice@border
\DeclareStringOption[0.5pt]{noteborder}
\DeclareStringOption[0.5pt]{hintborder}
\DeclareStringOption[0.5pt]{importantborder}
\DeclareStringOption[0.5pt]{tipborder}
\DeclareStringOption[1pt]{warningborder}
\DeclareStringOption[1pt]{cautionborder}
\DeclareStringOption[1pt]{attentionborder}
\DeclareStringOption[1pt]{dangerborder}
\DeclareStringOption[1pt]{errorborder}
% 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 backwards compatibility
\newcommand*{\sphinxDeclareColorOption}[2]{%
\definecolor{#1}#2%
\define@key{sphinx}{#1}{\definecolor{#1}##1}%
}%
\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}{{rgb}{1,1,1}}
\sphinxDeclareColorOption{VerbatimBorderColor}{{rgb}{0,0,0}}
% now the colours defined with "sphinx" prefix in their names
\newcommand*{\sphinxDeclareSphinxColorOption}[2]{%
% set the initial default
\definecolor{sphinx#1}#2%
% set the key handler. The "value" ##1 must be acceptable by \definecolor.
\define@key{sphinx}{#1}{\definecolor{sphinx#1}##1}%
}%
% admonition boxes, "light" style
\sphinxDeclareSphinxColorOption{noteBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{hintBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{importantBorderColor}{{rgb}{0,0,0}}
\sphinxDeclareSphinxColorOption{tipBorderColor}{{rgb}{0,0,0}}
% admonition boxes, "heavy" style
\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}}
\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}}
\DeclareDefaultOption{\@unknownoptionerror}
\ProcessKeyvalOptions*
% don't allow use of maxlistdepth via \sphinxsetup.
\DisableKeyvalOption{sphinx}{maxlistdepth}
% user interface: options can be changed midway in a document!
\newcommand\sphinxsetup[1]{\setkeys{sphinx}{#1}}
% this is the \ltx@ifundefined of ltxcmds.sty, which is loaded by
% hyperref.sty, but we need it before, and the first release of
% ltxcmds.sty as in TL2009/Debian has wrong definition.
\newcommand{\spx@ifundefined}[1]{%
\ifcsname #1\endcsname
\expandafter\ifx\csname #1\endcsname\relax
\expandafter\expandafter\expandafter\@firstoftwo
\else
\expandafter\expandafter\expandafter\@secondoftwo
\fi
\else
\expandafter\@firstoftwo
\fi
}
% FIXME: the reasons might be obsolete (better color drivers now?)
% use pdfoutput for pTeX and dvipdfmx
% when pTeX (\kanjiskip is defined), set pdfoutput to evade \include{pdfcolor}
@@ -117,8 +204,7 @@
\pagestyle{empty} % start this way
% Use this to set the font family for headers and other decor:
\newcommand{\py@HeaderFamily}{\sffamily\bfseries}
\newcommand{\sphinxSetHeaderFamily}[1]{\renewcommand{\py@HeaderFamily}{#1}}
\newcommand{\py@HeaderFamily}{\spx@opt@HeaderFamily}
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
\spx@ifundefined{fancyhf}{}{
@@ -147,7 +233,7 @@
}
% Some custom font markup commands.
% *** the macros without \sphinx prefix are still defined at bottom of file ***
% *** the macros without \sphinx prefix are still defined near end of file ***
\newcommand{\sphinxstrong}[1]{{\textbf{#1}}}
% to obtain straight quotes we execute \@noligs as patched by upquote, the
% macro must be robust in case it is used in captions e.g., and \scantokens is
@@ -165,9 +251,9 @@
\newcommand{\sphinxcrossref}[1]{\emph{#1}}
\newcommand{\sphinxtermref}[1]{\emph{#1}}
% miscellaneous related to footnotes
\newcommand*{\sphinxAtStartFootnote}{\mbox{ }}
% Support large numbered footnotes in minipage (cf. admonitions)
% Support large numbered footnotes in minipage
% But now obsolete due to systematic use of \savenotes/\spewnotes
% when minipages are in use in the various macro definitions next.
\def\thempfootnote{\arabic{mpfootnote}}
% Code-blocks
@@ -185,10 +271,6 @@
\let\endOriginalVerbatim\endVerbatim
\newif\ifspx@inframed % flag set if we are already in a framed environment
\newdimen\sphinxverbatimsep \sphinxverbatimsep \fboxsep % default 3pt
\newdimen\sphinxverbatimborder\sphinxverbatimborder\fboxrule % default 0.4pt
\newif\ifsphinxverbatimwithframe \sphinxverbatimwithframetrue
\newif\ifsphinxverbatimwrapslines \sphinxverbatimwrapslinestrue
% if forced use of minipage encapsulation is needed (e.g. table cells)
\newif\ifsphinxverbatimwithminipage \sphinxverbatimwithminipagefalse
\newcommand\spx@colorbox [2]{%
@@ -264,18 +346,14 @@
% For linebreaks inside Verbatim environment from package fancyvrb.
\newbox\sphinxcontinuationbox
\newbox\sphinxvisiblespacebox
% Customize this via 'preamble' key if desired.
% Use of \textvisiblespace for compatibility with XeTeX/LuaTeX/fontspec.
\newcommand*\sphinxvisiblespace {\textcolor{red}{\textvisiblespace}}
\newcommand*\sphinxcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
\newcommand*\sphinxcontinuationindent {3ex }
\newcommand*\sphinxafterbreak {\kern\sphinxcontinuationindent\copy\sphinxcontinuationbox}
\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\"% $, "
@@ -342,7 +420,7 @@
\fi
\fboxsep\sphinxverbatimsep \fboxrule\sphinxverbatimborder
% setting borderwidth to zero is simplest for no-frame effect with same pagebreaks
\ifsphinxverbatimwithframe\else\fboxrule\z@\fi
\ifspx@opt@verbatimwithframe\else\fboxrule\z@\fi
% Customize framed.sty \MakeFramed to glue caption to literal block
% via \spx@fcolorbox, will use \spx@VerbatimFBox which inserts title
\def\FrameCommand {\spx@colorbox\spx@fcolorbox }%
@@ -350,7 +428,7 @@
% for mid pages and last page portion of (long) split frame:
\def\MidFrameCommand{\spx@colorbox\fcolorbox }%
\let\LastFrameCommand\MidFrameCommand
\ifsphinxverbatimwrapslines
\ifspx@opt@verbatimwrapslines
% fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes.
% This customization wraps each line from the input in a \vtop, thus
% allowing it to wrap and display on two or more lines in the latex output.
@@ -359,8 +437,9 @@
% to achieve this without extensive rewrite of fancyvrb.
% - The (not used in sphinx) obeytabs option to Verbatim is
% broken by this change (showtabs and tabspace work).
\sbox\sphinxcontinuationbox {\sphinxcontinuationsymbol}%
\sbox\sphinxvisiblespacebox {\FV@SetupFont\sphinxvisiblespace}%
\expandafter\def\expandafter\FV@SetupFont\expandafter
{\FV@SetupFont\sbox\sphinxcontinuationbox {\spx@opt@verbatimcontinued}%
\sbox\sphinxvisiblespacebox {\spx@opt@verbatimvisiblespace}}%
\def\FancyVerbFormatLine ##1{\hsize\linewidth
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
\doublehyphendemerits\z@\finalhyphendemerits\z@
@@ -405,7 +484,7 @@
% For grid placement from \strut's in \FancyVerbFormatLine
\lineskip\z@skip
% active comma should not be overwritten by \@noligs
\ifsphinxverbatimwrapslines
\ifspx@opt@verbatimwrapslines
\let\verbatim@nolig@list \sphinx@verbatim@nolig@list
\fi
% will fetch its optional arguments if any
@@ -418,14 +497,14 @@
\endtrivlist
}
\newenvironment {sphinxVerbatimNoFrame}
{\sphinxverbatimwithframefalse
{\spx@opt@verbatimwithframefalse
% needed for fancyvrb as literal code will end in \end{sphinxVerbatimNoFrame}
\def\sphinxVerbatimEnvironment{\gdef\FV@EnvironName{sphinxVerbatimNoFrame}}%
\begin{sphinxVerbatim}}
{\end{sphinxVerbatim}}
\newenvironment {sphinxVerbatimintable}
{% don't use a frame if in a table cell
\sphinxverbatimwithframefalse
\spx@opt@verbatimwithframefalse
\sphinxverbatimwithminipagetrue
% counteract longtable redefinition of caption
\let\caption\sphinxfigcaption
@@ -438,15 +517,6 @@
% Topic boxes
% Again based on use of "framed.sty", this allows breakable framed boxes.
% define macro to frame contents and add shadow on right and bottom
% use public names for customizable lengths
\newlength\sphinxshadowsep \setlength\sphinxshadowsep {5pt}
\newlength\sphinxshadowsize \setlength\sphinxshadowsize {4pt}
\newlength\sphinxshadowrule
% this uses \fboxrule value at loading time of sphinx.sty (0.4pt normally)
\setlength\sphinxshadowrule {\fboxrule}
\long\def\spx@ShadowFBox#1{%
\leavevmode\begingroup
% first we frame the box #1
@@ -546,13 +616,13 @@
% {fulllineitems} is the main environment for object descriptions.
%
\newcommand{\py@itemnewline}[1]{%
\@tempdima\linewidth%
\@tempdima\linewidth
\advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}%
}
\newenvironment{fulllineitems}{
\begin{list}{}{\labelwidth \leftmargin \labelsep 0pt
\rightmargin 0pt \topsep -\parskip \partopsep \parskip
\begin{list}{}{\labelwidth \leftmargin \labelsep \z@
\rightmargin \z@ \topsep -\parskip \partopsep \parskip
\itemsep -\parsep
\let\makelabel=\py@itemnewline}
}{\end{list}}
@@ -573,14 +643,14 @@
% Production lists
%
\newenvironment{productionlist}{
\newenvironment{productionlist}{%
% \def\sphinxoptional##1{{\Large[}##1{\Large]}}
\def\production##1##2{\\\sphinxcode{##1}&::=&\sphinxcode{##2}}
\def\productioncont##1{\\& &\sphinxcode{##1}}
\def\production##1##2{\\\sphinxcode{##1}&::=&\sphinxcode{##2}}%
\def\productioncont##1{\\& &\sphinxcode{##1}}%
\parindent=2em
\indent
\setlength{\LTpre}{0pt}
\setlength{\LTpost}{0pt}
\setlength{\LTpre}{0pt}%
\setlength{\LTpost}{0pt}%
\begin{longtable}[l]{lcl}
}{%
\end{longtable}
@@ -589,6 +659,7 @@
% Notices / Admonitions
% Some are quite plain
% the spx@notice@bordercolor etc are set in the sphinxadmonition environment
\newenvironment{sphinxlightbox}{%
\par\allowbreak
\noindent{\color{spx@notice@bordercolor}%
@@ -614,25 +685,16 @@
{\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
\newenvironment{sphinxtip}[1]
{\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
% or user may just customize the bordercolor and the border width
% re-use \definecolor if change needed, and \renewcommand for rule width
\definecolor{sphinxnotebordercolor}{rgb}{0,0,0}
\definecolor{sphinxhintbordercolor}{rgb}{0,0,0}
\definecolor{sphinximportantbordercolor}{rgb}{0,0,0}
\definecolor{sphinxtipbordercolor}{rgb}{0,0,0}
\newcommand{\sphinxnoteborder}{0.5pt}
\newcommand{\sphinxhintborder}{0.5pt}
\newcommand{\sphinximportantborder}{0.5pt}
\newcommand{\sphinxtipborder}{0.5pt}
% or just use the package options
% these are needed for common handling by notice environment of lightbox
% and heavybox but they are currently not used by lightbox environment
\definecolor{sphinxnotebgcolor}{rgb}{1,1,1}
\definecolor{sphinxhintbgcolor}{rgb}{1,1,1}
\definecolor{sphinximportantbgcolor}{rgb}{1,1,1}
\definecolor{sphinxtipbgcolor}{rgb}{1,1,1}
% and there is consequently no corresponding package option
\definecolor{sphinxnoteBgColor}{rgb}{1,1,1}
\definecolor{sphinxhintBgColor}{rgb}{1,1,1}
\definecolor{sphinimportantBgColor}{rgb}{1,1,1}
\definecolor{sphinxtipBgColor}{rgb}{1,1,1}
% Others get more distinction
\newdimen\spx@notice@border
% Code adapted from framed.sty's "snugshade" environment.
% Nesting works (inner frames do not allow page breaks).
\newenvironment{sphinxheavybox}{\par
@@ -689,22 +751,7 @@
{\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
\newenvironment{sphinxerror}[1]
{\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
% or just re-do \definecolor for colours, \renewcommand for frame width
\definecolor{sphinxwarningbordercolor}{rgb}{0,0,0}
\definecolor{sphinxcautionbordercolor}{rgb}{0,0,0}
\definecolor{sphinxattentionbordercolor}{rgb}{0,0,0}
\definecolor{sphinxdangerbordercolor}{rgb}{0,0,0}
\definecolor{sphinxerrorbordercolor}{rgb}{0,0,0}
\definecolor{sphinxwarningbgcolor}{rgb}{1,1,1}
\definecolor{sphinxcautionbgcolor}{rgb}{1,1,1}
\definecolor{sphinxattentionbgcolor}{rgb}{1,1,1}
\definecolor{sphinxdangerbgcolor}{rgb}{1,1,1}
\definecolor{sphinxerrorbgcolor}{rgb}{1,1,1}
\newcommand{\sphinxwarningborder}{1pt}
\newcommand{\sphinxcautionborder}{1pt}
\newcommand{\sphinxattentionborder}{1pt}
\newcommand{\sphinxdangerborder}{1pt}
\newcommand{\sphinxerrorborder}{1pt}
% or just use package options
% the \colorlet of xcolor (if at all loaded) is overkill for our use case
\newcommand{\sphinxcolorlet}[2]
@@ -719,9 +766,9 @@
% can't use #1 directly in definition of end part
\def\spx@noticetype {#1}%
% set parameters of heavybox/lightbox
\sphinxcolorlet{spx@notice@bordercolor}{sphinx#1bordercolor}%
\sphinxcolorlet{spx@notice@bgcolor}{sphinx#1bgcolor}%
\setlength\spx@notice@border {\dimexpr\csname sphinx#1border\endcsname\relax}%
\sphinxcolorlet{spx@notice@bordercolor}{sphinx#1BorderColor}%
\sphinxcolorlet{spx@notice@bgcolor}{sphinx#1BgColor}%
\spx@notice@border \dimexpr\csname spx@opt@#1border\endcsname\relax
% start specific environment, passing the heading as argument
\begin{sphinx#1}{#2}}
% in end part, need to go around a LaTeX's "feature"
@@ -778,9 +825,9 @@
% Redefine description environment so that it is usable inside fulllineitems.
%
\renewcommand{\description}{%
\list{}{\labelwidth\z@%
\itemindent-\leftmargin%
\labelsep5pt%
\list{}{\labelwidth\z@
\itemindent-\leftmargin
\labelsep5pt\relax
\let\makelabel=\descriptionlabel}}
% Definition lists; requested by AMK for HOWTO documents. Probably useful
@@ -788,7 +835,7 @@
%
\newenvironment{definitions}{%
\begin{description}%
\def\term##1{\item[{##1}]\mbox{}\\*[0mm]}
\def\term##1{\item[{##1}]\mbox{}\\*[0mm]}%
}{%
\end{description}%
}
@@ -816,7 +863,7 @@
{\setlength{\partopsep}{\parskip}
\addtolength{\partopsep}{\baselineskip}
\topsep0pt\itemsep0.15\baselineskip\parsep0pt
\leftmargin#1}
\leftmargin#1\relax}
\raggedright}
{\end{list}}
@@ -862,19 +909,26 @@
\fi
\fi
% These options can be overriden inside 'hyperref' key
% or by later use of \hypersetup.
\PassOptionsToPackage{colorlinks,breaklinks,%
linkcolor=InnerLinkColor,filecolor=OuterLinkColor,%
menucolor=OuterLinkColor,urlcolor=OuterLinkColor,%
citecolor=InnerLinkColor}{hyperref}
% From docutils.writers.latex2e
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
\ifcsname DUrole#1\endcsname%
\ifcsname DUrole#1\endcsname
\csname DUrole#1\endcsname{#2}%
\else% backwards compatibility: try \docutilsrole#1{#2}
\ifcsname docutilsrole#1\endcsname%
\ifcsname docutilsrole#1\endcsname
\csname docutilsrole#1\endcsname{#2}%
\else%
\else
#2%
\fi%
\fi%
\fi
\fi
}
\providecommand*{\DUprovidelength}[2]{%
@@ -987,6 +1041,7 @@
\fi
% additional customizable styling
% FIXME: convert this to package options ?
\newcommand*{\sphinxstyleindexentry}{\texttt}
\newcommand{\sphinxstyleindexextra}[1]{ \emph{(#1)}}
\newcommand*{\sphinxstyleindexpageref}{, \pageref}

View File

@@ -52,6 +52,9 @@ DEFAULT_SETTINGS = {
'classoptions': '',
'extraclassoptions': '',
'maxlistdepth': '',
'sphinxpkgoptions': '',
'sphinxpackageoptions': '',
'sphinxsetup': '',
'passoptionstopackages': '',
'geometry': '\\usepackage[margin=1in,marginparwidth=0.5in]'
'{geometry}',
@@ -69,13 +72,7 @@ DEFAULT_SETTINGS = {
'fncychap': '\\usepackage[Bjarne]{fncychap}',
'longtable': '\\usepackage{longtable}',
'hyperref': ('% Include hyperref last.\n'
'\\usepackage[colorlinks,breaklinks,%\n'
' '
'linkcolor=InnerLinkColor,filecolor=OuterLinkColor,%\n'
' '
'menucolor=OuterLinkColor,urlcolor=OuterLinkColor,%\n'
' '
'citecolor=InnerLinkColor]{hyperref}\n'
'\\usepackage{hyperref}\n'
'% Fix anchor placement for figures with captions.\n'
'\\usepackage{hypcap}% it must be loaded after hyperref.\n'
'% Set up styles of URL: it should be placed after hyperref.\n'
@@ -375,9 +372,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
'releasename': _('Release'),
'indexname': _('Index'),
})
sphinxpkgoptions = ''
if not builder.config.latex_keep_old_macro_names:
sphinxpkgoptions = 'dontkeepoldnames'
self.elements['sphinxpkgoptions'] = 'dontkeepoldnames'
if document.settings.docclass == 'howto':
docclass = builder.config.latex_docclass.get('howto', 'article')
else:
@@ -452,10 +448,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.check_latex_elements()
self.elements.update(builder.config.latex_elements)
if self.elements['maxlistdepth']:
sphinxpkgoptions += ',maxlistdepth=%s' % self.elements['maxlistdepth']
if sphinxpkgoptions:
self.elements['passoptionstosphinx'] = \
'\\PassOptionsToPackage{%s}{sphinx}' % sphinxpkgoptions
self.elements['sphinxpkgoptions'] = \
','.join(self.elements['sphinxpkgoptions'], 'maxlistdepth=%s' %
self.elements['maxlistdepth'])
if self.elements['sphinxpkgoptions']:
self.elements['sphinxpkgoptions'] = ('[%s]' %
self.elements['sphinxpkgoptions'])
if self.elements['sphinxpackageoptions']:
self.elements['sphinxsetup'] = ('\\sphinxsetup{%s}' %
self.elements['sphinxpackageoptions'])
if self.elements['extraclassoptions']:
self.elements['classoptions'] += ',' + \
self.elements['extraclassoptions']