Fri, 11 May 2012 13:25:05 +0200
Restructuring the repository.
ulalume3@11 | 1 | % |
ulalume3@11 | 2 | % sphinx.sty |
ulalume3@11 | 3 | % |
ulalume3@11 | 4 | % Adapted from the old python.sty, mostly written by Fred Drake, |
ulalume3@11 | 5 | % by Georg Brandl. |
ulalume3@11 | 6 | % |
ulalume3@11 | 7 | |
ulalume3@11 | 8 | \NeedsTeXFormat{LaTeX2e}[1995/12/01] |
ulalume3@11 | 9 | \ProvidesPackage{sphinx}[2010/01/15 LaTeX package (Sphinx markup)] |
ulalume3@11 | 10 | |
ulalume3@11 | 11 | \RequirePackage{textcomp} |
ulalume3@11 | 12 | \RequirePackage{fancyhdr} |
ulalume3@11 | 13 | \RequirePackage{fancybox} |
ulalume3@11 | 14 | \RequirePackage{titlesec} |
ulalume3@11 | 15 | \RequirePackage{tabulary} |
ulalume3@11 | 16 | \RequirePackage{amsmath} % for \text |
ulalume3@11 | 17 | \RequirePackage{makeidx} |
ulalume3@11 | 18 | \RequirePackage{framed} |
ulalume3@11 | 19 | \RequirePackage{ifthen} |
ulalume3@11 | 20 | \RequirePackage{color} |
ulalume3@11 | 21 | % For highlighted code. |
ulalume3@11 | 22 | \RequirePackage{fancyvrb} |
ulalume3@11 | 23 | % For table captions. |
ulalume3@11 | 24 | \RequirePackage{threeparttable} |
ulalume3@11 | 25 | % Handle footnotes in tables. |
ulalume3@11 | 26 | \RequirePackage{footnote} |
ulalume3@11 | 27 | \makesavenoteenv{tabulary} |
ulalume3@11 | 28 | % For floating figures in the text. |
ulalume3@11 | 29 | \RequirePackage{wrapfig} |
ulalume3@11 | 30 | % Separate paragraphs by space by default. |
ulalume3@11 | 31 | \RequirePackage{parskip} |
ulalume3@11 | 32 | |
ulalume3@11 | 33 | % Redefine these colors to your liking in the preamble. |
ulalume3@11 | 34 | \definecolor{TitleColor}{rgb}{0.126,0.263,0.361} |
ulalume3@11 | 35 | \definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486} |
ulalume3@11 | 36 | \definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388} |
ulalume3@11 | 37 | % Redefine these colors to something not white if you want to have colored |
ulalume3@11 | 38 | % background and border for code examples. |
ulalume3@11 | 39 | \definecolor{VerbatimColor}{rgb}{1,1,1} |
ulalume3@11 | 40 | \definecolor{VerbatimBorderColor}{rgb}{1,1,1} |
ulalume3@11 | 41 | |
ulalume3@11 | 42 | % Uncomment these two lines to ignore the paper size and make the page |
ulalume3@11 | 43 | % size more like a typical published manual. |
ulalume3@11 | 44 | %\renewcommand{\paperheight}{9in} |
ulalume3@11 | 45 | %\renewcommand{\paperwidth}{8.5in} % typical squarish manual |
ulalume3@11 | 46 | %\renewcommand{\paperwidth}{7in} % O'Reilly ``Programmming Python'' |
ulalume3@11 | 47 | |
ulalume3@11 | 48 | % For graphicx, check if we are compiling under latex or pdflatex. |
ulalume3@11 | 49 | \ifx\pdftexversion\undefined |
ulalume3@11 | 50 | \usepackage{graphicx} |
ulalume3@11 | 51 | \else |
ulalume3@11 | 52 | \usepackage[pdftex]{graphicx} |
ulalume3@11 | 53 | \fi |
ulalume3@11 | 54 | |
ulalume3@11 | 55 | % for PDF output, use colors and maximal compression |
ulalume3@11 | 56 | \newif\ifsphinxpdfoutput\sphinxpdfoutputfalse |
ulalume3@11 | 57 | \ifx\pdfoutput\undefined\else\ifcase\pdfoutput |
ulalume3@11 | 58 | \let\py@NormalColor\relax |
ulalume3@11 | 59 | \let\py@TitleColor\relax |
ulalume3@11 | 60 | \else |
ulalume3@11 | 61 | \sphinxpdfoutputtrue |
ulalume3@11 | 62 | \input{pdfcolor} |
ulalume3@11 | 63 | \def\py@NormalColor{\color[rgb]{0.0,0.0,0.0}} |
ulalume3@11 | 64 | \def\py@TitleColor{\color{TitleColor}} |
ulalume3@11 | 65 | \pdfcompresslevel=9 |
ulalume3@11 | 66 | \fi\fi |
ulalume3@11 | 67 | |
ulalume3@11 | 68 | % XeLaTeX can do colors, too |
ulalume3@11 | 69 | \ifx\XeTeXrevision\undefined\else |
ulalume3@11 | 70 | \def\py@NormalColor{\color[rgb]{0.0,0.0,0.0}} |
ulalume3@11 | 71 | \def\py@TitleColor{\color{TitleColor}} |
ulalume3@11 | 72 | \fi |
ulalume3@11 | 73 | |
ulalume3@11 | 74 | % Increase printable page size (copied from fullpage.sty) |
ulalume3@11 | 75 | \topmargin 0pt |
ulalume3@11 | 76 | \advance \topmargin by -\headheight |
ulalume3@11 | 77 | \advance \topmargin by -\headsep |
ulalume3@11 | 78 | |
ulalume3@11 | 79 | % attempt to work a little better for A4 users |
ulalume3@11 | 80 | \textheight \paperheight |
ulalume3@11 | 81 | \advance\textheight by -2in |
ulalume3@11 | 82 | |
ulalume3@11 | 83 | \oddsidemargin 0pt |
ulalume3@11 | 84 | \evensidemargin 0pt |
ulalume3@11 | 85 | %\evensidemargin -.25in % for ``manual size'' documents |
ulalume3@11 | 86 | \marginparwidth 0.5in |
ulalume3@11 | 87 | |
ulalume3@11 | 88 | \textwidth \paperwidth |
ulalume3@11 | 89 | \advance\textwidth by -2in |
ulalume3@11 | 90 | |
ulalume3@11 | 91 | |
ulalume3@11 | 92 | % Style parameters and macros used by most documents here |
ulalume3@11 | 93 | \raggedbottom |
ulalume3@11 | 94 | \sloppy |
ulalume3@11 | 95 | \hbadness = 5000 % don't print trivial gripes |
ulalume3@11 | 96 | |
ulalume3@11 | 97 | \pagestyle{empty} % start this way; change for |
ulalume3@11 | 98 | \pagenumbering{roman} % ToC & chapters |
ulalume3@11 | 99 | |
ulalume3@11 | 100 | % Use this to set the font family for headers and other decor: |
ulalume3@11 | 101 | \newcommand{\py@HeaderFamily}{\sffamily\bfseries} |
ulalume3@11 | 102 | |
ulalume3@11 | 103 | % Redefine the 'normal' header/footer style when using "fancyhdr" package: |
ulalume3@11 | 104 | \@ifundefined{fancyhf}{}{ |
ulalume3@11 | 105 | % Use \pagestyle{normal} as the primary pagestyle for text. |
ulalume3@11 | 106 | \fancypagestyle{normal}{ |
ulalume3@11 | 107 | \fancyhf{} |
ulalume3@11 | 108 | \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} |
ulalume3@11 | 109 | \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}} |
ulalume3@11 | 110 | \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}} |
ulalume3@11 | 111 | \fancyhead[LE,RO]{{\py@HeaderFamily \@title, \py@release}} |
ulalume3@11 | 112 | \renewcommand{\headrulewidth}{0.4pt} |
ulalume3@11 | 113 | \renewcommand{\footrulewidth}{0.4pt} |
ulalume3@11 | 114 | } |
ulalume3@11 | 115 | % Update the plain style so we get the page number & footer line, |
ulalume3@11 | 116 | % but not a chapter or section title. This is to keep the first |
ulalume3@11 | 117 | % page of a chapter and the blank page between chapters `clean.' |
ulalume3@11 | 118 | \fancypagestyle{plain}{ |
ulalume3@11 | 119 | \fancyhf{} |
ulalume3@11 | 120 | \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}} |
ulalume3@11 | 121 | \renewcommand{\headrulewidth}{0pt} |
ulalume3@11 | 122 | \renewcommand{\footrulewidth}{0.4pt} |
ulalume3@11 | 123 | } |
ulalume3@11 | 124 | } |
ulalume3@11 | 125 | |
ulalume3@11 | 126 | % Some custom font markup commands. |
ulalume3@11 | 127 | % |
ulalume3@11 | 128 | \newcommand{\strong}[1]{{\bf #1}} |
ulalume3@11 | 129 | \newcommand{\code}[1]{\texttt{#1}} |
ulalume3@11 | 130 | \newcommand{\bfcode}[1]{\code{\bfseries#1}} |
ulalume3@11 | 131 | \newcommand{\email}[1]{\textsf{#1}} |
ulalume3@11 | 132 | |
ulalume3@11 | 133 | % Redefine the Verbatim environment to allow border and background colors. |
ulalume3@11 | 134 | % The original environment is still used for verbatims within tables. |
ulalume3@11 | 135 | \let\OriginalVerbatim=\Verbatim |
ulalume3@11 | 136 | \let\endOriginalVerbatim=\endVerbatim |
ulalume3@11 | 137 | |
ulalume3@11 | 138 | % Play with vspace to be able to keep the indentation. |
ulalume3@11 | 139 | \newlength\distancetoright |
ulalume3@11 | 140 | \def\mycolorbox#1{% |
ulalume3@11 | 141 | \setlength\distancetoright{\linewidth}% |
ulalume3@11 | 142 | \advance\distancetoright -\@totalleftmargin % |
ulalume3@11 | 143 | \fcolorbox{VerbatimBorderColor}{VerbatimColor}{% |
ulalume3@11 | 144 | \begin{minipage}{\distancetoright}% |
ulalume3@11 | 145 | #1 |
ulalume3@11 | 146 | \end{minipage}% |
ulalume3@11 | 147 | }% |
ulalume3@11 | 148 | } |
ulalume3@11 | 149 | \def\FrameCommand{\mycolorbox} |
ulalume3@11 | 150 | |
ulalume3@11 | 151 | \renewcommand{\Verbatim}[1][1]{% |
ulalume3@11 | 152 | % list starts new par, but we don't want it to be set apart vertically |
ulalume3@11 | 153 | \bgroup\parskip=0pt% |
ulalume3@11 | 154 | \smallskip% |
ulalume3@11 | 155 | % The list environement is needed to control perfectly the vertical |
ulalume3@11 | 156 | % space. |
ulalume3@11 | 157 | \list{}{% |
ulalume3@11 | 158 | \setlength\parskip{0pt}% |
ulalume3@11 | 159 | \setlength\itemsep{0ex}% |
ulalume3@11 | 160 | \setlength\topsep{0ex}% |
ulalume3@11 | 161 | \setlength\partopsep{0pt}% |
ulalume3@11 | 162 | \setlength\leftmargin{0pt}% |
ulalume3@11 | 163 | }% |
ulalume3@11 | 164 | \item\MakeFramed {\FrameRestore}% |
ulalume3@11 | 165 | \small% |
ulalume3@11 | 166 | \OriginalVerbatim[#1]% |
ulalume3@11 | 167 | } |
ulalume3@11 | 168 | \renewcommand{\endVerbatim}{% |
ulalume3@11 | 169 | \endOriginalVerbatim% |
ulalume3@11 | 170 | \endMakeFramed% |
ulalume3@11 | 171 | \endlist% |
ulalume3@11 | 172 | % close group to restore \parskip |
ulalume3@11 | 173 | \egroup% |
ulalume3@11 | 174 | } |
ulalume3@11 | 175 | |
ulalume3@11 | 176 | |
ulalume3@11 | 177 | % \moduleauthor{name}{email} |
ulalume3@11 | 178 | \newcommand{\moduleauthor}[2]{} |
ulalume3@11 | 179 | |
ulalume3@11 | 180 | % \sectionauthor{name}{email} |
ulalume3@11 | 181 | \newcommand{\sectionauthor}[2]{} |
ulalume3@11 | 182 | |
ulalume3@11 | 183 | % Augment the sectioning commands used to get our own font family in place, |
ulalume3@11 | 184 | % and reset some internal data items: |
ulalume3@11 | 185 | \titleformat{\section}{\Large\py@HeaderFamily}% |
ulalume3@11 | 186 | {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor} |
ulalume3@11 | 187 | \titleformat{\subsection}{\large\py@HeaderFamily}% |
ulalume3@11 | 188 | {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} |
ulalume3@11 | 189 | \titleformat{\subsubsection}{\py@HeaderFamily}% |
ulalume3@11 | 190 | {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} |
ulalume3@11 | 191 | \titleformat{\paragraph}{\small\py@HeaderFamily}% |
ulalume3@11 | 192 | {\py@TitleColor}{0em}{\py@TitleColor}{\py@NormalColor} |
ulalume3@11 | 193 | |
ulalume3@11 | 194 | % {fulllineitems} is the main environment for object descriptions. |
ulalume3@11 | 195 | % |
ulalume3@11 | 196 | \newcommand{\py@itemnewline}[1]{% |
ulalume3@11 | 197 | \@tempdima\linewidth% |
ulalume3@11 | 198 | \advance\@tempdima \leftmargin\makebox[\@tempdima][l]{#1}% |
ulalume3@11 | 199 | } |
ulalume3@11 | 200 | |
ulalume3@11 | 201 | \newenvironment{fulllineitems}{ |
ulalume3@11 | 202 | \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt |
ulalume3@11 | 203 | \rightmargin 0pt \topsep -\parskip \partopsep \parskip |
ulalume3@11 | 204 | \itemsep -\parsep |
ulalume3@11 | 205 | \let\makelabel=\py@itemnewline} |
ulalume3@11 | 206 | }{\end{list}} |
ulalume3@11 | 207 | |
ulalume3@11 | 208 | % \optional is used for ``[, arg]``, i.e. desc_optional nodes. |
ulalume3@11 | 209 | \newcommand{\optional}[1]{% |
ulalume3@11 | 210 | {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} |
ulalume3@11 | 211 | |
ulalume3@11 | 212 | \newlength{\py@argswidth} |
ulalume3@11 | 213 | \newcommand{\py@sigparams}[2]{% |
ulalume3@11 | 214 | \parbox[t]{\py@argswidth}{#1\code{)}#2}} |
ulalume3@11 | 215 | \newcommand{\pysigline}[1]{\item[#1]\nopagebreak} |
ulalume3@11 | 216 | \newcommand{\pysiglinewithargsret}[3]{% |
ulalume3@11 | 217 | \settowidth{\py@argswidth}{#1\code{(}}% |
ulalume3@11 | 218 | \addtolength{\py@argswidth}{-2\py@argswidth}% |
ulalume3@11 | 219 | \addtolength{\py@argswidth}{\linewidth}% |
ulalume3@11 | 220 | \item[#1\code{(}\py@sigparams{#2}{#3}]} |
ulalume3@11 | 221 | |
ulalume3@11 | 222 | % Production lists |
ulalume3@11 | 223 | % |
ulalume3@11 | 224 | \newenvironment{productionlist}{ |
ulalume3@11 | 225 | % \def\optional##1{{\Large[}##1{\Large]}} |
ulalume3@11 | 226 | \def\production##1##2{\\\code{##1}&::=&\code{##2}} |
ulalume3@11 | 227 | \def\productioncont##1{\\& &\code{##1}} |
ulalume3@11 | 228 | \parindent=2em |
ulalume3@11 | 229 | \indent |
ulalume3@11 | 230 | \begin{tabular}{lcl} |
ulalume3@11 | 231 | }{% |
ulalume3@11 | 232 | \end{tabular} |
ulalume3@11 | 233 | } |
ulalume3@11 | 234 | |
ulalume3@11 | 235 | % Notices / Admonitions |
ulalume3@11 | 236 | % |
ulalume3@11 | 237 | \newlength{\py@noticelength} |
ulalume3@11 | 238 | |
ulalume3@11 | 239 | \newcommand{\py@heavybox}{ |
ulalume3@11 | 240 | \setlength{\fboxrule}{1pt} |
ulalume3@11 | 241 | \setlength{\fboxsep}{6pt} |
ulalume3@11 | 242 | \setlength{\py@noticelength}{\linewidth} |
ulalume3@11 | 243 | \addtolength{\py@noticelength}{-2\fboxsep} |
ulalume3@11 | 244 | \addtolength{\py@noticelength}{-2\fboxrule} |
ulalume3@11 | 245 | %\setlength{\shadowsize}{3pt} |
ulalume3@11 | 246 | \Sbox |
ulalume3@11 | 247 | \minipage{\py@noticelength} |
ulalume3@11 | 248 | } |
ulalume3@11 | 249 | \newcommand{\py@endheavybox}{ |
ulalume3@11 | 250 | \endminipage |
ulalume3@11 | 251 | \endSbox |
ulalume3@11 | 252 | \fbox{\TheSbox} |
ulalume3@11 | 253 | } |
ulalume3@11 | 254 | |
ulalume3@11 | 255 | \newcommand{\py@lightbox}{{% |
ulalume3@11 | 256 | \setlength\parskip{0pt}\par |
ulalume3@11 | 257 | \rule[0ex]{\linewidth}{0.5pt}% |
ulalume3@11 | 258 | \par\vspace{-0.5ex}% |
ulalume3@11 | 259 | }} |
ulalume3@11 | 260 | \newcommand{\py@endlightbox}{{% |
ulalume3@11 | 261 | \setlength{\parskip}{0pt}% |
ulalume3@11 | 262 | \par\rule[0.5ex]{\linewidth}{0.5pt}% |
ulalume3@11 | 263 | \par\vspace{-0.5ex}% |
ulalume3@11 | 264 | }} |
ulalume3@11 | 265 | |
ulalume3@11 | 266 | % Some are quite plain: |
ulalume3@11 | 267 | \newcommand{\py@noticestart@note}{\py@lightbox} |
ulalume3@11 | 268 | \newcommand{\py@noticeend@note}{\py@endlightbox} |
ulalume3@11 | 269 | \newcommand{\py@noticestart@hint}{\py@lightbox} |
ulalume3@11 | 270 | \newcommand{\py@noticeend@hint}{\py@endlightbox} |
ulalume3@11 | 271 | \newcommand{\py@noticestart@important}{\py@lightbox} |
ulalume3@11 | 272 | \newcommand{\py@noticeend@important}{\py@endlightbox} |
ulalume3@11 | 273 | \newcommand{\py@noticestart@tip}{\py@lightbox} |
ulalume3@11 | 274 | \newcommand{\py@noticeend@tip}{\py@endlightbox} |
ulalume3@11 | 275 | |
ulalume3@11 | 276 | % Others gets more visible distinction: |
ulalume3@11 | 277 | \newcommand{\py@noticestart@warning}{\py@heavybox} |
ulalume3@11 | 278 | \newcommand{\py@noticeend@warning}{\py@endheavybox} |
ulalume3@11 | 279 | \newcommand{\py@noticestart@caution}{\py@heavybox} |
ulalume3@11 | 280 | \newcommand{\py@noticeend@caution}{\py@endheavybox} |
ulalume3@11 | 281 | \newcommand{\py@noticestart@attention}{\py@heavybox} |
ulalume3@11 | 282 | \newcommand{\py@noticeend@attention}{\py@endheavybox} |
ulalume3@11 | 283 | \newcommand{\py@noticestart@danger}{\py@heavybox} |
ulalume3@11 | 284 | \newcommand{\py@noticeend@danger}{\py@endheavybox} |
ulalume3@11 | 285 | \newcommand{\py@noticestart@error}{\py@heavybox} |
ulalume3@11 | 286 | \newcommand{\py@noticeend@error}{\py@endheavybox} |
ulalume3@11 | 287 | |
ulalume3@11 | 288 | \newenvironment{notice}[2]{ |
ulalume3@11 | 289 | \def\py@noticetype{#1} |
ulalume3@11 | 290 | \csname py@noticestart@#1\endcsname |
ulalume3@11 | 291 | \strong{#2} |
ulalume3@11 | 292 | }{\csname py@noticeend@\py@noticetype\endcsname} |
ulalume3@11 | 293 | |
ulalume3@11 | 294 | % Allow the release number to be specified independently of the |
ulalume3@11 | 295 | % \date{}. This allows the date to reflect the document's date and |
ulalume3@11 | 296 | % release to specify the release that is documented. |
ulalume3@11 | 297 | % |
ulalume3@11 | 298 | \newcommand{\py@release}{} |
ulalume3@11 | 299 | \newcommand{\version}{} |
ulalume3@11 | 300 | \newcommand{\shortversion}{} |
ulalume3@11 | 301 | \newcommand{\releaseinfo}{} |
ulalume3@11 | 302 | \newcommand{\releasename}{Release} |
ulalume3@11 | 303 | \newcommand{\release}[1]{% |
ulalume3@11 | 304 | \renewcommand{\py@release}{\releasename\space\version}% |
ulalume3@11 | 305 | \renewcommand{\version}{#1}} |
ulalume3@11 | 306 | \newcommand{\setshortversion}[1]{% |
ulalume3@11 | 307 | \renewcommand{\shortversion}{#1}} |
ulalume3@11 | 308 | \newcommand{\setreleaseinfo}[1]{% |
ulalume3@11 | 309 | \renewcommand{\releaseinfo}{#1}} |
ulalume3@11 | 310 | |
ulalume3@11 | 311 | % Allow specification of the author's address separately from the |
ulalume3@11 | 312 | % author's name. This can be used to format them differently, which |
ulalume3@11 | 313 | % is a good thing. |
ulalume3@11 | 314 | % |
ulalume3@11 | 315 | \newcommand{\py@authoraddress}{} |
ulalume3@11 | 316 | \newcommand{\authoraddress}[1]{\renewcommand{\py@authoraddress}{#1}} |
ulalume3@11 | 317 | |
ulalume3@11 | 318 | % This sets up the fancy chapter headings that make the documents look |
ulalume3@11 | 319 | % at least a little better than the usual LaTeX output. |
ulalume3@11 | 320 | % |
ulalume3@11 | 321 | \@ifundefined{ChTitleVar}{}{ |
ulalume3@11 | 322 | \ChNameVar{\raggedleft\normalsize\py@HeaderFamily} |
ulalume3@11 | 323 | \ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily} |
ulalume3@11 | 324 | \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily} |
ulalume3@11 | 325 | % This creates chapter heads without the leading \vspace*{}: |
ulalume3@11 | 326 | \def\@makechapterhead#1{% |
ulalume3@11 | 327 | {\parindent \z@ \raggedright \normalfont |
ulalume3@11 | 328 | \ifnum \c@secnumdepth >\m@ne |
ulalume3@11 | 329 | \DOCH |
ulalume3@11 | 330 | \fi |
ulalume3@11 | 331 | \interlinepenalty\@M |
ulalume3@11 | 332 | \DOTI{#1} |
ulalume3@11 | 333 | } |
ulalume3@11 | 334 | } |
ulalume3@11 | 335 | } |
ulalume3@11 | 336 | |
ulalume3@11 | 337 | % Redefine description environment so that it is usable inside fulllineitems. |
ulalume3@11 | 338 | % |
ulalume3@11 | 339 | \renewcommand{\description}{% |
ulalume3@11 | 340 | \list{}{\labelwidth\z@% |
ulalume3@11 | 341 | \itemindent-\leftmargin% |
ulalume3@11 | 342 | \labelsep5pt% |
ulalume3@11 | 343 | \let\makelabel=\descriptionlabel}} |
ulalume3@11 | 344 | |
ulalume3@11 | 345 | % Definition lists; requested by AMK for HOWTO documents. Probably useful |
ulalume3@11 | 346 | % elsewhere as well, so keep in in the general style support. |
ulalume3@11 | 347 | % |
ulalume3@11 | 348 | \newenvironment{definitions}{% |
ulalume3@11 | 349 | \begin{description}% |
ulalume3@11 | 350 | \def\term##1{\item[##1]\mbox{}\\*[0mm]} |
ulalume3@11 | 351 | }{% |
ulalume3@11 | 352 | \end{description}% |
ulalume3@11 | 353 | } |
ulalume3@11 | 354 | |
ulalume3@11 | 355 | % Tell TeX about pathological hyphenation cases: |
ulalume3@11 | 356 | \hyphenation{Base-HTTP-Re-quest-Hand-ler} |
ulalume3@11 | 357 | |
ulalume3@11 | 358 | |
ulalume3@11 | 359 | % The following is stuff copied from docutils' latex writer. |
ulalume3@11 | 360 | % |
ulalume3@11 | 361 | \newcommand{\optionlistlabel}[1]{\bf #1 \hfill} |
ulalume3@11 | 362 | \newenvironment{optionlist}[1] |
ulalume3@11 | 363 | {\begin{list}{} |
ulalume3@11 | 364 | {\setlength{\labelwidth}{#1} |
ulalume3@11 | 365 | \setlength{\rightmargin}{1cm} |
ulalume3@11 | 366 | \setlength{\leftmargin}{\rightmargin} |
ulalume3@11 | 367 | \addtolength{\leftmargin}{\labelwidth} |
ulalume3@11 | 368 | \addtolength{\leftmargin}{\labelsep} |
ulalume3@11 | 369 | \renewcommand{\makelabel}{\optionlistlabel}} |
ulalume3@11 | 370 | }{\end{list}} |
ulalume3@11 | 371 | |
ulalume3@11 | 372 | \newlength{\lineblockindentation} |
ulalume3@11 | 373 | \setlength{\lineblockindentation}{2.5em} |
ulalume3@11 | 374 | \newenvironment{lineblock}[1] |
ulalume3@11 | 375 | {\begin{list}{} |
ulalume3@11 | 376 | {\setlength{\partopsep}{\parskip} |
ulalume3@11 | 377 | \addtolength{\partopsep}{\baselineskip} |
ulalume3@11 | 378 | \topsep0pt\itemsep0.15\baselineskip\parsep0pt |
ulalume3@11 | 379 | \leftmargin#1} |
ulalume3@11 | 380 | \raggedright} |
ulalume3@11 | 381 | {\end{list}} |
ulalume3@11 | 382 | |
ulalume3@11 | 383 | % Redefine includgraphics for avoiding images larger than the screen size |
ulalume3@11 | 384 | % If the size is not specified. |
ulalume3@11 | 385 | \let\py@Oldincludegraphics\includegraphics |
ulalume3@11 | 386 | |
ulalume3@11 | 387 | \newbox\image@box% |
ulalume3@11 | 388 | \newdimen\image@width% |
ulalume3@11 | 389 | \renewcommand\includegraphics[2][\@empty]{% |
ulalume3@11 | 390 | \ifx#1\@empty% |
ulalume3@11 | 391 | \setbox\image@box=\hbox{\py@Oldincludegraphics{#2}}% |
ulalume3@11 | 392 | \image@width\wd\image@box% |
ulalume3@11 | 393 | \ifdim \image@width>\linewidth% |
ulalume3@11 | 394 | \setbox\image@box=\hbox{\py@Oldincludegraphics[width=\linewidth]{#2}}% |
ulalume3@11 | 395 | \box\image@box% |
ulalume3@11 | 396 | \else% |
ulalume3@11 | 397 | \py@Oldincludegraphics{#2}% |
ulalume3@11 | 398 | \fi% |
ulalume3@11 | 399 | \else% |
ulalume3@11 | 400 | \py@Oldincludegraphics[#1]{#2}% |
ulalume3@11 | 401 | \fi% |
ulalume3@11 | 402 | } |
ulalume3@11 | 403 | |
ulalume3@11 | 404 | |
ulalume3@11 | 405 | % Fix the index and bibliography environments to add an entry to the Table of |
ulalume3@11 | 406 | % Contents; this is much nicer than just having to jump to the end of the book |
ulalume3@11 | 407 | % and flip around, especially with multiple indexes. |
ulalume3@11 | 408 | % |
ulalume3@11 | 409 | \let\py@OldTheindex=\theindex |
ulalume3@11 | 410 | \renewcommand{\theindex}{ |
ulalume3@11 | 411 | \cleardoublepage |
ulalume3@11 | 412 | \phantomsection |
ulalume3@11 | 413 | \py@OldTheindex |
ulalume3@11 | 414 | \addcontentsline{toc}{chapter}{\indexname} |
ulalume3@11 | 415 | } |
ulalume3@11 | 416 | |
ulalume3@11 | 417 | \let\py@OldThebibliography=\thebibliography |
ulalume3@11 | 418 | \renewcommand{\thebibliography}[1]{ |
ulalume3@11 | 419 | \cleardoublepage |
ulalume3@11 | 420 | \phantomsection |
ulalume3@11 | 421 | \py@OldThebibliography{1} |
ulalume3@11 | 422 | \addcontentsline{toc}{chapter}{\bibname} |
ulalume3@11 | 423 | } |
ulalume3@11 | 424 | |
ulalume3@11 | 425 | % Include hyperref last. |
ulalume3@11 | 426 | \RequirePackage[colorlinks,breaklinks, |
ulalume3@11 | 427 | linkcolor=InnerLinkColor,filecolor=OuterLinkColor, |
ulalume3@11 | 428 | menucolor=OuterLinkColor,urlcolor=OuterLinkColor, |
ulalume3@11 | 429 | citecolor=InnerLinkColor]{hyperref} |
ulalume3@11 | 430 | % Fix anchor placement for figures with captions. |
ulalume3@11 | 431 | % (Note: we don't use a package option here; instead, we give an explicit |
ulalume3@11 | 432 | % \capstart for figures that actually have a caption.) |
ulalume3@11 | 433 | \RequirePackage{hypcap} |
ulalume3@11 | 434 | |
ulalume3@11 | 435 | % From docutils.writers.latex2e |
ulalume3@11 | 436 | \providecommand{\DUspan}[2]{% |
ulalume3@11 | 437 | {% group ("span") to limit the scope of styling commands |
ulalume3@11 | 438 | \@for\node@class@name:=#1\do{% |
ulalume3@11 | 439 | \ifcsname docutilsrole\node@class@name\endcsname% |
ulalume3@11 | 440 | \csname docutilsrole\node@class@name\endcsname% |
ulalume3@11 | 441 | \fi% |
ulalume3@11 | 442 | }% |
ulalume3@11 | 443 | {#2}% node content |
ulalume3@11 | 444 | }% close "span" |
ulalume3@11 | 445 | } |
ulalume3@11 | 446 | |
ulalume3@11 | 447 | \providecommand*{\DUprovidelength}[2]{ |
ulalume3@11 | 448 | \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{} |
ulalume3@11 | 449 | } |
ulalume3@11 | 450 | |
ulalume3@11 | 451 | \DUprovidelength{\DUlineblockindent}{2.5em} |
ulalume3@11 | 452 | \ifthenelse{\isundefined{\DUlineblock}}{ |
ulalume3@11 | 453 | \newenvironment{DUlineblock}[1]{% |
ulalume3@11 | 454 | \list{}{\setlength{\partopsep}{\parskip} |
ulalume3@11 | 455 | \addtolength{\partopsep}{\baselineskip} |
ulalume3@11 | 456 | \setlength{\topsep}{0pt} |
ulalume3@11 | 457 | \setlength{\itemsep}{0.15\baselineskip} |
ulalume3@11 | 458 | \setlength{\parsep}{0pt} |
ulalume3@11 | 459 | \setlength{\leftmargin}{#1}} |
ulalume3@11 | 460 | \raggedright |
ulalume3@11 | 461 | } |
ulalume3@11 | 462 | {\endlist} |
ulalume3@11 | 463 | }{} |
ulalume3@11 | 464 | |
ulalume3@11 | 465 | |
ulalume3@11 | 466 | % From footmisc.sty: allows footnotes in titles |
ulalume3@11 | 467 | \let\FN@sf@@footnote\footnote |
ulalume3@11 | 468 | \def\footnote{\ifx\protect\@typeset@protect |
ulalume3@11 | 469 | \expandafter\FN@sf@@footnote |
ulalume3@11 | 470 | \else |
ulalume3@11 | 471 | \expandafter\FN@sf@gobble@opt |
ulalume3@11 | 472 | \fi |
ulalume3@11 | 473 | } |
ulalume3@11 | 474 | \edef\FN@sf@gobble@opt{\noexpand\protect |
ulalume3@11 | 475 | \expandafter\noexpand\csname FN@sf@gobble@opt \endcsname} |
ulalume3@11 | 476 | \expandafter\def\csname FN@sf@gobble@opt \endcsname{% |
ulalume3@11 | 477 | \@ifnextchar[%] |
ulalume3@11 | 478 | \FN@sf@gobble@twobracket |
ulalume3@11 | 479 | \@gobble |
ulalume3@11 | 480 | } |
ulalume3@11 | 481 | \def\FN@sf@gobble@twobracket[#1]#2{} |