elog2labfolder/_build/latex/sphinx.sty
changeset 3 b71be85a294c
equal deleted inserted replaced
2:5e51ce17f274 3:b71be85a294c
       
     1 %
       
     2 % sphinx.sty
       
     3 %
       
     4 % Adapted from the old python.sty, mostly written by Fred Drake,
       
     5 % by Georg Brandl.
       
     6 %
       
     7 
       
     8 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
       
     9 \ProvidesPackage{sphinx}[2017/12/12 v1.6.6 LaTeX package (Sphinx markup)]
       
    10 
       
    11 % provides \ltx@ifundefined
       
    12 % (many packages load ltxcmds: graphicx does for pdftex and lualatex but
       
    13 % not xelatex, and anyhow kvoptions does, but it may be needed in future to
       
    14 % use \sphinxdeprecationwarning earlier, and it needs \ltx@ifundefined)
       
    15 \RequirePackage{ltxcmds}
       
    16 
       
    17 %% for deprecation warnings
       
    18 \newcommand\sphinxdeprecationwarning[4]{% #1 the deprecated macro or name,
       
    19 % #2 = when deprecated, #3 = when removed, #4 = additional info
       
    20   \edef\spx@tempa{\detokenize{#1}}%
       
    21   \ltx@ifundefined{sphinx_depr_\spx@tempa}{%
       
    22      \global\expandafter\let\csname sphinx_depr_\spx@tempa\endcsname\spx@tempa
       
    23      \expandafter\AtEndDocument\expandafter{\expandafter\let\expandafter
       
    24          \sphinxdeprecatedmacro\csname sphinx_depr_\spx@tempa\endcsname
       
    25          \PackageWarningNoLine{sphinx}{^^J**** SPHINX DEPRECATION WARNING:^^J
       
    26          \sphinxdeprecatedmacro^^J
       
    27          \@spaces- is deprecated at Sphinx #2^^J
       
    28          \@spaces- and removed at Sphinx #3.^^J
       
    29          #4^^J****}}%
       
    30   }{% warning already emitted (at end of latex log), don't repeat
       
    31   }}
       
    32 
       
    33 
       
    34 %% PACKAGES
       
    35 %
       
    36 % we delay handling of options to after having loaded packages, because
       
    37 % of the need to use \definecolor.
       
    38 \RequirePackage{graphicx}
       
    39 \@ifclassloaded{memoir}{}{\RequirePackage{fancyhdr}}
       
    40 % for \text macro and \iffirstchoice@ conditional even if amsmath not loaded
       
    41 \RequirePackage{amstext}
       
    42 \RequirePackage[warn]{textcomp}
       
    43 \RequirePackage{titlesec}
       
    44 \@ifpackagelater{titlesec}{2016/03/15}%
       
    45  {\@ifpackagelater{titlesec}{2016/03/21}%
       
    46   {}%
       
    47   {\newif\ifsphinx@ttlpatch@ok
       
    48    \IfFileExists{etoolbox.sty}{%
       
    49      \RequirePackage{etoolbox}%
       
    50      \patchcmd{\ttlh@hang}{\parindent\z@}{\parindent\z@\leavevmode}%
       
    51                                 {\sphinx@ttlpatch@oktrue}{}%
       
    52      \ifsphinx@ttlpatch@ok
       
    53      \patchcmd{\ttlh@hang}{\noindent}{}{}{\sphinx@ttlpatch@okfalse}%
       
    54      \fi
       
    55    }{}%
       
    56    \ifsphinx@ttlpatch@ok
       
    57      \typeout{^^J Package Sphinx Info: ^^J
       
    58               **** titlesec 2.10.1 successfully patched for bugfix ****^^J}%
       
    59    \else
       
    60      \AtEndDocument{\PackageWarningNoLine{sphinx}{^^J%
       
    61 ******** titlesec 2.10.1 has a bug, (section numbers disappear) ......|^^J%
       
    62 ******** and Sphinx could not patch it, perhaps because your local ...|^^J%
       
    63 ******** copy is already fixed without a changed release date. .......|^^J%
       
    64 ******** If not, you must update titlesec! ...........................|}}%
       
    65    \fi
       
    66   }%
       
    67  }{}
       
    68 \RequirePackage{tabulary}
       
    69 % tabulary has a bug with its re-definition of \multicolumn in its first pass
       
    70 % which is not \long. But now Sphinx does not use LaTeX's \multicolumn but its
       
    71 % own macro. Hence we don't even need to patch tabulary. See sphinxmulticell.sty
       
    72 % X or S (Sphinx) may have meanings if some table package is loaded hence
       
    73 % \X was chosen to avoid possibility of conflict
       
    74 \newcolumntype{\X}[2]{p{\dimexpr
       
    75       (\linewidth-\arrayrulewidth)*#1/#2-\tw@\tabcolsep-\arrayrulewidth\relax}}
       
    76 \newcolumntype{\Y}[1]{p{\dimexpr
       
    77       #1\dimexpr\linewidth-\arrayrulewidth\relax-\tw@\tabcolsep-\arrayrulewidth\relax}}
       
    78 % using here T (for Tabulary) feels less of a problem than the X could be
       
    79 \newcolumntype{T}{J}%
       
    80 % For tables allowing pagebreaks
       
    81 \RequirePackage{longtable}
       
    82 % User interface to set-up whitespace before and after tables:
       
    83 \newcommand*\sphinxtablepre {0pt}%
       
    84 \newcommand*\sphinxtablepost{\medskipamount}%
       
    85 \newcommand*\sphinxbelowcaptionspace{.5\sphinxbaselineskip}%
       
    86 % as one can not use \baselineskip from inside longtable (it is zero there)
       
    87 % we need \sphinxbaselineskip, which defaults to \baselineskip
       
    88 \def\sphinxbaselineskip{\baselineskip}%
       
    89 % These commands are inserted by the table templates
       
    90 \def\sphinxatlongtablestart
       
    91    {\par
       
    92     \vskip\parskip
       
    93     \vskip\dimexpr\sphinxtablepre\relax % adjust vertical position
       
    94     \vbox{}% get correct baseline from above
       
    95     \LTpre\z@skip\LTpost\z@skip % set to zero longtable's own skips
       
    96     \edef\sphinxbaselineskip{\dimexpr\the\dimexpr\baselineskip\relax\relax}%
       
    97    }%
       
    98 \def\sphinxatlongtableend{\prevdepth\z@\vskip\sphinxtablepost\relax}%
       
    99 \def\sphinxlongtablecapskipadjust
       
   100    {\dimexpr-\dp\strutbox-\sphinxbaselineskip+\sphinxbelowcaptionspace\relax}%
       
   101 % Now for tables not using longtable
       
   102 \def\sphinxattablestart
       
   103    {\par
       
   104     \vskip\dimexpr\sphinxtablepre\relax
       
   105    }%
       
   106 \let\sphinxattableend\sphinxatlongtableend
       
   107 % longtable's wraps captions to a maximal width of \LTcapwidth
       
   108 % so we do the same for all tables
       
   109 \newcommand*\sphinxcapstartof[1]{%
       
   110    \vskip\parskip
       
   111    \vbox{}% force baselineskip for good positioning by capstart of hyperanchor
       
   112    \def\@captype{#1}%
       
   113    \capstart
       
   114 % move back vertically to compensate space inserted by next paragraph
       
   115    \vskip-\baselineskip\vskip-\parskip
       
   116 }%
       
   117 \newcommand\sphinxcaption[2][\LTcapwidth]{%
       
   118    \noindent\hb@xt@\linewidth{\hss
       
   119       \vtop{\@tempdima\dimexpr#1\relax
       
   120 % don't exceed linewidth for the caption width
       
   121             \ifdim\@tempdima>\linewidth\hsize\linewidth\else\hsize\@tempdima\fi
       
   122 % longtable ignores \abovecaptionskip/\belowcaptionskip, so do the same here
       
   123             \abovecaptionskip\z@skip
       
   124             \belowcaptionskip\z@skip
       
   125             \caption[{#2}]%
       
   126                {\strut\ignorespaces#2\ifhmode\unskip\@finalstrut\strutbox\fi}%
       
   127            }\hss}%
       
   128    \par\prevdepth\dp\strutbox
       
   129 }%
       
   130 \newcommand\sphinxaftercaption
       
   131 {% this default definition serves with a caption *above* a table, to make sure
       
   132  % its last baseline is \sphinxbelowcaptionspace above table top
       
   133  \nobreak
       
   134    \vskip\dimexpr\sphinxbelowcaptionspace\relax
       
   135    \vskip-\baselineskip\vskip-\parskip
       
   136 }%
       
   137 % varwidth is crucial for our handling of general contents in merged cells
       
   138 \RequirePackage{varwidth}
       
   139 % but addition of a compatibility patch with hyperref is needed
       
   140 % (tested with varwidth v 0.92  Mar 2009)
       
   141 \AtBeginDocument {%
       
   142     \let\@@vwid@Hy@raisedlink\Hy@raisedlink
       
   143     \long\def\@vwid@Hy@raisedlink#1{\@vwid@wrap{\@@vwid@Hy@raisedlink{#1}}}%
       
   144     \edef\@vwid@setup{%
       
   145       \let\noexpand\Hy@raisedlink\noexpand\@vwid@Hy@raisedlink % HYPERREF !
       
   146       \unexpanded\expandafter{\@vwid@setup}}%
       
   147 }%
       
   148 % Homemade package to handle merged cells
       
   149 \RequirePackage{sphinxmulticell}
       
   150 \RequirePackage{makeidx}
       
   151 % For framing code-blocks and warning type notices, and shadowing topics
       
   152 \RequirePackage{framed}
       
   153 % The xcolor package draws better fcolorboxes around verbatim code
       
   154 \IfFileExists{xcolor.sty}{
       
   155     \RequirePackage{xcolor}
       
   156 }{
       
   157     \RequirePackage{color}
       
   158 }
       
   159 % For highlighted code.
       
   160 \RequirePackage{fancyvrb}
       
   161 \fvset{fontsize=\small}
       
   162 \define@key{FV}{hllines}{\def\sphinx@verbatim@checkifhl##1{\in@{, ##1,}{#1}}}
       
   163 % For hyperlinked footnotes in tables; also for gathering footnotes from
       
   164 % topic and warning blocks. Also to allow code-blocks in footnotes.
       
   165 \RequirePackage{footnotehyper-sphinx}
       
   166 % For the H specifier. Do not \restylefloat{figure}, it breaks Sphinx code
       
   167 % for allowing figures in tables.
       
   168 \RequirePackage{float}
       
   169 % For floating figures in the text. Better to load after float.
       
   170 \RequirePackage{wrapfig}
       
   171 % Separate paragraphs by space by default.
       
   172 \RequirePackage{parskip}
       
   173 % For parsed-literal blocks.
       
   174 \RequirePackage{alltt}
       
   175 % Display "real" single quotes in literal blocks.
       
   176 \RequirePackage{upquote}
       
   177 % control caption around literal-block
       
   178 \RequirePackage{capt-of}
       
   179 \RequirePackage{needspace}
       
   180 
       
   181 % to make pdf with correct encoded bookmarks in Japanese
       
   182 % this should precede the hyperref package
       
   183 \ifx\kanjiskip\undefined
       
   184 % for non-Japanese: make sure bookmarks are ok also with lualatex
       
   185   \PassOptionsToPackage{pdfencoding=unicode}{hyperref}
       
   186 \else
       
   187   \RequirePackage{atbegshi}
       
   188   \ifx\ucs\undefined
       
   189     \ifnum 42146=\euc"A4A2
       
   190       \AtBeginShipoutFirst{\special{pdf:tounicode EUC-UCS2}}
       
   191     \else
       
   192       \AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
       
   193     \fi
       
   194   \else
       
   195     \AtBeginShipoutFirst{\special{pdf:tounicode UTF8-UCS2}}
       
   196   \fi
       
   197 \fi
       
   198 
       
   199 \ifx\@jsc@uplatextrue\undefined\else
       
   200   \PassOptionsToPackage{setpagesize=false}{hyperref}
       
   201 \fi
       
   202 
       
   203 % These options can be overriden inside  'hyperref' key
       
   204 % or by later use of \hypersetup.
       
   205 \PassOptionsToPackage{colorlinks,breaklinks,%
       
   206  linkcolor=InnerLinkColor,filecolor=OuterLinkColor,%
       
   207  menucolor=OuterLinkColor,urlcolor=OuterLinkColor,%
       
   208  citecolor=InnerLinkColor}{hyperref}
       
   209 
       
   210 % stylesheet for highlighting with pygments
       
   211 \RequirePackage{sphinxhighlight}
       
   212 % fix baseline increase from Pygments latex formatter in case of error tokens
       
   213 % and keep \fboxsep's scope local via added braces
       
   214 \def\PYG@tok@err{%
       
   215     \def\PYG@bc##1{{\setlength{\fboxsep}{-\fboxrule}%
       
   216                     \fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}%
       
   217 }
       
   218 \def\PYG@tok@cs{%
       
   219     \def\PYG@tc##1{\textcolor[rgb]{0.25,0.50,0.56}{##1}}%
       
   220     \def\PYG@bc##1{{\setlength{\fboxsep}{0pt}%
       
   221                     \colorbox[rgb]{1.00,0.94,0.94}{\strut ##1}}}%
       
   222 }%
       
   223 
       
   224 
       
   225 %% OPTIONS
       
   226 %
       
   227 % Handle options via "kvoptions" (later loaded by hyperref anyhow)
       
   228 \RequirePackage{kvoptions}
       
   229 \SetupKeyvalOptions{prefix=spx@opt@} % use \spx@opt@ prefix
       
   230 
       
   231 % Sphinx legacy text layout: 1in margins on all four sides
       
   232 \ifx\@jsc@uplatextrue\undefined
       
   233 \DeclareStringOption[1in]{hmargin}
       
   234 \DeclareStringOption[1in]{vmargin}
       
   235 \DeclareStringOption[.5in]{marginpar}
       
   236 \else
       
   237 % Japanese standard document classes handle \mag in a special way
       
   238 \DeclareStringOption[\inv@mag in]{hmargin}
       
   239 \DeclareStringOption[\inv@mag in]{vmargin}
       
   240 \DeclareStringOption[.5\dimexpr\inv@mag in\relax]{marginpar}
       
   241 \fi
       
   242 
       
   243 \DeclareBoolOption{dontkeepoldnames} % \ifspx@opt@dontkeepoldnames = \iffalse
       
   244 \DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
       
   245 
       
   246 % dimensions, we declare the \dimen registers here.
       
   247 \newdimen\sphinxverbatimsep
       
   248 \newdimen\sphinxverbatimborder
       
   249 \newdimen\sphinxshadowsep
       
   250 \newdimen\sphinxshadowsize
       
   251 \newdimen\sphinxshadowrule
       
   252 % \DeclareStringOption is not convenient for the handling of these dimensions
       
   253 % because we want to assign the values to the corresponding registers. Even if
       
   254 % we added the code to the key handler it would be too late for the initial
       
   255 % set-up and we would need to do initial assignments explicitely. We end up
       
   256 % using \define@key directly.
       
   257 % verbatim
       
   258 \sphinxverbatimsep=\fboxsep
       
   259   \define@key{sphinx}{verbatimsep}{\sphinxverbatimsep\dimexpr #1\relax}
       
   260 \sphinxverbatimborder=\fboxrule
       
   261   \define@key{sphinx}{verbatimborder}{\sphinxverbatimborder\dimexpr #1\relax}
       
   262 % topic boxes
       
   263 \sphinxshadowsep =5pt
       
   264   \define@key{sphinx}{shadowsep}{\sphinxshadowsep\dimexpr #1\relax}
       
   265 \sphinxshadowsize=4pt
       
   266   \define@key{sphinx}{shadowsize}{\sphinxshadowsize\dimexpr #1\relax}
       
   267 \sphinxshadowrule=\fboxrule
       
   268   \define@key{sphinx}{shadowrule}{\sphinxshadowrule\dimexpr #1\relax}
       
   269 % verbatim
       
   270 \DeclareBoolOption[true]{verbatimwithframe}
       
   271 \DeclareBoolOption[true]{verbatimwrapslines}
       
   272 \DeclareBoolOption[false]{verbatimhintsturnover}
       
   273 \DeclareBoolOption[true]{inlineliteralwraps}
       
   274 % parsed literal
       
   275 \DeclareBoolOption[true]{parsedliteralwraps}
       
   276 % \textvisiblespace for compatibility with fontspec+XeTeX/LuaTeX
       
   277 \DeclareStringOption[\textcolor{red}{\textvisiblespace}]{verbatimvisiblespace}
       
   278 \DeclareStringOption % must use braces to hide the brackets
       
   279   [{\makebox[2\fontcharwd\font`\x][r]{\textcolor{red}{\tiny$\m@th\hookrightarrow$}}}]%
       
   280   {verbatimcontinued}
       
   281 % notices/admonitions
       
   282 % the dimensions for notices/admonitions are kept as macros and assigned to
       
   283 % \spx@notice@border at time of use, hence \DeclareStringOption is ok for this
       
   284 \newdimen\spx@notice@border
       
   285 \DeclareStringOption[0.5pt]{noteborder}
       
   286 \DeclareStringOption[0.5pt]{hintborder}
       
   287 \DeclareStringOption[0.5pt]{importantborder}
       
   288 \DeclareStringOption[0.5pt]{tipborder}
       
   289 \DeclareStringOption[1pt]{warningborder}
       
   290 \DeclareStringOption[1pt]{cautionborder}
       
   291 \DeclareStringOption[1pt]{attentionborder}
       
   292 \DeclareStringOption[1pt]{dangerborder}
       
   293 \DeclareStringOption[1pt]{errorborder}
       
   294 % footnotes
       
   295 \DeclareStringOption[\mbox{ }]{AtStartFootnote}
       
   296 % we need a public macro name for direct use in latex file
       
   297 \newcommand*{\sphinxAtStartFootnote}{\spx@opt@AtStartFootnote}
       
   298 % no such need for this one, as it is used inside other macros
       
   299 \DeclareStringOption[\leavevmode\unskip]{BeforeFootnote}
       
   300 % some font styling.
       
   301 \DeclareStringOption[\sffamily\bfseries]{HeaderFamily}
       
   302 % colours
       
   303 % same problems as for dimensions: we want the key handler to use \definecolor.
       
   304 % first, some colours with no prefix, for backwards compatibility
       
   305 \newcommand*{\sphinxDeclareColorOption}[2]{%
       
   306    \definecolor{#1}#2%
       
   307    \define@key{sphinx}{#1}{\definecolor{#1}##1}%
       
   308 }%
       
   309 \sphinxDeclareColorOption{TitleColor}{{rgb}{0.126,0.263,0.361}}
       
   310 \sphinxDeclareColorOption{InnerLinkColor}{{rgb}{0.208,0.374,0.486}}
       
   311 \sphinxDeclareColorOption{OuterLinkColor}{{rgb}{0.216,0.439,0.388}}
       
   312 \sphinxDeclareColorOption{VerbatimColor}{{rgb}{1,1,1}}
       
   313 \sphinxDeclareColorOption{VerbatimBorderColor}{{rgb}{0,0,0}}
       
   314 % now the colours defined with "sphinx" prefix in their names
       
   315 \newcommand*{\sphinxDeclareSphinxColorOption}[2]{%
       
   316    % set the initial default
       
   317    \definecolor{sphinx#1}#2%
       
   318    % set the key handler. The "value" ##1 must be acceptable by \definecolor.
       
   319    \define@key{sphinx}{#1}{\definecolor{sphinx#1}##1}%
       
   320 }%
       
   321 % Default color chosen to be as in minted.sty LaTeX package!
       
   322 \sphinxDeclareSphinxColorOption{VerbatimHighlightColor}{{rgb}{0.878,1,1}}
       
   323 % admonition boxes, "light" style
       
   324 \sphinxDeclareSphinxColorOption{noteBorderColor}{{rgb}{0,0,0}}
       
   325 \sphinxDeclareSphinxColorOption{hintBorderColor}{{rgb}{0,0,0}}
       
   326 \sphinxDeclareSphinxColorOption{importantBorderColor}{{rgb}{0,0,0}}
       
   327 \sphinxDeclareSphinxColorOption{tipBorderColor}{{rgb}{0,0,0}}
       
   328 % admonition boxes, "heavy" style
       
   329 \sphinxDeclareSphinxColorOption{warningBorderColor}{{rgb}{0,0,0}}
       
   330 \sphinxDeclareSphinxColorOption{cautionBorderColor}{{rgb}{0,0,0}}
       
   331 \sphinxDeclareSphinxColorOption{attentionBorderColor}{{rgb}{0,0,0}}
       
   332 \sphinxDeclareSphinxColorOption{dangerBorderColor}{{rgb}{0,0,0}}
       
   333 \sphinxDeclareSphinxColorOption{errorBorderColor}{{rgb}{0,0,0}}
       
   334 \sphinxDeclareSphinxColorOption{warningBgColor}{{rgb}{1,1,1}}
       
   335 \sphinxDeclareSphinxColorOption{cautionBgColor}{{rgb}{1,1,1}}
       
   336 \sphinxDeclareSphinxColorOption{attentionBgColor}{{rgb}{1,1,1}}
       
   337 \sphinxDeclareSphinxColorOption{dangerBgColor}{{rgb}{1,1,1}}
       
   338 \sphinxDeclareSphinxColorOption{errorBgColor}{{rgb}{1,1,1}}
       
   339 
       
   340 \DeclareDefaultOption{\@unknownoptionerror}
       
   341 \ProcessKeyvalOptions*
       
   342 % don't allow use of maxlistdepth via \sphinxsetup.
       
   343 \DisableKeyvalOption{sphinx}{maxlistdepth}
       
   344 % user interface: options can be changed midway in a document!
       
   345 \newcommand\sphinxsetup[1]{\setkeys{sphinx}{#1}}
       
   346 
       
   347 
       
   348 %% MAXLISTDEPTH
       
   349 %
       
   350 % remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.
       
   351 % This is a hack, which works with the standard classes: it assumes \@toodeep
       
   352 % is always used in "true" branches: "\if ... \@toodeep \else .. \fi."
       
   353 
       
   354 % will force use the "false" branch (if there is one)
       
   355 \def\spx@toodeep@hack{\fi\iffalse}
       
   356 
       
   357 % do nothing if 'maxlistdepth' key not used or if package enumitem loaded.
       
   358 \ifnum\spx@opt@maxlistdepth=\z@\expandafter\@gobbletwo\fi
       
   359 \AtBeginDocument{%
       
   360 \@ifpackageloaded{enumitem}{\remove@to@nnil}{}%
       
   361   \let\spx@toodeepORI\@toodeep
       
   362   \def\@toodeep{%
       
   363     \ifnum\@listdepth<\spx@opt@maxlistdepth\relax
       
   364       \expandafter\spx@toodeep@hack
       
   365     \else
       
   366       \expandafter\spx@toodeepORI
       
   367     \fi}%
       
   368 % define all missing \@list... macros
       
   369   \count@\@ne
       
   370   \loop
       
   371      \ltx@ifundefined{@list\romannumeral\the\count@}
       
   372        {\iffalse}{\iftrue\advance\count@\@ne}%
       
   373   \repeat
       
   374   \loop
       
   375      \ifnum\count@>\spx@opt@maxlistdepth\relax\else
       
   376        \expandafter\let
       
   377          \csname @list\romannumeral\the\count@\expandafter\endcsname
       
   378          \csname @list\romannumeral\the\numexpr\count@-\@ne\endcsname
       
   379        % workaround 2.6--3.2d babel-french issue (fixed in 3.2e; no change needed)
       
   380        \ltx@ifundefined{leftmargin\romannumeral\the\count@}
       
   381        {\expandafter\let
       
   382          \csname leftmargin\romannumeral\the\count@\expandafter\endcsname
       
   383          \csname leftmargin\romannumeral\the\numexpr\count@-\@ne\endcsname}{}%
       
   384      \advance\count@\@ne
       
   385   \repeat
       
   386 % define all missing enum... counters and \labelenum... macros and \p@enum..
       
   387   \count@\@ne
       
   388   \loop
       
   389      \ltx@ifundefined{c@enum\romannumeral\the\count@}
       
   390        {\iffalse}{\iftrue\advance\count@\@ne}%
       
   391   \repeat
       
   392   \loop
       
   393      \ifnum\count@>\spx@opt@maxlistdepth\relax\else
       
   394        \newcounter{enum\romannumeral\the\count@}%
       
   395        \expandafter\def
       
   396          \csname labelenum\romannumeral\the\count@\expandafter\endcsname
       
   397          \expandafter
       
   398          {\csname theenum\romannumeral\the\numexpr\count@\endcsname.}%
       
   399        \expandafter\def
       
   400          \csname p@enum\romannumeral\the\count@\expandafter\endcsname
       
   401          \expandafter
       
   402          {\csname p@enum\romannumeral\the\numexpr\count@-\@ne\expandafter
       
   403           \endcsname\csname theenum\romannumeral\the\numexpr\count@-\@ne\endcsname.}%
       
   404      \advance\count@\@ne
       
   405   \repeat
       
   406 % define all missing labelitem... macros
       
   407   \count@\@ne
       
   408   \loop
       
   409      \ltx@ifundefined{labelitem\romannumeral\the\count@}
       
   410      {\iffalse}{\iftrue\advance\count@\@ne}%
       
   411   \repeat
       
   412   \loop
       
   413      \ifnum\count@>\spx@opt@maxlistdepth\relax\else
       
   414        \expandafter\let
       
   415          \csname labelitem\romannumeral\the\count@\expandafter\endcsname
       
   416          \csname labelitem\romannumeral\the\numexpr\count@-\@ne\endcsname
       
   417      \advance\count@\@ne
       
   418   \repeat
       
   419   \PackageInfo{sphinx}{maximal list depth extended to \spx@opt@maxlistdepth}%
       
   420 \@gobble\@nnil
       
   421 }
       
   422 
       
   423 
       
   424 %% INDEX, BIBLIOGRAPHY, APPENDIX, TABLE OF CONTENTS
       
   425 %
       
   426 % fix the double index and bibliography on the table of contents
       
   427 % in jsclasses (Japanese standard document classes)
       
   428 \ifx\@jsc@uplatextrue\undefined\else
       
   429   \renewenvironment{sphinxtheindex}
       
   430     {\cleardoublepage\phantomsection
       
   431      \begin{theindex}}
       
   432     {\end{theindex}}
       
   433 
       
   434   \renewenvironment{sphinxthebibliography}[1]
       
   435     {\cleardoublepage% \phantomsection % not needed here since TeXLive 2010's hyperref
       
   436      \begin{thebibliography}{1}}
       
   437     {\end{thebibliography}}
       
   438 \fi
       
   439 
       
   440 % disable \@chappos in Appendix in pTeX
       
   441 \ifx\kanjiskip\undefined\else
       
   442   \let\py@OldAppendix=\appendix
       
   443   \renewcommand{\appendix}{
       
   444     \py@OldAppendix
       
   445     \gdef\@chappos{}
       
   446   }
       
   447 \fi
       
   448 
       
   449 % make commands known to non-Sphinx document classes
       
   450 \providecommand*{\sphinxtableofcontents}{\tableofcontents}
       
   451 \ltx@ifundefined{sphinxthebibliography}
       
   452  {\newenvironment
       
   453   {sphinxthebibliography}{\begin{thebibliography}}{\end{thebibliography}}%
       
   454  }
       
   455  {}% else clause of ifundefined
       
   456 \ltx@ifundefined{sphinxtheindex}
       
   457  {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}%
       
   458  {}% else clause of ifundefined
       
   459 
       
   460 
       
   461 %% COLOR (general)
       
   462 %
       
   463 % FIXME: \normalcolor should probably be used in place of \py@NormalColor
       
   464 % elsewhere, and \py@NormalColor should never be defined. \normalcolor
       
   465 % switches to the colour from last \color call in preamble.
       
   466 \def\py@NormalColor{\color{black}}
       
   467 % FIXME: it is probably better to use \color{TitleColor}, as TitleColor
       
   468 % can be customized from 'sphinxsetup', and drop usage of \py@TitleColor
       
   469 \def\py@TitleColor{\color{TitleColor}}
       
   470 % FIXME: this line should be dropped, as "9" is default anyhow.
       
   471 \ifdefined\pdfcompresslevel\pdfcompresslevel = 9 \fi
       
   472 
       
   473 
       
   474 %% PAGE STYLING
       
   475 %
       
   476 % Style parameters and macros used by most documents here
       
   477 \raggedbottom
       
   478 \sloppy
       
   479 \hbadness = 5000                % don't print trivial gripes
       
   480 
       
   481 \pagestyle{empty}               % start this way
       
   482 
       
   483 % Redefine the 'normal' header/footer style when using "fancyhdr" package:
       
   484 % Note: this presupposes "twoside". If "oneside" class option, there will be warnings.
       
   485 \ltx@ifundefined{fancyhf}{}{
       
   486   % Use \pagestyle{normal} as the primary pagestyle for text.
       
   487   \fancypagestyle{normal}{
       
   488     \fancyhf{}
       
   489 % (for \py@HeaderFamily cf "TITLES")
       
   490     \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
       
   491     \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
       
   492     \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
       
   493     \fancyhead[LE,RO]{{\py@HeaderFamily \@title, \py@release}}
       
   494     \renewcommand{\headrulewidth}{0.4pt}
       
   495     \renewcommand{\footrulewidth}{0.4pt}
       
   496     % define chaptermark with \@chappos when \@chappos is available for Japanese
       
   497     \ltx@ifundefined{@chappos}{}
       
   498       {\def\chaptermark##1{\markboth{\@chapapp\space\thechapter\space\@chappos\space ##1}{}}}
       
   499   }
       
   500   % Update the plain style so we get the page number & footer line,
       
   501   % but not a chapter or section title.  This is to keep the first
       
   502   % page of a chapter and the blank page between chapters `clean.'
       
   503   \fancypagestyle{plain}{
       
   504     \fancyhf{}
       
   505     \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
       
   506     \renewcommand{\headrulewidth}{0pt}
       
   507     \renewcommand{\footrulewidth}{0.4pt}
       
   508   }
       
   509 }
       
   510 
       
   511 % geometry
       
   512 \ifx\kanjiskip\undefined
       
   513   \PassOptionsToPackage{%
       
   514      hmargin={\unexpanded{\spx@opt@hmargin}},%
       
   515      vmargin={\unexpanded{\spx@opt@vmargin}},%
       
   516      marginpar=\unexpanded{\spx@opt@marginpar}}
       
   517   {geometry}
       
   518 \else
       
   519  % set text width for Japanese documents to be integer multiple of 1zw
       
   520  % and text height to be integer multiple of \baselineskip
       
   521  % the execution is delayed to \sphinxsetup then geometry.sty
       
   522  \normalsize\normalfont
       
   523  \newcommand*\sphinxtextwidthja[1]{%
       
   524     \if@twocolumn\tw@\fi
       
   525     \dimexpr
       
   526        \numexpr\dimexpr\paperwidth-\tw@\dimexpr#1\relax\relax/
       
   527                \dimexpr\if@twocolumn\tw@\else\@ne\fi zw\relax
       
   528     zw\relax}%
       
   529  \newcommand*\sphinxmarginparwidthja[1]{%
       
   530     \dimexpr\numexpr\dimexpr#1\relax/\dimexpr1zw\relax zw\relax}%
       
   531  \newcommand*\sphinxtextlinesja[1]{%
       
   532     \numexpr\@ne+\dimexpr\paperheight-\topskip-\tw@\dimexpr#1\relax\relax/
       
   533                  \baselineskip\relax}%
       
   534  \ifx\@jsc@uplatextrue\undefined\else
       
   535  % the way we found in order for the papersize special written by
       
   536  % geometry in the dvi file to be correct in case of jsbook class
       
   537    \ifnum\mag=\@m\else % do nothing special if nomag class option or 10pt
       
   538      \PassOptionsToPackage{truedimen}{geometry}%
       
   539    \fi
       
   540  \fi
       
   541  \PassOptionsToPackage{%
       
   542     hmarginratio={1:1},%
       
   543     textwidth=\unexpanded{\sphinxtextwidthja{\spx@opt@hmargin}},%
       
   544     vmarginratio={1:1},%
       
   545     lines=\unexpanded{\sphinxtextlinesja{\spx@opt@vmargin}},%
       
   546     marginpar=\unexpanded{\sphinxmarginparwidthja{\spx@opt@marginpar}},%
       
   547     footskip=2\baselineskip,%
       
   548   }{geometry}%
       
   549  \AtBeginDocument
       
   550  {% update a dimension used by the jsclasses
       
   551   \ifx\@jsc@uplatextrue\undefined\else\fullwidth\textwidth\fi
       
   552   % for some reason, jreport normalizes all dimensions with \@settopoint
       
   553   \@ifclassloaded{jreport}
       
   554     {\@settopoint\textwidth\@settopoint\textheight\@settopoint\marginparwidth}
       
   555     {}% <-- "false" clause of \@ifclassloaded
       
   556   }%
       
   557 \fi
       
   558 
       
   559 % fix fncychap's bug which uses prematurely the \textwidth value
       
   560 \@ifpackagewith{fncychap}{Bjornstrup}
       
   561  {\AtBeginDocument{\mylen\textwidth\advance\mylen-2\myhi}}%
       
   562  {}% <-- "false" clause of \@ifpackagewith
       
   563 
       
   564 
       
   565 %% TITLES
       
   566 %
       
   567 % Since Sphinx 1.5, users should use HeaderFamily key to 'sphinxsetup' rather
       
   568 % than defining their own \py@HeaderFamily command (which is still possible).
       
   569 % Memo: \py@HeaderFamily is also used by \maketitle as defined in
       
   570 % sphinxmanual.cls/sphinxhowto.cls
       
   571 \newcommand{\py@HeaderFamily}{\spx@opt@HeaderFamily}
       
   572 
       
   573 % This sets up the fancy chapter headings that make the documents look
       
   574 % at least a little better than the usual LaTeX output.
       
   575 \@ifpackagewith{fncychap}{Bjarne}{
       
   576   \ChNameVar {\raggedleft\normalsize \py@HeaderFamily}
       
   577   \ChNumVar  {\raggedleft\Large      \py@HeaderFamily}
       
   578   \ChTitleVar{\raggedleft\Large      \py@HeaderFamily}
       
   579   % This creates (numbered) chapter heads without the leading \vspace*{}:
       
   580   \def\@makechapterhead#1{%
       
   581     {\parindent \z@ \raggedright \normalfont
       
   582       \ifnum \c@secnumdepth >\m@ne
       
   583         \if@mainmatter
       
   584           \DOCH
       
   585         \fi
       
   586       \fi
       
   587       \interlinepenalty\@M
       
   588       \if@mainmatter
       
   589         \DOTI{#1}%
       
   590       \else%
       
   591         \DOTIS{#1}%
       
   592       \fi
       
   593     }}
       
   594 }{}% <-- "false" clause of \@ifpackagewith
       
   595 
       
   596 % Augment the sectioning commands used to get our own font family in place,
       
   597 % and reset some internal data items (\titleformat from titlesec package)
       
   598 \titleformat{\section}{\Large\py@HeaderFamily}%
       
   599             {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor}
       
   600 \titleformat{\subsection}{\large\py@HeaderFamily}%
       
   601             {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
       
   602 \titleformat{\subsubsection}{\py@HeaderFamily}%
       
   603             {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor}
       
   604 % By default paragraphs (and subsubsections) will not be numbered because
       
   605 % sphinxmanual.cls and sphinxhowto.cls set secnumdepth to 2
       
   606 \titleformat{\paragraph}{\py@HeaderFamily}%
       
   607             {\py@TitleColor\theparagraph}{0.5em}{\py@TitleColor}{\py@NormalColor}
       
   608 \titleformat{\subparagraph}{\py@HeaderFamily}%
       
   609             {\py@TitleColor\thesubparagraph}{0.5em}{\py@TitleColor}{\py@NormalColor}
       
   610 
       
   611 
       
   612 %% GRAPHICS
       
   613 %
       
   614 % \sphinxincludegraphics defined to resize images larger than the line width,
       
   615 % except if height or width option present.
       
   616 %
       
   617 % If scale is present, rescale before fitting to line width. (since 1.5)
       
   618 \newbox\spx@image@box
       
   619 \newcommand*{\sphinxincludegraphics}[2][]{%
       
   620   \in@{height}{#1}\ifin@\else\in@{width}{#1}\fi
       
   621   \ifin@ % height or width present
       
   622     \includegraphics[#1]{#2}%
       
   623   \else % no height nor width (but #1 may be "scale=...")
       
   624     \setbox\spx@image@box\hbox{\includegraphics[#1,draft]{#2}}%
       
   625     \ifdim \wd\spx@image@box>\linewidth
       
   626       \setbox\spx@image@box\box\voidb@x % clear memory
       
   627       \includegraphics[#1,width=\linewidth]{#2}%
       
   628     \else
       
   629       \includegraphics[#1]{#2}%
       
   630     \fi
       
   631   \fi
       
   632 }
       
   633 
       
   634 
       
   635 %% FIGURE IN TABLE
       
   636 %
       
   637 \newenvironment{sphinxfigure-in-table}[1][\linewidth]{%
       
   638   \def\@captype{figure}%
       
   639   \sphinxsetvskipsforfigintablecaption
       
   640   \begin{minipage}{#1}%
       
   641 }{\end{minipage}}
       
   642 % store original \caption macro for use with figures in longtable and tabulary
       
   643 \AtBeginDocument{\let\spx@originalcaption\caption}
       
   644 \newcommand*\sphinxfigcaption
       
   645   {\ifx\equation$%$% this is trick to identify tabulary first pass
       
   646        \firstchoice@false\else\firstchoice@true\fi
       
   647    \spx@originalcaption }
       
   648 \newcommand*\sphinxsetvskipsforfigintablecaption
       
   649   {\abovecaptionskip\smallskipamount
       
   650    \belowcaptionskip\smallskipamount}
       
   651 
       
   652 %% FOOTNOTES
       
   653 %
       
   654 % Support large numbered footnotes in minipage
       
   655 % But now obsolete due to systematic use of \savenotes/\spewnotes
       
   656 % when minipages are in use in the various macro definitions next.
       
   657 \def\thempfootnote{\arabic{mpfootnote}}
       
   658 
       
   659 
       
   660 %% LITERAL BLOCKS
       
   661 %
       
   662 % Based on use of "fancyvrb.sty"'s Verbatim.
       
   663 % - with framing allowing page breaks ("framed.sty")
       
   664 % - with breaking of long lines (exploits Pygments mark-up),
       
   665 % - with possibly of a top caption, non-separable by pagebreak.
       
   666 % - and usable inside tables or footnotes ("footnotehyper-sphinx").
       
   667 
       
   668 % For extensions which use \OriginalVerbatim and compatibility with Sphinx <
       
   669 % 1.5, we define and use these when (unmodified) Verbatim will be needed. But
       
   670 % Sphinx >= 1.5 does not modify the \Verbatim macro anymore.
       
   671 \let\OriginalVerbatim   \Verbatim
       
   672 \let\endOriginalVerbatim\endVerbatim
       
   673 
       
   674 % if the available space on page is less than \literalblockneedspace, insert pagebreak
       
   675 \newcommand{\sphinxliteralblockneedspace}{5\baselineskip}
       
   676 \newcommand{\sphinxliteralblockwithoutcaptionneedspace}{1.5\baselineskip}
       
   677 
       
   678 % for captions of literal blocks
       
   679 % also define `\theH...` macros for hyperref
       
   680 \newcounter{literalblock}
       
   681 \ltx@ifundefined{c@chapter}
       
   682   {\@addtoreset{literalblock}{section}
       
   683   \def\theliteralblock {\ifnum\c@section>\z@ \thesection.\fi\arabic{literalblock}}
       
   684   \def\theHliteralblock {\theHsection.\arabic{literalblock}}}
       
   685   {\@addtoreset{literalblock}{chapter}
       
   686   \def\theliteralblock {\ifnum\c@chapter>\z@ \thechapter.\fi\arabic{literalblock}}
       
   687   \def\theHliteralblock {\theHchapter.\arabic{literalblock}}}
       
   688 % at start of caption title
       
   689 \newcommand*{\fnum@literalblock}{\literalblockname\nobreakspace\theliteralblock}
       
   690 % this will be overwritten in document preamble by Babel translation
       
   691 \newcommand*{\literalblockname}{Listing }
       
   692 % file extension needed for \caption's good functioning, the file is created
       
   693 % only if a \listof{literalblock}{foo} command is encountered, which is
       
   694 % analogous to \listoffigures, but for the code listings (foo = chosen title.)
       
   695 \newcommand*{\ext@literalblock}{lol}
       
   696 
       
   697 % The title (caption) is specified from outside as macro \sphinxVerbatimTitle.
       
   698 % \sphinxVerbatimTitle is reset to empty after each use of Verbatim.
       
   699 \newcommand*\sphinxVerbatimTitle {}
       
   700 % This box to typeset the caption before framed.sty multiple passes for framing.
       
   701 \newbox\spx@Verbatim@TitleBox
       
   702 % Holder macro for labels of literal blocks. Set-up by LaTeX writer.
       
   703 \newcommand*\sphinxLiteralBlockLabel {}
       
   704 \newcommand*\sphinxSetupCaptionForVerbatim [1]
       
   705 {%
       
   706     \needspace{\sphinxliteralblockneedspace}%
       
   707 % insert a \label via \sphinxLiteralBlockLabel
       
   708 % reset to normal the color for the literal block caption
       
   709 % the caption inserts \abovecaptionskip whitespace above itself (usually 10pt)
       
   710 % there is also \belowcaptionskip but it is usually zero, hence the \smallskip
       
   711     \def\sphinxVerbatimTitle
       
   712        {\py@NormalColor
       
   713         \captionof{literalblock}{\sphinxLiteralBlockLabel #1}\smallskip }%
       
   714 }
       
   715 \newcommand*\sphinxSetupCodeBlockInFootnote {%
       
   716   \fvset{fontsize=\footnotesize}\let\caption\sphinxfigcaption
       
   717   \sphinxverbatimwithminipagetrue % reduces vertical spaces
       
   718   % we counteract float.sty's \caption which does \@normalsize
       
   719   \let\normalsize\footnotesize\let\@parboxrestore\relax
       
   720   \abovecaptionskip \smallskipamount \belowcaptionskip \z@skip}
       
   721 
       
   722 \newif\ifspx@inframed % flag set if we are already in a framed environment
       
   723 % if forced use of minipage encapsulation is needed (e.g. table cells)
       
   724 \newif\ifsphinxverbatimwithminipage   \sphinxverbatimwithminipagefalse
       
   725 \long\def\spx@colorbox #1#2#3{%
       
   726 % let the framing obey the current indentation (adapted from framed.sty's code).
       
   727   \hskip\@totalleftmargin
       
   728   \hskip-\fboxsep\hskip-\fboxrule
       
   729   \spx@fcolorbox{VerbatimBorderColor}{VerbatimColor}{#1}{#2}{#3}%
       
   730   \hskip-\fboxsep\hskip-\fboxrule
       
   731   \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth
       
   732 }
       
   733 % use of \color@b@x here is compatible with both xcolor.sty and color.sty
       
   734 \long\def\spx@fcolorbox #1#2#3#4%
       
   735   {\color@b@x {\color{#1}\spx@VerbatimFBox{#3}{#4}}{\color{#2}}}%
       
   736 % Frame drawing macro
       
   737 % #1 = used by default for title above frame, may contain "continued" hint
       
   738 % #2 = for material underneath frame, used for "continues on next page" hint
       
   739 % #3 = actual contents with background color
       
   740 \long\def\spx@VerbatimFBox#1#2#3{%
       
   741   \leavevmode
       
   742   \begingroup
       
   743   \setbox\@tempboxa\hbox{{#3}}% inner braces to avoid color leaks
       
   744   \hbox
       
   745    {\lower\dimexpr\fboxrule+\dp\@tempboxa\hbox{%
       
   746       \vbox{#1% above frame
       
   747             % draw frame border _latest_ to avoid pdf viewer issue
       
   748             \kern\fboxrule
       
   749             \hbox{\kern\fboxrule
       
   750                   \copy\@tempboxa
       
   751                   \kern-\wd\@tempboxa\kern-\fboxrule
       
   752                   \vrule\@width\fboxrule
       
   753                   \kern\wd\@tempboxa
       
   754                   \vrule\@width\fboxrule}%
       
   755             \kern-\dimexpr\ht\@tempboxa+\dp\@tempboxa+\fboxrule\relax
       
   756             \hrule\@height\fboxrule
       
   757             \kern\dimexpr\ht\@tempboxa+\dp\@tempboxa\relax
       
   758             \hrule\@height\fboxrule
       
   759             #2% below frame
       
   760           }%
       
   761     }%
       
   762    }%
       
   763   \endgroup
       
   764 }
       
   765 
       
   766 % Customize framed.sty \MakeFramed to glue caption to literal block
       
   767 % and add optional hint "continued on next page"
       
   768 \def\spx@Verbatim@FrameCommand
       
   769    {\spx@colorbox\spx@Verbatim@Title{}}%
       
   770 % Macros for a frame with page breaks:
       
   771 \def\spx@Verbatim@FirstFrameCommand
       
   772    {\spx@colorbox\spx@Verbatim@Title\spx@Verbatim@Continues}%
       
   773 \def\spx@Verbatim@MidFrameCommand
       
   774    {\spx@colorbox\spx@Verbatim@Continued\spx@Verbatim@Continues}%
       
   775 \def\spx@Verbatim@LastFrameCommand
       
   776    {\spx@colorbox\spx@Verbatim@Continued{}}%
       
   777 
       
   778 \def\spx@Verbatim@Title{% hide width from framed.sty measuring
       
   779   \moveright\dimexpr\fboxrule+.5\wd\@tempboxa
       
   780   \hb@xt@\z@{\hss\unhcopy\spx@Verbatim@TitleBox\hss}%
       
   781 }%
       
   782 \def\spx@Verbatim@Continued{%
       
   783   \moveright\dimexpr\fboxrule+\wd\@tempboxa-\fboxsep
       
   784   \hb@xt@\z@{\hss
       
   785              {\normalcolor\sphinxstylecodecontinued\literalblockcontinuedname}}%
       
   786 }%
       
   787 \def\spx@Verbatim@Continues{%
       
   788   \moveright\dimexpr\fboxrule+\wd\@tempboxa-\fboxsep
       
   789   \hb@xt@\z@{\hss
       
   790              {\normalcolor\sphinxstylecodecontinues\literalblockcontinuesname}}%
       
   791 }%
       
   792 % Defaults are redefined in document preamble according to language
       
   793 \newcommand*\literalblockcontinuedname{continued from previous page}%
       
   794 \newcommand*\literalblockcontinuesname{continues on next page}%
       
   795 
       
   796 % For linebreaks inside Verbatim environment from package fancyvrb.
       
   797 \newbox\sphinxcontinuationbox
       
   798 \newbox\sphinxvisiblespacebox
       
   799 \newcommand*\sphinxafterbreak {\copy\sphinxcontinuationbox}
       
   800 
       
   801 % Take advantage of the already applied Pygments mark-up to insert
       
   802 % potential linebreaks for TeX processing.
       
   803 %        {, <, #, %, $, ' and ": go to next line.
       
   804 %        _, }, ^, &, >, - and ~: stay at end of broken line.
       
   805 % Use of \textquotesingle for straight quote.
       
   806 % FIXME: convert this to package options ?
       
   807 \newcommand*\sphinxbreaksbeforelist {%
       
   808     \do\PYGZob\{\do\PYGZlt\<\do\PYGZsh\#\do\PYGZpc\%% {, <, #, %,
       
   809     \do\PYGZdl\$\do\PYGZdq\"% $, "
       
   810     \def\PYGZsq
       
   811      {\discretionary{}{\sphinxafterbreak\textquotesingle}{\textquotesingle}}% '
       
   812 }
       
   813 \newcommand*\sphinxbreaksafterlist {%
       
   814     \do\PYGZus\_\do\PYGZcb\}\do\PYGZca\^\do\PYGZam\&% _, }, ^, &,
       
   815     \do\PYGZgt\>\do\PYGZhy\-\do\PYGZti\~% >, -, ~
       
   816 }
       
   817 \newcommand*\sphinxbreaksatspecials {%
       
   818   \def\do##1##2%
       
   819      {\def##1{\discretionary{}{\sphinxafterbreak\char`##2}{\char`##2}}}%
       
   820   \sphinxbreaksbeforelist
       
   821   \def\do##1##2%
       
   822      {\def##1{\discretionary{\char`##2}{\sphinxafterbreak}{\char`##2}}}%
       
   823   \sphinxbreaksafterlist
       
   824 }
       
   825 
       
   826 \def\sphinx@verbatim@nolig@list {\do \`}%
       
   827 % Some characters . , ; ? ! / are not pygmentized.
       
   828 % This macro makes them "active" and they will insert potential linebreaks.
       
   829 % Not compatible with math mode (cf \sphinxunactivateextras).
       
   830 \newcommand*\sphinxbreaksbeforeactivelist {}% none
       
   831 \newcommand*\sphinxbreaksafteractivelist  {\do\.\do\,\do\;\do\?\do\!\do\/}
       
   832 \newcommand*\sphinxbreaksviaactive {%
       
   833    \def\do##1{\lccode`\~`##1%
       
   834     \lowercase{\def~}{\discretionary{}{\sphinxafterbreak\char`##1}{\char`##1}}%
       
   835     \catcode`##1\active}%
       
   836    \sphinxbreaksbeforeactivelist
       
   837    \def\do##1{\lccode`\~`##1%
       
   838     \lowercase{\def~}{\discretionary{\char`##1}{\sphinxafterbreak}{\char`##1}}%
       
   839     \catcode`##1\active}%
       
   840    \sphinxbreaksafteractivelist
       
   841    \lccode`\~`\~
       
   842 }
       
   843 
       
   844 % If the linebreak is at a space, the latter will be displayed as visible
       
   845 % space at end of first line, and a continuation symbol starts next line.
       
   846 \def\spx@verbatim@space {%
       
   847      \nobreak\hskip\z@skip
       
   848      \discretionary{\copy\sphinxvisiblespacebox}{\sphinxafterbreak}
       
   849                    {\kern\fontdimen2\font}%
       
   850 }%
       
   851 
       
   852 % needed to create wrapper environments of fancyvrb's Verbatim
       
   853 \newcommand*{\sphinxVerbatimEnvironment}{\gdef\FV@EnvironName{sphinxVerbatim}}
       
   854 % serves to implement line highlighting and line wrapping
       
   855 \newcommand\sphinxFancyVerbFormatLine[1]{%
       
   856   \expandafter\sphinx@verbatim@checkifhl\expandafter{\the\FV@CodeLineNo}%
       
   857   \ifin@
       
   858      \sphinxVerbatimHighlightLine{#1}%
       
   859   \else
       
   860      \sphinxVerbatimFormatLine{#1}%
       
   861   \fi
       
   862 }%
       
   863 \newcommand\sphinxVerbatimHighlightLine[1]{%
       
   864   \edef\sphinxrestorefboxsep{\fboxsep\the\fboxsep\relax}%
       
   865   \fboxsep0pt\relax % cf LaTeX bug graphics/4524
       
   866   \colorbox{sphinxVerbatimHighlightColor}%
       
   867            {\sphinxrestorefboxsep\sphinxVerbatimFormatLine{#1}}%
       
   868   % no need to restore \fboxsep here, as this ends up in a \hbox from fancyvrb
       
   869 }%
       
   870 % \sphinxVerbatimFormatLine will be set locally to one of those two:
       
   871 \newcommand\sphinxVerbatimFormatLineWrap[1]{%
       
   872     \hsize\linewidth
       
   873     \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
       
   874           \doublehyphendemerits\z@\finalhyphendemerits\z@
       
   875           \strut #1\strut}%
       
   876 }%
       
   877 \newcommand\sphinxVerbatimFormatLineNoWrap[1]{\hb@xt@\linewidth{\strut #1\hss}}%
       
   878 \g@addto@macro\FV@SetupFont{%
       
   879     \sbox\sphinxcontinuationbox {\spx@opt@verbatimcontinued}%
       
   880     \sbox\sphinxvisiblespacebox {\spx@opt@verbatimvisiblespace}%
       
   881 }%
       
   882 % Sphinx <1.5 optional argument was in fact mandatory. It is now really
       
   883 % optional and handled by original Verbatim.
       
   884 \newenvironment{sphinxVerbatim}{%
       
   885   % quit horizontal mode if we are still in a paragraph
       
   886   \par
       
   887   % list starts new par, but we don't want it to be set apart vertically
       
   888   \parskip\z@skip
       
   889   % first, let's check if there is a caption
       
   890   \ifx\sphinxVerbatimTitle\empty
       
   891       \addvspace\z@% counteract possible previous negative skip (French lists!)
       
   892       \smallskip
       
   893       % there was no caption. Check if nevertheless a label was set.
       
   894       \ifx\sphinxLiteralBlockLabel\empty\else
       
   895       % we require some space to be sure hyperlink target from \phantomsection
       
   896       % will not be separated from upcoming verbatim by a page break
       
   897           \needspace{\sphinxliteralblockwithoutcaptionneedspace}%
       
   898           \phantomsection\sphinxLiteralBlockLabel
       
   899       \fi
       
   900       \let\spx@Verbatim@Title\@empty
       
   901   \else
       
   902   % non-empty \sphinxVerbatimTitle has label inside it (in case there is one)
       
   903      \setbox\spx@Verbatim@TitleBox
       
   904             \hbox{\begin{minipage}{\linewidth}%
       
   905                     \sphinxVerbatimTitle
       
   906                   \end{minipage}}%
       
   907   \fi
       
   908   \fboxsep\sphinxverbatimsep \fboxrule\sphinxverbatimborder
       
   909   % setting borderwidth to zero is simplest for no-frame effect with same pagebreaks
       
   910   \ifspx@opt@verbatimwithframe\else\fboxrule\z@\fi
       
   911   \let\FrameCommand     \spx@Verbatim@FrameCommand
       
   912   \let\FirstFrameCommand\spx@Verbatim@FirstFrameCommand
       
   913   \let\MidFrameCommand  \spx@Verbatim@MidFrameCommand
       
   914   \let\LastFrameCommand \spx@Verbatim@LastFrameCommand
       
   915   \ifspx@opt@verbatimhintsturnover\else
       
   916       \let\spx@Verbatim@Continued\@empty
       
   917       \let\spx@Verbatim@Continues\@empty
       
   918   \fi
       
   919   \ifspx@opt@verbatimwrapslines
       
   920   % fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes.
       
   921   % This customization wraps each line from the input in a \vtop, thus
       
   922   % allowing it to wrap and display on two or more lines in the latex output.
       
   923   %     - The codeline counter will be increased only once.
       
   924   %     - The wrapped material will not break across pages, it is impossible
       
   925   %       to achieve this without extensive rewrite of fancyvrb.
       
   926   %     - The (not used in sphinx) obeytabs option to Verbatim is
       
   927   %       broken by this change (showtabs and tabspace work).
       
   928     \let\sphinxVerbatimFormatLine\sphinxVerbatimFormatLineWrap
       
   929     \let\FV@Space\spx@verbatim@space
       
   930   % Allow breaks at special characters using \PYG... macros.
       
   931     \sphinxbreaksatspecials
       
   932   % Breaks at punctuation characters . , ; ? ! and / (needs catcode activation)
       
   933     \fvset{codes*=\sphinxbreaksviaactive}%
       
   934   \else % end of conditional code for wrapping long code lines
       
   935     \let\sphinxVerbatimFormatLine\sphinxVerbatimFormatLineNoWrap
       
   936   \fi
       
   937   \let\FancyVerbFormatLine\sphinxFancyVerbFormatLine
       
   938   % workaround to fancyvrb's check of \@currenvir
       
   939   \let\VerbatimEnvironment\sphinxVerbatimEnvironment
       
   940   % workaround to fancyvrb's check of current list depth
       
   941   \def\@toodeep {\advance\@listdepth\@ne}%
       
   942   % The list environment is needed to control perfectly the vertical space.
       
   943   % Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt.
       
   944   % - if caption: vertical space above caption = (\abovecaptionskip + D) with
       
   945   %   D = \baselineskip-\FrameHeightAdjust, and then \smallskip above frame.
       
   946   % - if no caption: (\smallskip + D) above frame. By default D=6pt.
       
   947   % Use trivlist rather than list to avoid possible "too deeply nested" error.
       
   948   \itemsep   \z@skip
       
   949   \topsep    \z@skip
       
   950   \partopsep \z@skip% trivlist will set \parsep to \parskip = zero (see above)
       
   951   % \leftmargin will be set to zero by trivlist
       
   952   \rightmargin\z@
       
   953   \parindent  \z@% becomes \itemindent. Default zero, but perhaps overwritten.
       
   954   \trivlist\item\relax
       
   955      \ifsphinxverbatimwithminipage\spx@inframedtrue\fi
       
   956      % use a minipage if we are already inside a framed environment
       
   957      \ifspx@inframed\noindent\begin{minipage}{\linewidth}\fi
       
   958      \MakeFramed {% adapted over from framed.sty's snugshade environment
       
   959         \advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage
       
   960         }%
       
   961      % For grid placement from \strut's in \FancyVerbFormatLine
       
   962      \lineskip\z@skip
       
   963      % active comma should not be overwritten by \@noligs
       
   964      \ifspx@opt@verbatimwrapslines
       
   965        \let\verbatim@nolig@list \sphinx@verbatim@nolig@list
       
   966      \fi
       
   967      % will fetch its optional arguments if any
       
   968      \OriginalVerbatim
       
   969 }
       
   970 {%
       
   971   \endOriginalVerbatim
       
   972   \par\unskip\@minipagefalse\endMakeFramed % from framed.sty snugshade
       
   973   \ifspx@inframed\end{minipage}\fi
       
   974   \endtrivlist
       
   975 }
       
   976 \newenvironment {sphinxVerbatimNoFrame}
       
   977   {\spx@opt@verbatimwithframefalse
       
   978    % needed for fancyvrb as literal code will end in \end{sphinxVerbatimNoFrame}
       
   979    \def\sphinxVerbatimEnvironment{\gdef\FV@EnvironName{sphinxVerbatimNoFrame}}%
       
   980    \begin{sphinxVerbatim}}
       
   981   {\end{sphinxVerbatim}}
       
   982 \newenvironment {sphinxVerbatimintable}
       
   983   {% don't use a frame if in a table cell
       
   984    \spx@opt@verbatimwithframefalse
       
   985    \sphinxverbatimwithminipagetrue
       
   986    % counteract longtable redefinition of caption
       
   987    \let\caption\sphinxfigcaption
       
   988    % reduce above caption space if in a table cell
       
   989    \abovecaptionskip\smallskipamount
       
   990    \def\sphinxVerbatimEnvironment{\gdef\FV@EnvironName{sphinxVerbatimintable}}%
       
   991    \begin{sphinxVerbatim}}
       
   992   {\end{sphinxVerbatim}}
       
   993 
       
   994 
       
   995 %% PARSED LITERALS
       
   996 % allow long lines to wrap like they do in code-blocks
       
   997 
       
   998 % this should be kept in sync with definitions in sphinx.util.texescape
       
   999 \newcommand*\sphinxbreaksattexescapedchars{%
       
  1000   \def\do##1##2% put potential break point before character
       
  1001      {\def##1{\discretionary{}{\sphinxafterbreak\char`##2}{\char`##2}}}%
       
  1002   \do\{\{\do\textless\<\do\#\#\do\%\%\do\$\$% {, <, #, %, $
       
  1003   \def\do##1##2% put potential break point after character
       
  1004      {\def##1{\discretionary{\char`##2}{\sphinxafterbreak}{\char`##2}}}%
       
  1005   \do\_\_\do\}\}\do\textasciicircum\^\do\&\&% _, }, ^, &,
       
  1006   \do\textgreater\>\do\textasciitilde\~% >, ~
       
  1007 }
       
  1008 \newcommand*\sphinxbreaksviaactiveinparsedliteral{%
       
  1009   \sphinxbreaksviaactive % by default handles . , ; ? ! /
       
  1010   \do\-% we need also the hyphen character (ends up "as is" in parsed-literal)
       
  1011   \lccode`\~`\~ %
       
  1012   % update \dospecials as it is used by \url
       
  1013   % but deactivation will already have been done hence this is unneeded:
       
  1014   %  \expandafter\def\expandafter\dospecials\expandafter{\dospecials
       
  1015   %   \sphinxbreaksbeforeactivelist\sphinxbreaksafteractivelist\do\-}%
       
  1016 }
       
  1017 \newcommand*\sphinxbreaksatspaceinparsedliteral{%
       
  1018   \lccode`~32 \lowercase{\let~}\spx@verbatim@space\lccode`\~`\~
       
  1019 }
       
  1020 \newcommand*{\sphinxunactivateextras}{\let\do\@makeother
       
  1021       \sphinxbreaksbeforeactivelist\sphinxbreaksafteractivelist\do\-}%
       
  1022 % the \catcode13=5\relax (deactivate end of input lines) is left to callers
       
  1023 \newcommand*{\sphinxunactivateextrasandspace}{\catcode32=10\relax
       
  1024       \sphinxunactivateextras}%
       
  1025 % now for the modified alltt environment
       
  1026 \newenvironment{sphinxalltt}
       
  1027 {% at start of next line to workaround Emacs/AUCTeX issue with this file
       
  1028 \begin{alltt}%
       
  1029  \ifspx@opt@parsedliteralwraps
       
  1030    \sbox\sphinxcontinuationbox {\spx@opt@verbatimcontinued}%
       
  1031    \sbox\sphinxvisiblespacebox {\spx@opt@verbatimvisiblespace}%
       
  1032    \sphinxbreaksattexescapedchars
       
  1033    \sphinxbreaksviaactiveinparsedliteral
       
  1034    \sphinxbreaksatspaceinparsedliteral
       
  1035 % alltt takes care of the ' as derivative ("prime") in math mode
       
  1036    \everymath\expandafter{\the\everymath\sphinxunactivateextrasandspace
       
  1037              \catcode`\<=12\catcode`\>=12\catcode`\^=7\catcode`\_=8 }%
       
  1038 % not sure if displayed math (align,...) can end up in parsed-literal, anyway
       
  1039    \everydisplay\expandafter{\the\everydisplay
       
  1040              \catcode13=5 \sphinxunactivateextrasandspace
       
  1041              \catcode`\<=12\catcode`\>=12\catcode`\^=7\catcode`\_=8 }%
       
  1042  \fi }
       
  1043 {\end{alltt}}
       
  1044 
       
  1045 % Protect \href's first argument in contexts such as sphinxalltt (or
       
  1046 % \sphinxcode). Sphinx uses \#, \%, \& ... always inside \sphinxhref.
       
  1047 \protected\def\sphinxhref#1#2{{%
       
  1048     \sphinxunactivateextrasandspace % never do \scantokens with active space!
       
  1049     \endlinechar\m@ne\everyeof{{#2}}% keep catcode regime for #2
       
  1050     \scantokens{\href{#1}}% normalise it for #1 during \href expansion
       
  1051 }}
       
  1052 % Same for \url. And also \nolinkurl for coherence.
       
  1053 \protected\def\sphinxurl#1{{%
       
  1054     \sphinxunactivateextrasandspace\everyeof{}% (<- precaution for \scantokens)
       
  1055     \endlinechar\m@ne\scantokens{\url{#1}}%
       
  1056 }}
       
  1057 \protected\def\sphinxnolinkurl#1{{%
       
  1058     \sphinxunactivateextrasandspace\everyeof{}%
       
  1059     \endlinechar\m@ne\scantokens{\nolinkurl{#1}}%
       
  1060 }}
       
  1061 
       
  1062 
       
  1063 %% TOPIC AND CONTENTS BOXES
       
  1064 %
       
  1065 % Again based on use of "framed.sty", this allows breakable framed boxes.
       
  1066 \long\def\spx@ShadowFBox#1{%
       
  1067   \leavevmode\begingroup
       
  1068   % first we frame the box #1
       
  1069   \setbox\@tempboxa
       
  1070    \hbox{\vrule\@width\sphinxshadowrule
       
  1071          \vbox{\hrule\@height\sphinxshadowrule
       
  1072                \kern\sphinxshadowsep
       
  1073                \hbox{\kern\sphinxshadowsep #1\kern\sphinxshadowsep}%
       
  1074                \kern\sphinxshadowsep
       
  1075                \hrule\@height\sphinxshadowrule}%
       
  1076          \vrule\@width\sphinxshadowrule}%
       
  1077   % Now we add the shadow, like \shadowbox from fancybox.sty would do
       
  1078   \dimen@\dimexpr.5\sphinxshadowrule+\sphinxshadowsize\relax
       
  1079   \hbox{\vbox{\offinterlineskip
       
  1080               \hbox{\copy\@tempboxa\kern-.5\sphinxshadowrule
       
  1081                     % add shadow on right side
       
  1082                     \lower\sphinxshadowsize
       
  1083                           \hbox{\vrule\@height\ht\@tempboxa \@width\dimen@}%
       
  1084                     }%
       
  1085               \kern-\dimen@ % shift back vertically to bottom of frame
       
  1086               % and add shadow at bottom
       
  1087               \moveright\sphinxshadowsize
       
  1088                     \vbox{\hrule\@width\wd\@tempboxa \@height\dimen@}%
       
  1089               }%
       
  1090         % move left by the size of right shadow so shadow adds no width
       
  1091         \kern-\sphinxshadowsize
       
  1092        }%
       
  1093   \endgroup
       
  1094 }
       
  1095 
       
  1096 % use framed.sty to allow page breaks in frame+shadow
       
  1097 % works well inside Lists and Quote-like environments
       
  1098 % produced by ``topic'' directive (or local contents)
       
  1099 % could nest if LaTeX writer authorized it
       
  1100 \newenvironment{sphinxShadowBox}
       
  1101   {\def\FrameCommand {\spx@ShadowFBox }%
       
  1102    % configure framed.sty not to add extra vertical spacing
       
  1103    \ltx@ifundefined{OuterFrameSep}{}{\OuterFrameSep\z@skip}%
       
  1104    % the \trivlist will add the vertical spacing on top and bottom which is
       
  1105    % typical of center environment as used in Sphinx <= 1.4.1
       
  1106    % the \noindent has the effet of an extra blank line on top, to
       
  1107    % imitate closely the layout from Sphinx <= 1.4.1; the \FrameHeightAdjust
       
  1108    % will put top part of frame on this baseline.
       
  1109    \def\FrameHeightAdjust {\baselineskip}%
       
  1110    % use package footnote to handle footnotes
       
  1111    \savenotes
       
  1112    \trivlist\item\noindent
       
  1113     % use a minipage if we are already inside a framed environment
       
  1114     \ifspx@inframed\begin{minipage}{\linewidth}\fi
       
  1115     \MakeFramed {\spx@inframedtrue
       
  1116     % framed.sty puts into "\width" the added width (=2shadowsep+2shadowrule)
       
  1117     % adjust \hsize to what the contents must use
       
  1118     \advance\hsize-\width
       
  1119     % adjust LaTeX parameters to behave properly in indented/quoted contexts
       
  1120     \FrameRestore
       
  1121     % typeset the contents as in a minipage (Sphinx <= 1.4.1 used a minipage and
       
  1122     % itemize/enumerate are therein typeset more tightly, we want to keep
       
  1123     % that). We copy-paste from LaTeX source code but don't do a real minipage.
       
  1124     \@pboxswfalse
       
  1125     \let\@listdepth\@mplistdepth \@mplistdepth\z@
       
  1126     \@minipagerestore
       
  1127     \@setminipage
       
  1128     }%
       
  1129   }%
       
  1130   {% insert the "endminipage" code
       
  1131     \par\unskip
       
  1132     \@minipagefalse
       
  1133    \endMakeFramed
       
  1134      \ifspx@inframed\end{minipage}\fi
       
  1135    \endtrivlist
       
  1136    % output the stored footnotes
       
  1137    \spewnotes
       
  1138   }
       
  1139 
       
  1140 
       
  1141 %% NOTICES AND ADMONITIONS
       
  1142 %
       
  1143 % Some are quite plain
       
  1144 % the spx@notice@bordercolor etc are set in the sphinxadmonition environment
       
  1145 \newenvironment{sphinxlightbox}{%
       
  1146   \par\allowbreak
       
  1147   \noindent{\color{spx@notice@bordercolor}%
       
  1148             \rule{\linewidth}{\spx@notice@border}}\par\nobreak
       
  1149   {\parskip\z@skip\noindent}%
       
  1150   }
       
  1151   {%
       
  1152   \par
       
  1153   % counteract previous possible negative skip (French lists!):
       
  1154   % (we can't cancel that any earlier \vskip introduced a potential pagebreak)
       
  1155   \ifdim\lastskip<\z@\vskip-\lastskip\fi
       
  1156   \nobreak\vbox{\noindent\kern\@totalleftmargin
       
  1157       {\color{spx@notice@bordercolor}%
       
  1158        \rule[\dimexpr.4\baselineskip-\spx@notice@border\relax]
       
  1159              {\linewidth}{\spx@notice@border}}\hss}\allowbreak
       
  1160   }% end of sphinxlightbox environment definition
       
  1161 % may be renewenvironment'd by user for complete customization
       
  1162 \newenvironment{sphinxnote}[1]
       
  1163   {\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
       
  1164 \newenvironment{sphinxhint}[1]
       
  1165   {\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
       
  1166 \newenvironment{sphinximportant}[1]
       
  1167   {\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
       
  1168 \newenvironment{sphinxtip}[1]
       
  1169   {\begin{sphinxlightbox}\sphinxstrong{#1} }{\end{sphinxlightbox}}
       
  1170 % or just use the package options
       
  1171 % these are needed for common handling by notice environment of lightbox
       
  1172 % and heavybox but they are  currently not used by lightbox environment
       
  1173 % and there is consequently no corresponding package option
       
  1174 \definecolor{sphinxnoteBgColor}{rgb}{1,1,1}
       
  1175 \definecolor{sphinxhintBgColor}{rgb}{1,1,1}
       
  1176 \definecolor{sphinximportantBgColor}{rgb}{1,1,1}
       
  1177 \definecolor{sphinxtipBgColor}{rgb}{1,1,1}
       
  1178 
       
  1179 % Others get more distinction
       
  1180 % Code adapted from framed.sty's "snugshade" environment.
       
  1181 % Nesting works (inner frames do not allow page breaks).
       
  1182 \newenvironment{sphinxheavybox}{\par
       
  1183    \setlength{\FrameRule}{\spx@notice@border}%
       
  1184    \setlength{\FrameSep}{\dimexpr.6\baselineskip-\FrameRule\relax}
       
  1185    % configure framed.sty's parameters to obtain same vertical spacing
       
  1186    % as for "light" boxes. We need for this to manually insert parskip glue and
       
  1187    % revert a skip done by framed before the frame.
       
  1188     \ltx@ifundefined{OuterFrameSep}{}{\OuterFrameSep\z@skip}%
       
  1189     \vspace{\FrameHeightAdjust}
       
  1190    % copied/adapted from framed.sty's snugshade
       
  1191    \def\FrameCommand##1{\hskip\@totalleftmargin
       
  1192        \fboxsep\FrameSep \fboxrule\FrameRule
       
  1193        \fcolorbox{spx@notice@bordercolor}{spx@notice@bgcolor}{##1}%
       
  1194        \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
       
  1195    \savenotes
       
  1196    % use a minipage if we are already inside a framed environment
       
  1197    \ifspx@inframed
       
  1198        \noindent\begin{minipage}{\linewidth}
       
  1199    \else
       
  1200        % handle case where notice is first thing in a list item (or is quoted)
       
  1201        \if@inlabel
       
  1202         \noindent\par\vspace{-\baselineskip}
       
  1203        \else
       
  1204         \vspace{\parskip}
       
  1205        \fi
       
  1206    \fi
       
  1207    \MakeFramed {\spx@inframedtrue
       
  1208      \advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize
       
  1209      % minipage initialization copied from LaTeX source code.
       
  1210      \@pboxswfalse
       
  1211      \let\@listdepth\@mplistdepth \@mplistdepth\z@
       
  1212      \@minipagerestore
       
  1213      \@setminipage }%
       
  1214    }
       
  1215    {%
       
  1216    \par\unskip
       
  1217    \@minipagefalse
       
  1218    \endMakeFramed
       
  1219    \ifspx@inframed\end{minipage}\fi
       
  1220    % set footnotes at bottom of page
       
  1221    \spewnotes
       
  1222    % arrange for similar spacing below frame as for "light" boxes.
       
  1223    \vskip .4\baselineskip
       
  1224    }% end of sphinxheavybox environment definition
       
  1225 % may be renewenvironment'd by user for complete customization
       
  1226 \newenvironment{sphinxwarning}[1]
       
  1227   {\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
       
  1228 \newenvironment{sphinxcaution}[1]
       
  1229   {\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
       
  1230 \newenvironment{sphinxattention}[1]
       
  1231   {\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
       
  1232 \newenvironment{sphinxdanger}[1]
       
  1233   {\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
       
  1234 \newenvironment{sphinxerror}[1]
       
  1235   {\begin{sphinxheavybox}\sphinxstrong{#1} }{\end{sphinxheavybox}}
       
  1236 % or just use package options
       
  1237 
       
  1238 % the \colorlet of xcolor (if at all loaded) is overkill for our use case
       
  1239 \newcommand{\sphinxcolorlet}[2]
       
  1240     {\expandafter\let\csname\@backslashchar color@#1\expandafter\endcsname
       
  1241                      \csname\@backslashchar color@#2\endcsname }
       
  1242 
       
  1243 % the main dispatch for all types of notices
       
  1244 \newenvironment{sphinxadmonition}[2]{% #1=type, #2=heading
       
  1245   % can't use #1 directly in definition of end part
       
  1246   \def\spx@noticetype {#1}%
       
  1247   % set parameters of heavybox/lightbox
       
  1248   \sphinxcolorlet{spx@notice@bordercolor}{sphinx#1BorderColor}%
       
  1249   \sphinxcolorlet{spx@notice@bgcolor}{sphinx#1BgColor}%
       
  1250   \spx@notice@border \dimexpr\csname spx@opt@#1border\endcsname\relax
       
  1251   % start specific environment, passing the heading as argument
       
  1252   \begin{sphinx#1}{#2}}
       
  1253   % workaround some LaTeX "feature" of \end command
       
  1254  {\edef\spx@temp{\noexpand\end{sphinx\spx@noticetype}}\spx@temp}
       
  1255 % use of ``notice'' is for backwards compatibility and will be removed in
       
  1256 % Sphinx 1.7.
       
  1257 \newenvironment{notice}
       
  1258   {\sphinxdeprecationwarning {notice}{1.6}{1.7}{%
       
  1259   This document was probably built with a Sphinx extension using ``notice''^^J
       
  1260   environment. At Sphinx 1.7, ``notice'' environment will be removed. Please^^J
       
  1261   report to extension author to use ``sphinxadmonition'' instead.^^J%
       
  1262   ****}\begin{sphinxadmonition}}{\end{sphinxadmonition}}
       
  1263 
       
  1264 
       
  1265 %% PYTHON DOCS MACROS AND ENVIRONMENTS
       
  1266 %  (some macros here used by \maketitle in sphinxmanual.cls and sphinxhowto.cls)
       
  1267 
       
  1268 % \moduleauthor{name}{email}
       
  1269 \newcommand{\moduleauthor}[2]{}
       
  1270 
       
  1271 % \sectionauthor{name}{email}
       
  1272 \newcommand{\sectionauthor}[2]{}
       
  1273 
       
  1274 % Allow the release number to be specified independently of the
       
  1275 % \date{}.  This allows the date to reflect the document's date and
       
  1276 % release to specify the release that is documented.
       
  1277 %
       
  1278 \newcommand{\py@release}{}
       
  1279 \newcommand{\version}{}
       
  1280 \newcommand{\shortversion}{}
       
  1281 \newcommand{\releaseinfo}{}
       
  1282 \newcommand{\releasename}{Release}
       
  1283 \newcommand{\release}[1]{%
       
  1284   \renewcommand{\py@release}{\releasename\space\version}%
       
  1285   \renewcommand{\version}{#1}}
       
  1286 \newcommand{\setshortversion}[1]{%
       
  1287   \renewcommand{\shortversion}{#1}}
       
  1288 \newcommand{\setreleaseinfo}[1]{%
       
  1289   \renewcommand{\releaseinfo}{#1}}
       
  1290 
       
  1291 % Allow specification of the author's address separately from the
       
  1292 % author's name.  This can be used to format them differently, which
       
  1293 % is a good thing.
       
  1294 %
       
  1295 \newcommand{\py@authoraddress}{}
       
  1296 \newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}}
       
  1297 
       
  1298 % {fulllineitems} is the main environment for object descriptions.
       
  1299 %
       
  1300 \newcommand{\py@itemnewline}[1]{%
       
  1301   \kern\labelsep
       
  1302   \@tempdima\linewidth
       
  1303   \advance\@tempdima \labelwidth\makebox[\@tempdima][l]{#1}%
       
  1304   \kern-\labelsep
       
  1305 }
       
  1306 
       
  1307 \newenvironment{fulllineitems}{%
       
  1308   \begin{list}{}{\labelwidth \leftmargin
       
  1309                  \rightmargin \z@ \topsep -\parskip \partopsep \parskip
       
  1310                  \itemsep -\parsep
       
  1311                  \let\makelabel=\py@itemnewline}%
       
  1312 }{\end{list}}
       
  1313 
       
  1314 % Signatures, possibly multi-line
       
  1315 %
       
  1316 \newlength{\py@argswidth}
       
  1317 \newcommand{\py@sigparams}[2]{%
       
  1318   \parbox[t]{\py@argswidth}{#1\sphinxcode{)}#2}}
       
  1319 \newcommand{\pysigline}[1]{\item[{#1}]}
       
  1320 \newcommand{\pysiglinewithargsret}[3]{%
       
  1321   \settowidth{\py@argswidth}{#1\sphinxcode{(}}%
       
  1322   \addtolength{\py@argswidth}{-2\py@argswidth}%
       
  1323   \addtolength{\py@argswidth}{\linewidth}%
       
  1324   \item[{#1\sphinxcode{(}\py@sigparams{#2}{#3}}]}
       
  1325 \newcommand{\pysigstartmultiline}{%
       
  1326  \def\pysigstartmultiline{\vskip\smallskipamount\parskip\z@skip\itemsep\z@skip}%
       
  1327  \edef\pysigstopmultiline
       
  1328      {\noexpand\leavevmode\parskip\the\parskip\relax\itemsep\the\itemsep\relax}%
       
  1329  \parskip\z@skip\itemsep\z@skip
       
  1330 }
       
  1331 
       
  1332 % Production lists
       
  1333 %
       
  1334 \newenvironment{productionlist}{%
       
  1335 %  \def\sphinxoptional##1{{\Large[}##1{\Large]}}
       
  1336   \def\production##1##2{\\\sphinxcode{##1}&::=&\sphinxcode{##2}}%
       
  1337   \def\productioncont##1{\\& &\sphinxcode{##1}}%
       
  1338   \parindent=2em
       
  1339   \indent
       
  1340   \setlength{\LTpre}{0pt}%
       
  1341   \setlength{\LTpost}{0pt}%
       
  1342   \begin{longtable}[l]{lcl}
       
  1343 }{%
       
  1344   \end{longtable}
       
  1345 }
       
  1346 
       
  1347 % Definition lists; requested by AMK for HOWTO documents.  Probably useful
       
  1348 % elsewhere as well, so keep in in the general style support.
       
  1349 %
       
  1350 \newenvironment{definitions}{%
       
  1351   \begin{description}%
       
  1352   \def\term##1{\item[{##1}]\mbox{}\\*[0mm]}%
       
  1353 }{%
       
  1354   \end{description}%
       
  1355 }
       
  1356 
       
  1357 %% FROM DOCTUTILS LATEX WRITER
       
  1358 %
       
  1359 % The following is stuff copied from docutils' latex writer.
       
  1360 %
       
  1361 \newcommand{\optionlistlabel}[1]{\normalfont\bfseries #1 \hfill}% \bf deprecated
       
  1362 \newenvironment{optionlist}[1]
       
  1363 {\begin{list}{}
       
  1364   {\setlength{\labelwidth}{#1}
       
  1365    \setlength{\rightmargin}{1cm}
       
  1366    \setlength{\leftmargin}{\rightmargin}
       
  1367    \addtolength{\leftmargin}{\labelwidth}
       
  1368    \addtolength{\leftmargin}{\labelsep}
       
  1369    \renewcommand{\makelabel}{\optionlistlabel}}
       
  1370 }{\end{list}}
       
  1371 
       
  1372 \newlength{\lineblockindentation}
       
  1373 \setlength{\lineblockindentation}{2.5em}
       
  1374 \newenvironment{lineblock}[1]
       
  1375 {\begin{list}{}
       
  1376   {\setlength{\partopsep}{\parskip}
       
  1377    \addtolength{\partopsep}{\baselineskip}
       
  1378    \topsep0pt\itemsep0.15\baselineskip\parsep0pt
       
  1379    \leftmargin#1\relax}
       
  1380  \raggedright}
       
  1381 {\end{list}}
       
  1382 
       
  1383 % From docutils.writers.latex2e
       
  1384 % inline markup (custom roles)
       
  1385 % \DUrole{#1}{#2} tries \DUrole#1{#2}
       
  1386 \providecommand*{\DUrole}[2]{%
       
  1387   \ifcsname DUrole\detokenize{#1}\endcsname
       
  1388     \csname DUrole\detokenize{#1}\endcsname{#2}%
       
  1389   \else% backwards compatibility: try \docutilsrole#1{#2}
       
  1390     \ifcsname docutilsrole\detokenize{#1}\endcsname
       
  1391       \csname docutilsrole\detokenize{#1}\endcsname{#2}%
       
  1392     \else
       
  1393       #2%
       
  1394     \fi
       
  1395   \fi
       
  1396 }
       
  1397 
       
  1398 \providecommand*{\DUprovidelength}[2]{%
       
  1399   \ifdefined#1\else\newlength{#1}\setlength{#1}{#2}\fi
       
  1400 }
       
  1401 
       
  1402 \DUprovidelength{\DUlineblockindent}{2.5em}
       
  1403 \ifdefined\DUlineblock\else
       
  1404   \newenvironment{DUlineblock}[1]{%
       
  1405     \list{}{\setlength{\partopsep}{\parskip}
       
  1406             \addtolength{\partopsep}{\baselineskip}
       
  1407             \setlength{\topsep}{0pt}
       
  1408             \setlength{\itemsep}{0.15\baselineskip}
       
  1409             \setlength{\parsep}{0pt}
       
  1410             \setlength{\leftmargin}{#1}}
       
  1411     \raggedright
       
  1412   }
       
  1413   {\endlist}
       
  1414 \fi
       
  1415 
       
  1416 %% TEXT STYLING
       
  1417 %
       
  1418 % Some custom font markup commands.
       
  1419 % *** the macros without \sphinx prefix are still defined farther down ***
       
  1420 \protected\def\sphinxstrong#1{{\textbf{#1}}}
       
  1421 % to obtain straight quotes we execute \@noligs as patched by upquote, and
       
  1422 % \scantokens is needed in cases where it would be too late for the macro to
       
  1423 % first set catcodes and then fetch its argument. We also make the contents
       
  1424 % breakable at non-escaped . , ; ? ! / using \sphinxbreaksviaactive.
       
  1425 % the macro must be protected if it ends up used in moving arguments,
       
  1426 % in 'alltt' \@noligs is done already, and the \scantokens must be avoided.
       
  1427 \protected\def\sphinxcode#1{{\def\@tempa{alltt}%
       
  1428   \ifx\@tempa\@currenvir\else
       
  1429    \ifspx@opt@inlineliteralwraps
       
  1430       \sphinxbreaksviaactive\let\sphinxafterbreak\empty
       
  1431       % do not overwrite the comma set-up
       
  1432       \let\verbatim@nolig@list\sphinx@literal@nolig@list
       
  1433    \fi
       
  1434    % fix a space-gobbling issue due to LaTeX's original \do@noligs
       
  1435    \let\do@noligs\sphinx@do@noligs
       
  1436    \@noligs\endlinechar\m@ne\everyeof{}% (<- in case inside \sphinxhref)
       
  1437    \expandafter\scantokens
       
  1438   \fi {\texttt{#1}}}}
       
  1439 \def\sphinx@do@noligs #1{\catcode`#1\active\begingroup\lccode`\~`#1\relax
       
  1440     \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1 }}}
       
  1441 \def\sphinx@literal@nolig@list {\do\`\do\<\do\>\do\'\do\-}%
       
  1442 
       
  1443 \protected\def\sphinxbfcode#1{\sphinxcode{\bfseries{}#1}}
       
  1444 \protected\def\sphinxemail#1{\textsf{#1}}
       
  1445 \protected\def\sphinxtablecontinued#1{\textsf{#1}}
       
  1446 \protected\def\sphinxtitleref#1{\emph{#1}}
       
  1447 \protected\def\sphinxmenuselection#1{\emph{#1}}
       
  1448 \protected\def\sphinxaccelerator#1{\underline{#1}}
       
  1449 \protected\def\sphinxcrossref#1{\emph{#1}}
       
  1450 \protected\def\sphinxtermref#1{\emph{#1}}
       
  1451 % \optional is used for ``[, arg]``, i.e. desc_optional nodes.
       
  1452 \long\protected\def\sphinxoptional#1{%
       
  1453   {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}
       
  1454 
       
  1455 \ifspx@opt@dontkeepoldnames\else
       
  1456   \let\spx@alreadydefinedlist\@empty
       
  1457   \typeout{** (sphinx) defining (legacy) text style macros without \string\sphinx\space prefix}
       
  1458   \typeout{** if clashes with packages, do not set latex_keep_old_macro_names=True
       
  1459     in conf.py}
       
  1460   \@for\@tempa:=code,strong,bfcode,email,tablecontinued,titleref,%
       
  1461                 menuselection,accelerator,crossref,termref,optional\do
       
  1462  {% first, check if command with no prefix already exists
       
  1463   \ltx@ifundefined{\@tempa}{%
       
  1464   % give it the meaning defined so far with \sphinx prefix
       
  1465   \expandafter\let\csname\@tempa\expandafter\endcsname
       
  1466                   \csname sphinx\@tempa\endcsname
       
  1467   % redefine the \sphinx prefixed macro to expand to non-prefixed one
       
  1468   \expandafter\def\csname sphinx\@tempa\expandafter\endcsname
       
  1469                   \expandafter{\csname\@tempa\endcsname}%
       
  1470   }{\edef\spx@alreadydefinedlist{\spx@alreadydefinedlist{\@tempa}}}%
       
  1471  }%
       
  1472   \ifx\spx@alreadydefinedlist\@empty\else
       
  1473     \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=\spx@alreadydefinedlist\do
       
  1474     {% emit warning now
       
  1475      \PackageWarning{sphinx}{not redefining already existing \@backslashchar\@tempa\space!^^J%
       
  1476         Anyhow, Sphinx mark-up uses only \string\sphinx\@tempa.}%
       
  1477      % and also at end of log for better visibility
       
  1478      \expandafter\sphinxdeprecationwarning\expandafter{\csname\@tempa\endcsname}{1.6}{1.7}
       
  1479        {\sphinxdeprecatedmacro already existed at Sphinx loading time! Not redefined!^^J
       
  1480          Sphinx mark-up uses only \string\sphinx\expandafter\@gobble\sphinxdeprecatedmacro.^^J
       
  1481          Note: if this warning is about macro \string\strong, it presumably results^^J
       
  1482          from fontspec 2.6 having defined it prior to Sphinx. No need for alarm!}%
       
  1483     }%
       
  1484   \fi
       
  1485   \sphinxdeprecationwarning{latex_keep_old_macro_names=True}{1.6}{1.7}{}%
       
  1486 \fi
       
  1487 
       
  1488 % additional customizable styling
       
  1489 % FIXME: convert this to package options ?
       
  1490 \protected\def\sphinxstyleindexentry     {\texttt}
       
  1491 \protected\def\sphinxstyleindexextra #1{ \emph{(#1)}}
       
  1492 \protected\def\sphinxstyleindexpageref   {, \pageref}
       
  1493 \protected\def\sphinxstyletopictitle #1{\textbf{#1}\par\medskip}
       
  1494 \let\sphinxstylesidebartitle\sphinxstyletopictitle
       
  1495 \protected\def\sphinxstyleothertitle     {\textbf}
       
  1496 \protected\def\sphinxstylesidebarsubtitle #1{~\\\textbf{#1} \smallskip}
       
  1497 % \text.. commands do not allow multiple paragraphs
       
  1498 \let\sphinxstylethead\empty
       
  1499 \protected\def\sphinxstyletheadfamily {\ifx\sphinxstylethead\empty\sffamily\fi}
       
  1500 \AtBeginDocument{\ifx\sphinxstylethead\empty\else
       
  1501 \sphinxdeprecationwarning{\sphinxstylethead}{1.6}{1.7}{%
       
  1502     \string\sphinxstyletheadfamily\space replaces it
       
  1503     (it defaults to \string\sffamily) to allow use^^J
       
  1504     with multiple paragraphs. Backwards compatibility is maintained, but please^^J
       
  1505     move customization into \string\sphinxstyletheadfamily\space
       
  1506     in time for 1.7.^^J
       
  1507     And if you do it now, you will spare yourself this warning!}\fi}
       
  1508 \protected\def\sphinxstyleemphasis       {\emph}
       
  1509 \protected\def\sphinxstyleliteralemphasis#1{\emph{\sphinxcode{#1}}}
       
  1510 \protected\def\sphinxstylestrong         {\textbf}
       
  1511 \protected\def\sphinxstyleliteralstrong  {\sphinxbfcode}
       
  1512 \protected\def\sphinxstyleabbreviation   {\textsc}
       
  1513 \protected\def\sphinxstyleliteralintitle {\sphinxcode}
       
  1514 \newcommand*\sphinxstylecodecontinued[1]{\footnotesize(#1)}%
       
  1515 \newcommand*\sphinxstylecodecontinues[1]{\footnotesize(#1)}%
       
  1516 % figure legend comes after caption and may contain arbitrary body elements
       
  1517 \newenvironment{sphinxlegend}{\par\small}{\par}
       
  1518 
       
  1519 % Declare Unicode characters used by linux tree command to pdflatex utf8/utf8x
       
  1520 \def\spx@bd#1#2{%
       
  1521   \leavevmode
       
  1522   \begingroup
       
  1523   \ifx\spx@bd@height   \@undefined\def\spx@bd@height{\baselineskip}\fi
       
  1524   \ifx\spx@bd@width    \@undefined\setbox0\hbox{0}\def\spx@bd@width{\wd0 }\fi
       
  1525   \ifx\spx@bd@thickness\@undefined\def\spx@bd@thickness{.6\p@}\fi
       
  1526   \ifx\spx@bd@lower    \@undefined\def\spx@bd@lower{\dp\strutbox}\fi
       
  1527   \lower\spx@bd@lower#1{#2}%
       
  1528   \endgroup
       
  1529 }%
       
  1530 \@namedef{sphinx@u2500}% BOX DRAWINGS LIGHT HORIZONTAL
       
  1531   {\spx@bd{\vbox to\spx@bd@height}
       
  1532           {\vss\hrule\@height\spx@bd@thickness
       
  1533                      \@width\spx@bd@width\vss}}%
       
  1534 \@namedef{sphinx@u2502}% BOX DRAWINGS LIGHT VERTICAL
       
  1535   {\spx@bd{\hb@xt@\spx@bd@width}
       
  1536           {\hss\vrule\@height\spx@bd@height
       
  1537                      \@width \spx@bd@thickness\hss}}%
       
  1538 \@namedef{sphinx@u2514}% BOX DRAWINGS LIGHT UP AND RIGHT
       
  1539   {\spx@bd{\hb@xt@\spx@bd@width}
       
  1540           {\hss\raise.5\spx@bd@height
       
  1541            \hb@xt@\z@{\hss\vrule\@height.5\spx@bd@height
       
  1542                                 \@width \spx@bd@thickness\hss}%
       
  1543            \vbox to\spx@bd@height{\vss\hrule\@height\spx@bd@thickness
       
  1544                                             \@width.5\spx@bd@width\vss}}}%
       
  1545 \@namedef{sphinx@u251C}% BOX DRAWINGS LIGHT VERTICAL AND RIGHT
       
  1546   {\spx@bd{\hb@xt@\spx@bd@width}
       
  1547           {\hss
       
  1548            \hb@xt@\z@{\hss\vrule\@height\spx@bd@height
       
  1549                                 \@width \spx@bd@thickness\hss}%
       
  1550            \vbox to\spx@bd@height{\vss\hrule\@height\spx@bd@thickness
       
  1551                                             \@width.5\spx@bd@width\vss}}}%
       
  1552 \protected\def\sphinxunichar#1{\@nameuse{sphinx@u#1}}%
       
  1553 
       
  1554 % Tell TeX about pathological hyphenation cases:
       
  1555 \hyphenation{Base-HTTP-Re-quest-Hand-ler}
       
  1556 \endinput