HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/docutils/writers/latex2e/__pycache__/__init__.cpython-36.pyc
3

�2�e���@s�dZdZddlZddlZddlZddlZddlZddlZddl	Zddl
ZyddlZWn ek
rtddl
jjZYnXddlmZmZmZmZmZmZddlmZddlmZddlmZmZGdd	�d	ej�ZGd
d�de�ZGdd
�d
e�Z Gdd�de�Z!de!_"de!_#de!_$de!_%de!_&de!_'de!_(de!_)de!_*de!_+de!_,de!_-de!_.de!_/de!_0de!_1d e!_2d!e!_3d"e!_4d#e!_5d$e!_6d%e!_7d&e!_8d'e!_9d(e!_:d)e!_;d*e!_<d+e!_=d,e!_>Gd-d.�d.e�Z?Gd/d0�d0e�Z@Gd1d2�d2e�ZAGd3d4�d4ejB�ZCdS)5zLaTeX2e document tree Writer.ZreStructuredText�N)�frontend�nodes�	languages�writers�utils�io)�
SafeString)�
writer_aux)�pick_math_environment�unichar2texc(@seZdZd�ZdZejjejje	��Z
djddddg�Zd�Z
ddddgddifddgddifddgddejd�fddgdd gdd!d"d#�fd$d%gd&dejd�fd'd(gd)d*ejd+�fd,d-gd.d/d0d1gd.d!d2�fd3d4gd5d6d7ejd8�fd9d:gd6d;ejd<�fd=d>gd?d*d@�fdAdBgd&dejd�fdCdDgdEejdFgdG�fdHdIgdeifdJedKgedLdM�fdNdOgdPdejd�fdQdRgdSd*ejd+�fdTdUgd&dejd�fdVdWgdXd*ejd+�fdYdZgd&dejd�fd[d\gd]d*ejd+�fd^d_gd&dejd�fd`dagddbifdcddgdd5ifdedfgddejd�fdgdhgd*didj�fdkdlgddejd�fdmdngd*dodj�fdpdqgdrdsdM�fdtdugdd5ifdvdwgd&dejd�fdxdygd	gd!dzeje
d{�fd|d}gdd5ifd~dgdd�ifd�d�gddifd�d�gddiff#fZd�d&iZd�Zd�Zd�Zed�ZdZd�d��Zd�d��Zd�d��Zd�d��ZdS)��Writer�latex�latex2ezdefault.tex�
z% PDF Standard Fontsz\usepackage{mathptmx} % Timesz\usepackage[scaled=.90]{helvet}z\usepackage{courier}�standard�booktabs�nolines�
borderless�colwidths-auto�colwidths-givenzLaTeX-Specific OptionsNz-Specify documentclass.  Default is "article".z--documentclass�defaultZarticlezeSpecify document options.  Multiple options can be given, separated by commas.  Default is "a4paper".z--documentoptionsZa4paperz5Footnotes with numbers/symbols by Docutils. (default)z--docutils-footnotesT�
store_true)r�action�	validatorz^Format for footnote references: one of "superscript" or "brackets".  Default is "superscript".z--footnote-references�superscript�bracketsz<format>Ztrim_footnote_reference_space)�choicesr�metavar�	overridesz!Use \cite command for citations. z--use-latex-citationsrzNUse figure floats for citations (might get mixed with real figures). (default)z--figure-citations�use_latex_citationsZstore_false)�destrrz{Format for block quote attributions: one of "dash" (em-dash prefix), "parentheses"/"parens", or "none".  Default is "dash".z
--attribution�dash�parentheses�parens�none)rrrz�Specify LaTeX packages/stylesheets.  A style is referenced with \usepackage if extension is ".sty" or omitted and with \input else.  Overrides previous --stylesheet and --stylesheet-path settings.z--stylesheet�z<file[,file,...]>�stylesheet_path)rrrrz�Comma separated list of LaTeX packages/stylesheets. Relative paths are expanded if a matching file is found in the --stylesheet-dirs. With --link-stylesheet, the path is rewritten relative to the output *.tex file. z--stylesheet-path�
stylesheet)rrrz7Link to the stylesheet(s) in the output file. (default)z--link-stylesheet�embed_stylesheet)r rz^Embed the stylesheet(s) in the output file. Stylesheets must be accessible during processing. z--embed-stylesheetz�Comma-separated list of directories where stylesheets are found. Used by --stylesheet-path when expanding relative path arguments. Default: "."z--stylesheet-dirsz<dir[,dir,...]>�.)rrrzlCustomization by LaTeX code in the preamble. Default: select PDF standard fonts (Times, Helvetica, Courier).z--latex-preamblez)Specify the template file. Default: "%s".z
--templatez<file>)rrz&Table of contents by LaTeX. (default) z--use-latex-toc�z6Table of contents by Docutils (without page numbers). z--use-docutils-toc�
use_latex_tocz*Add parts on top of the section hierarchy.z--use-part-sectionz=Attach author and date to the document info table. (default) z--use-docutils-docinfo�use_latex_docinfoz-Attach author and date to the document title.z--use-latex-docinfoz$Typeset abstract as topic. (default)z--topic-abstract�use_latex_abstractz<Use LaTeX abstract environment for the document's abstract. z--use-latex-abstractzOColor of any hyperlinks embedded in text (default: "blue", "false" to disable).z--hyperlink-colorZbluez;Additional options to the "hyperref" package (default: "").z--hyperref-optionsz^Enable compound enumerators for nested enumerated lists (e.g. "1.2.a.ii").  Default: disabled.z--compound-enumeratorszNDisable compound enumerators for nested enumerated lists. This is the default.z--no-compound-enumerators�compound_enumerators)rr z�Enable section ("." subsection ...) prefixes for compound enumerators.  This has no effect without --compound-enumerators.Default: disabled.z --section-prefix-for-enumeratorszHDisable section prefixes for compound enumerators.  This is the default.z#--no-section-prefix-for-enumerators�section_prefix_for_enumeratorszgSet the separator between section number and enumerator for compound enumerated lists.  Default is "-".z--section-enumerator-separator�-z<char>zuWhen possibile, use the specified environment for literal-blocks. Default is quoting of whitespace and special chars.z--literal-block-envzhWhen possibile, use verbatim for literal-blocks. Compatibility alias for "--literal-block-env=verbatim".z--use-verbatim-when-possiblez�Table style. "standard" with horizontal and vertical lines, "booktabs" (LaTeX booktabs style) only horizontal lines above and below the table and below the header or "borderless".  Default: "standard"z
--table-style�append)rrrrrz�LaTeX graphicx package option. Possible values are "dvips", "pdftex". "auto" includes LaTeX code to use "pdftex" if processing with pdf(la)tex and dvips otherwise. Default is no option.z--graphicx-optionz�LaTeX font encoding. Possible values are "", "T1" (default), "OT1", "LGR,T1" or any other combination of options to the `fontenc` package. z--font-encoding�T1z�Per default the latex-writer puts the reference title into hyperreferences. Specify "ref*" or "pageref*" to get the section number or the page number.z--reference-labelzVSpecify style and database for bibtex, for example "--use-bibtex=mystyle,mydb1,mydb2".z--use-bibtex�
sectnum_depthzlatex2e writerr�head_prefix�requirements�latex_preamble�	fallbacks�pdfsetup�title�subtitle�	titledata�body_pre_docinfo�docinfo�
dedication�abstract�bodycCstjj|�t|_dS)N)rr�__init__�LaTeXTranslator�translator_class)�self�rE�/usr/lib/python3.6/__init__.pyrA�szWriter.__init__cCstjj|�tjgS)N)rr�get_transformsr	ZAdmonitions)rDrErErFrG�s
zWriter.get_transformscCs�|j|j�}|jj|�x |jD]}t||t||��q Wyt|jjjd�}Wn0t	k
r~tt
jj|j
|jjj�d�}YnXtjt|j�d��}|j�|j�|j|j�|_dS)N�rbzutf-8)rC�document�	walkabout�visitor_attributes�setattr�getattr�open�settings�template�IOError�os�path�join�default_template_path�stringZTemplate�str�read�close�assemble_partsZ
substitute�parts�output)rDZvisitor�partZ
template_filerPrErErF�	translate�szWriter.translatecCsdtjj|�xR|jD]H}t||�}||jkrL|r:|jd�dj|�|j|<qdj|�|j|<qWdS)z9Assemble the `self.parts` dictionary of output fragments.r%rN)	rrrZrKrM�
head_partsr1rTr[)rDr]�linesrErErFrZs


zWriter.assemble_parts)r
r)rrrrrr)r)	r4r5r6r'r7r8r9r:r;)r<r=r>r?r@)�__name__�
__module__�__qualname__Z	supportedZdefault_templaterRrS�dirname�abspath�__file__rUrTZdefault_preambleZtable_style_valuesrZvalidate_booleanZvalidate_comma_separated_listZ
settings_specZsettings_defaultsZconfig_sectionZconfig_section_dependenciesr_rKr\rArGr^rZrErErErFrs2























rcD@s�eZdZdZdddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d0d3d4d5d6d7d8d9d:d;d<d=d9d:d>d?d@dAdB�CZedCdD�eej��D��ZdEZdFdFdG�Z	dQdIdJ�Z
dKdL�ZdMdN�ZdOdP�Z
dHS)R�BabelzLanguage specifics for LaTeX.Z	afrikaans�arabicZ	bulgarianZbretonZcatalanZczechZwelshZdanishZngermanZgermanZ	naustrianZaustrianZlowersorbian�greekZpolutonikogreek�englishZ
australianZcanadianZbritishZ
newzealandZamericanZ	esperanto�spanish�estonian�basqueZfinnish�frenchZcanadienZirishZibycus�galician�hebrewZcroatianZuppersorbianZmagyarZinterlinguaZbahasaiZ	icelandicZitalianZjapaneseZkazakh�latinZ
lithuanianZlatvianZ	mongolianZbahasamZnorskZdutchZnynorskZpolishZportugesZbrazilZromanianZrussianZsaminZserbiancZserbianZslovakZsloveneZalbanianZswedishZturkishZ	ukrainianZvietnam)CZaf�arZbg�brZcaZcsZcyZdaZdezde-1901zde-ATz
de-AT-1901ZdsbZelz
el-polytonZenzen-AUzen-CAzen-GBzen-NZzen-USZeoZesZetZeu�fi�frzfr-CAZgaz
grc-ibycusZglZheZhrZhsbZhuZia�id�is�itZjaZkkZla�ltZlvZmnZmsZnb�nlZnn�noZpl�ptzpt-BRZroZruZsezsh-Cyrlzsh-LatnZskZslZsq�srzsr-LatnZsv�trZukZvicCsg|]\}}|j�|f�qSrE)�lower)�.0�k�vrErErF�
<listcomp>kszBabel.<listcomp>z,Language "%s" not supported by LaTeX (babel)z.<>)rorkNcCs||_|j|�|_i|_dS)N)�reporter�
language_name�language�otherlanguages)rD�
language_coder�rErErFrA�szBabel.__init__cst�jj��}|j�jpd�ddj|�g�_g}x2dj�fdd�|D��D]}||krN|j|�qNW|r��jjddj|��d|kr��jjd	�d
|kr��jjddd
g�d|krʈjjddd
g�|ddko�dt�jj��k�r�jddd�jg7_dj�j�S)z7Return the babel call with correct options and settingsrjz\usepackage[%s]{babel}�,r%csg|]}�jj|d��qS)r%)�active_chars�get)r��l)rDrErFr��sz"Babel.__call__.<locals>.<listcomp>z#\AtBeginDocument{\shorthandoff{%s}}roz)\deactivatetilden % restore ~ in Galicianrlz
\makeatletterz+  \addto\extrasestonian{\bbl@deactivate{~}}z\makeatotherrmz)  \addto\extrasbasque{\bbl@deactivate{~}}r*rnzE% Prevent side-effects if French hyphenation patterns are not loaded:z\frenchbsetup{StandardLayout}z4\AtBeginDocument{\selectlanguage{%s}\noextrasfrench}r���)	�sortedr��keysr1r�rTZsetup�extend�list)rDrZ
shorthands�crE)rDrF�__call__�s6zBabel.__call__cCsTx2tj|�D]$}y
|j|Stk
r.YqXqW|jdk	rP|jj|j|�dS)z,Return TeX language name for `language_code`Nr%)rZnormalize_language_tag�language_codes�KeyErrorr��warning�warn_msg)rDr��tagrErErFr��s


zBabel.language_namecCs|jS)N)r�)rDrErErF�get_language�szBabel.get_language)N)rarbrc�__doc__r��dictr��itemsr�r�rAr�r�r�rErErErFrgs�
!rgc@s eZdZdZdd�Zdd�ZdS)�SortableDictz�Dictionary with additional sorting methods

    Tip: use key starting with with '_' for sorting before small letters
         and with '~' for sorting after small letters.
    cCst|j��}|j�|S)zReturn sorted list of keys)r�r��sort)rDr�rErErF�
sortedkeys�szSortableDict.sortedkeyscs�fdd��j�D�S)z$Return list of values sorted by keyscsg|]}�|�qSrErE)r��key)rDrErFr��sz-SortableDict.sortedvalues.<locals>.<listcomp>)r�)rDrE)rDrF�sortedvalues�szSortableDict.sortedvaluesN)rarbrcr�r�r�rErErErFr��sr�c@seZdZdZdS)�PreambleCmdsz'Building blocks for the latex preamble.N)rarbrcr�rErErErFr��sr�zQ
% abstract title
\providecommand*{\DUtitleabstract}[1]{\centerline{\textbf{#1}}}a
% admonition (specially marked topic)
\providecommand{\DUadmonition}[2][class-arg]{%
  % try \DUadmonition#1{#2}:
  \ifcsname DUadmonition#1\endcsname%
    \csname DUadmonition#1\endcsname{#2}%
  \else
    \begin{center}
      \fbox{\parbox{0.9\linewidth}{#2}}
    \end{center}
  \fi
}z\usepackage{color}zT
% docinfo (width of docinfo table)
\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}zv
% dedication topic
\providecommand*{\DUCLASSdedication}{%
  \renewenvironment{quote}{\begin{center}}{\end{center}}%
}a�
% class handling for environments (block-level elements)
% \begin{DUclass}{spam} tries \DUCLASSspam and
% \end{DUclass}{spam} tries \endDUCLASSspam
\ifx\DUclass\undefined % poor man's "provideenvironment"
 \newenvironment{DUclass}[1]%
  {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
     \csname \DocutilsClassFunctionName \endcsname}%
  {\csname end\DocutilsClassFunctionName \endcsname}%
\fizU
% error admonition title
\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}z�
% fieldlist environment
\ifthenelse{\isundefined{\DUfieldlist}}{
  \newenvironment{DUfieldlist}%
    {\quote\description}
    {\enddescription\endquote}
}{}zc\usepackage{float} % float configuration
\floatplacement{figure}{H} % place figures here definitelyav% numeric or symbol footnotes with hyperlinks
\providecommand*{\DUfootnotemark}[3]{%
  \raisebox{1em}{\hypertarget{#1}{}}%
  \hyperlink{#2}{\textsuperscript{#3}}%
}
\providecommand{\DUfootnotetext}[4]{%
  \begingroup%
  \renewcommand{\thefootnote}{%
    \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
    \protect\hyperlink{#2}{#3}}%
  \footnotetext{#4}%
  \endgroup%
}zt% Check output format
\ifx\pdftexversion\undefined
  \usepackage{graphicx}
\else
  \usepackage[pdftex]{graphicx}
\fia% basic code highlight:
\providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
\providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
\providecommand*\DUrolekeyword[1]{\textbf{#1}}
\providecommand*\DUrolestring[1]{\textit{#1}}a
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
  % backwards compatibility: try \docutilsrole#1{#2}
  \ifcsname docutilsrole#1\endcsname%
    \csname docutilsrole#1\endcsname{#2}%
  \else
    \csname DUrole#1\endcsname{#2}%
  \fi%
}ze
% legend environment
\ifthenelse{\isundefined{\DUlegend}}{
  \newenvironment{DUlegend}{\small}{}
}{}a�
% lineblock environment
\DUprovidelength{\DUlineblockindent}{2.5em}
\ifthenelse{\isundefined{\DUlineblock}}{
  \newenvironment{DUlineblock}[1]{%
    \list{}{\setlength{\partopsep}{\parskip}
            \addtolength{\partopsep}{\baselineskip}
            \setlength{\topsep}{0pt}
            \setlength{\itemsep}{0.15\baselineskip}
            \setlength{\parsep}{0pt}
            \setlength{\leftmargin}{#1}}
    \raggedright
  }
  {\endlist}
}{}z�
%% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
  \usepackage[%s]{hyperref}
  \usepackage{bookmark}
  \urlstyle{same} %% normal text font (alternatives: tt, rm, sf)
}{}z/%% local table of contents
\usepackage{minitoc}a
% optionlist environment
\providecommand*{\DUoptionlistlabel}[1]{\bf #1 \hfill}
\DUprovidelength{\DUoptionlistindent}{3cm}
\ifthenelse{\isundefined{\DUoptionlist}}{
  \newenvironment{DUoptionlist}{%
    \list{}{\setlength{\labelwidth}{\DUoptionlistindent}
            \setlength{\rightmargin}{1cm}
            \setlength{\leftmargin}{\rightmargin}
            \addtolength{\leftmargin}{\labelwidth}
            \addtolength{\leftmargin}{\labelsep}
            \renewcommand{\makelabel}{\DUoptionlistlabel}}
  }
  {\endlist}
}{}z�
% providelength (provide a length variable and set default, if it is new)
\providecommand*{\DUprovidelength}[2]{
  \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{}
}zp
% rubric (informal heading)
\providecommand*{\DUrubric}[1]{%
  \subsubsection*{\centering\textit{\textmd{#1}}}}z�
% sidebar (text outside the main text flow)
\providecommand{\DUsidebar}[1]{%
  \begin{center}
    \colorbox[gray]{0.80}{\parbox{0.9\linewidth}{#1}}
  \end{center}
}zY
% subtitle (for topic/sidebar)
\providecommand*{\DUsubtitle}[1]{\par\emph{#1}\smallskip}zU
% subtitle (in document title)
\providecommand*{\DUdocumentsubtitle}[1]{{\large #1}}zz\usepackage{longtable,ltcaption,array}
\setlength{\extrarowheight}{2pt}
\newlength{\DUtablewidth} % internal use in tablesz*\usepackage{textcomp} % text symbol macroszn
% text mode subscript
\ifx\textsubscript\undefined
  \usepackage{fixltx2e} % since 2015 loaded by default
\fizN
% titlereference role
\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}a
% title for topics, admonitions, unsupported section levels, and sidebar
\providecommand*{\DUtitle}[2][class-arg]{%
  % call \DUtitle#1{#2} if it exists:
  \ifcsname DUtitle#1\endcsname%
    \csname DUtitle#1\endcsname{#2}%
  \else
    \smallskip\noindent\textbf{#2}\smallskip%
  \fi
}z�
% transition (break, fancybreak, anonymous section)
\providecommand*{\DUtransition}{%
  \hspace*{\fill}\hrulefill\hspace*{\fill}
  \vskip 0.5\baselineskip
}cJ@s�eZdZdZed�ded�ded�diZed�d	ed
�ded�d
ed�ded�ded�ded�ded�ded�ded�dddiZddddd d!d d"d#d$d%d&d'd(d)d*d+d,�Zdd-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dA�ZdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[dQd\d]d^dQd\d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtd@dudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d��IZ	d�d�d�d�d��Z
d�S)��CharMapsz8LaTeX representations for active and Unicode characters.�\z\textbackslash{}�{z\{�}z\}�#z\#�$z\$�%z\%�&z\&�~z\textasciitilde{}�_z\_�^z\textasciicircum{}�"z\textquotedbl{}�[z{[}�]z{]}�z\-z\enskipz\quadz\,z\hspace{0pt}z\hbox{-}z\AAz\ensuremath{\Leftrightarrow}z\ensuremath{\spadesuit}z\ensuremath{\clubsuit}ZffrtZflZffiZffl)i i i i i i i/ i i+!i�!i`&ic&i�i�i�i�i�z\guillemotleft{}z\guillemotright{}z\textcompwordmark{}z
\textendash{}z
\textemdash{}z\textquoteleft{}z\textquoteright{}z\quotesinglbase{}z\textquotedblleft{}z\textquotedblright{}z\quotedblbase{}z\textperthousand{}z\textpertenthousand{}z\guilsinglleft{}z\guilsinglright{}z\textvisiblespace{}z\dag{}z\ddag{}z\dots{}z\texttrademark{})���i i i i i i i i i i0 i1 i9 i: i#$i  i! i& i"!z\textcent{}z\textcurrency{}z
\textyen{}z\textbrokenbar{}z\textsection{}z\textasciidieresis{}z\textcopyright{}z\textordfeminine{}z\textlnot{}z\textregistered{}z\textasciimacron{}z
\textdegree{}z	\textpm{}z\texttwosuperior{}z\textthreesuperior{}z\textasciiacute{}z	\textmu{}z\textparagraph{}z\textonesuperior{}z\textordmasculine{}z\textonequarter{}z\textonehalf{}z\textthreequarters{}z\texttimes{}z
\textdiv{}z
\textflorin{}z\textacutedbl{}z
\textbardbl{}z
\textbullet{}z\textasciigrave{}z\textgravedbl{}z\textreferencemark{}z\textinterrobang{}z\textfractionsolidus{}z
\textlquill{}z
\textrquill{}z\textdiscount{}z\textcolonmonetary{}z\textfrenchfranc{}z\textlira{}z\textnaira{}z
\textwon{}z\textdong{}z\texteuro{}z\textpeso{}z\textguarani{}z\textcelsius{}z
\textnumero{}z\textcircledP{}z
\textrecipe{}z\textservicemark{}z
\textohm{}z
\textmho{}z\textestimated{}z\textleftarrow{}z\textuparrow{}z\textrightarrow{}z\textdownarrow{}z\textminus{}z\textasteriskcentered{}z\textsurd{}z\textblank{}z\textopenbullet{}z\textbigcircle{}z\textmusicalnote{}z\textmarried{}z\textdivorced{}z
\textlangle{}z
\textrangle{})I��������������������������i�i�i�i i" i2 i3 i5 i6 i; i= iD iE iF iR i� i� i� i� i� i� i� i� i� i!i!i!i!i !i"!i&!i'!i.!i�!i�!i�!i�!i"i"i"i"$i�%i�%ij&i�&i�&i�'i�'z
\ding{170}z
\ding{169}z	\ding{51}z	\ding{55})ie&if&i'i'N)rarbrcr��ord�alltt�special�unsupported_unicode�utf8_supported_unicode�textcomp�pifontrErErErFr��sr�c@s"eZdZdZddd�Zdd�ZdS)	�
DocumentClassz"Details of a LaTeX document class.FcCsL||_||_dddddg|_|jdkr4|jjdd�|jrH|jjdd
�dS)N�sectionZ
subsectionZ
subsubsection�	paragraphZsubparagraph�book�memoir�report�scrbook�scrreprtr�chapterr])r�r�r�r�r�)�document_classZ
_with_part�sections�insert)rDr�Z	with_partrErErFrAfs
zDocumentClass.__init__cCs.|t|j�kr|j|dSdtj|�SdS)z�Return the LaTeX section name for section `level`.

        The name depends on the specific document class.
        Level is 1,2,3..., as level 0 is the title.
        r*zDUtitle[section%s]N)�lenr��roman�toRoman)rD�levelrErErFr�qszDocumentClass.sectionN)F)rarbrcr�rAr�rErErErFr�cs
r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6S)7�Tablea�Manage a table while traversing.

    Maybe change to a mixin defining the visit/departs, but then
    class Table internal variables are in the Translator.

    Table style might be

    :standard:   horizontal and vertical lines
    :booktabs:   only horizontal lines (requires "booktabs" LaTeX package)
    :borderless: no borders around table cells
    :nolines:    alias for borderless

    :colwidths-auto:  column widths determined by LaTeX
    :colwidths-given: use colum widths from rST source
    cCs:||_||_d|_i|_g|_g|_g|_d|_d|_dS)NFr)	�_translator�_latex_type�_open�_attrs�
_col_width�_rowspan�stubs�colwidths_auto�	_in_thead)rDZ
translatorZ
latex_typerErErFrA�szTable.__init__cCs"d|_g|_g|_i|_d|_dS)NTF)r��
_col_specs�captionr�Z_in_head)rDrErErFrN�s
z
Table.opencCs(d|_d|_g|_i|_g|_d|_dS)NF)r�r�r�r�r�r�)rDrErErFrY�szTable.closecCs|jS)N)r�)rDrErErF�is_open�sz
Table.is_opencCsbdd�||D�}y|d|_Wntk
r:d|_YnXd|krLd|kpZd|koZd|k|_dS)NcSs g|]}|dkr|jdd��qS)rrrr)rrrr)�replace)r��clsrErErFr��sz)Table.set_table_style.<locals>.<listcomp>r*rzcolwidths-autozcolwidths-givenr�)�borders�
IndexErrorr�)rD�table_style�classesr�rErErF�set_table_style�szTable.set_table_stylecCs|jdkr|jrdS|jS)N�	longtablez
longtable*)r�r�)rDrErErF�get_latex_type�szTable.get_latex_typecCs||j|<dS)N)r�)rD�attr�valuerErErF�set�sz	Table.setcCs||jkr|j|SdS)N)r�)rDr�rErErFr��s

z	Table.getcCs|jdkrdSdS)Nr�|r%)r�)rDrErErF�get_vertical_bar�s
zTable.get_vertical_barcCsNdddd�}|j|jd�pd�}d|j�|fg}|jsD|jdd	�d
j|�S)Nr�r��r)�left�center�right�alignrz\begin{%s}[%s]rz%\setlength{\DUtablewidth}{\linewidth}r)r�r�r�r�rT)rDZ	align_maprZopeningrErErF�get_opening�szTable.get_openingcCs4g}|jdkr|jd�|jd|j��dj|�S)Nrz\bottomrulez\end{%s}r)r�r1r�rT)rD�closingrErErF�get_closing�s


zTable.get_closingcCs$|jj|�|jj|jjd��dS)NZstub)r�r1r��
attributesr�)rD�noderErErF�
visit_colspec�szTable.visit_colspeccCs�|j�}dgt|j�|_g|_|jr@|dt|j�}||Sd}d}x*|jD] }t|dd�|}||7}qPWd}|dkr�||}d	}xJ|jD]@}|t|dd�|}|jj|d
�|d||d
f7}q�W||S)z�Return column specification for longtable.

        Assumes reST line length being 80 characters.
        Table width is hairy.

        === ===
        ABC DEF
        === ===

        usually gets to narrow, therefore we add 1 (fiddlefactor).
        rr��Pg�colwidthr*g�(\���?g�?r%g{�G�zt?z%sp{%.3f\DUtablewidth})r�r�r�r�r�r��floatr1)rDr	ZbarZlatex_table_spec�widthZtotal_widthrZfactorrErErF�get_colspecs�s(zTable.get_colspecscCs*yd|j|jStk
r$dSXdS)z4Return columnwidth for current cell (not multicell).z%.2f\DUtablewidth�*N)r��_cell_in_rowr�)rDrErErF�get_column_widthszTable.get_column_widthcsHy.tdd���fdd�t|�D�D��}d|Stk
rBdSXdS)z)Return sum of columnwidths for multicell.cSsg|]}|�qSrErE)r�rrErErFr�sz/Table.get_multicolumn_width.<locals>.<listcomp>csg|]}�j�|�qSrE)r�)r��co)rD�startrErFr�szp{%.2f\DUtablewidth}r�N)�sum�ranger�)rDrZlen_Zmc_widthrE)rDrrF�get_multicolumn_widthszTable.get_multicolumn_widthcCs4|js
dSdj|j�}d|jj�kr,d|Sd|S)Nr%r*z\caption{%s}\\
z!\caption[]{%s (... continued)}\\
)r�rTr��thead_depth)rDr�rErErF�get_captionszTable.get_captioncCs|jdkrd|jj�kSdS)Nr�r*r)r�r�r)rDrErErF�need_recurses
zTable.need_recursecCs2|jd7_|jdkrdgS|jdkr.dgSgS)Nr*rz\hline
rz	\toprule
)r�r�)rDrErErF�visit_thead"s

zTable.visit_theadcCszg}|jdkr|jd�|jdkrhd|jj�kr<|jd�n,|jd�|jdt|j�d�|jd	�|jd8_|S)
Nrz	\midrule
r�r*z\endfirsthead
z	\endhead
z\multicolumn{%d}{c}z&{\hfill ... continued on next page} \\z
\endfoot
\endlastfoot
)r�r1r�r�rr�r�r�)rD�arErErF�depart_thead*s




zTable.depart_theadcCs
d|_dS)Nr)r)rDrErErF�	visit_row<szTable.visit_rowc
s�dg}d�_x6tt�j��D]$}�j|dkr�j|d8<qW�jdkrЇfdd�tt�j��D�}t|�t�j�kr�|jd�nHd}|j�x0y|j�}WnPYnX|d	||f7}q�W|j|�|S)
Nz \\
rr*rcs"g|]}�j|dkr|d�qS)rr*)r�)r��i)rDrErFr�Gsz$Table.depart_row.<locals>.<listcomp>z\hline
r%z\cline{%d-%d}
)rrr�r�r�r1�reverse�pop)rD�resrZrowspansZclineZc_startrE)rDrF�
depart_row?s&

zTable.depart_rowc	Cs y||j|<WnYnXdS)N)r�)rD�cellr�rErErF�set_rowspanXszTable.set_rowspanc	Csy
|j|SdSdS)Nr)r�)rDr$rErErF�get_rowspan^s
zTable.get_rowspancCs|jS)N)r)rDrErErF�get_entry_numberdszTable.get_entry_numbercCs|jd7_dS)Nr*)r)rDrErErF�visit_entrygszTable.visit_entrycCs t|j�|jkr|j|jSdS)NF)r�r�r)rDrErErF�is_stub_columnjszTable.is_stub_columnN)rarbrcr�rArNrYr�r�r�r�r�r�rrr
rrrrrrrrr#r%r&r'r(r)rErErErFr�|s6

	#
r�c@seZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZdZdZefdd�Zdd�Zd	d
�Zdd�Zd
d�Zejd�fdd�Zdd�Zdd�Z�d�dd�Zdd�Z�d�dd�Zdd�Zd d!�Z d"d#�Z!d$d%�Z"d&d'�Z#d(d)�Z$d*d+�Z%d,d-�Z&d.d/�Z'd0d1�Z(d2d3�Z)d4d5�Z*d6d7�Z+�d�d8d9�Z,d:d;�Z-d<d=�Z.d>d?�Z/d@dA�Z0dBdC�Z1dDdE�Z2dFdG�Z3dHdI�Z4dJdK�Z5dLdM�Z6dNdO�Z7dPdQ�Z8dRdS�Z9dTdU�Z:dVdW�Z;dXdY�Z<dZd[�Z=d\d]�Z>d^d_�Z?d`da�Z@dbdc�ZAddde�ZBdfdg�ZCdhdi�ZDdjdk�ZEdldm�ZFdndo�ZGdpdq�ZHdrds�ZIdtdu�ZJdvdw�ZKdxdy�ZLdzd{�ZMd|d}�ZNd~d�ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgd�d��Zhd�d��Zid�d��Zjd�d��Zkd�d��Zld�d��Zmd�d��Znd�d��Zod�d��Zpd�dÄZqd�dńZrd�dDŽZsd�dɄZtd�d˄Zud�d̈́Zvd�dτZwd�dфZxd�dӄZyd�dՄZzd�dׄZ{d�dلZ|d�dۄZ}d�d݄Z~d�d߄Zd�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z��d�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d�Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d	�Z��d
�d�Z��d�d
�Z��d�d�Z��d�d�Z��d��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d �Z��d!�d"�Z��d#�d$�Z��d%�d&�Z��d'�d(�Z��d)�d*�Z��d+�d,�Z��d-�d.�Z��d/�d0�Z��d1�d2�Z��d3�d4�Z��d5�d6�Z��d7�d8�Z��d9�d:�Z��d;�d<�Z��d=�d>�Z��d?�d@�Z��dA�dB�Z��dC�dD�Z��dE�dF�Z��dG�dH�Z��dI�dJ�Z��dK�dL�Z��dM�dN�Z��dO�dP�Z��dQ�dR�Z��dS�dT�Z��dU�dV�Z��dW�dX�Z��d��d��d��d��d]�Z��d^�d_�Z��d`�da�Z��db�dc�Z��dd�de�Z��df�dg�Z��dh�di�Zdj�dk�ZÐdl�dm�ZĐdn�do�ZŐdp�dq�ZƐdr�ds�Zǐdt�du�ZȐdv�dw�Zɐdx�dy�Zʐdz�d{�Zːd|�d}�Z̐d~�d�Z͐d��d��Zΐd��d��Zϐd��d��ZАd��d��Zѐd��d��Z�dZӐd��d��ZԐd��d��ZՐd��d��Z֐d��d��Zאd��d��Zؐd��d��Zِd��d��Zڐd��d��Zېd��d��Zܐd��d��Zݐd��d��Zސd��d��Zߐd��d��Z�dS(�rBz�
    Generate code for 8-bit LaTeX from a Docutils document tree.

    See the docstring of docutils.writers._html_base.HTMLTranslator for
    notes on and examples of safe subclassing.
    Fr0rcsXtjj�|��jjj�_�jjj�_|j�_}�j	|j
��_|j�_|j
�_
|j�_|j�_|j�_|j�_t|dd��_|j�_|jjdd��_d�_d�_|jdkr�tjd|j�\}�_�_}n|jr�d�_�jjr�jjjdd	��_nd�_t j!|j"|j��_#||j"|j��_$�j#j%d
�_&�jj'g}�j$j(d5k�rL|j)�j$j(�dj*dd
�|D���_'t+|j,|j-��_.�jj/dk�r�d�_0n*�jj/j1�dk�r�t2j3�_0nd�jj/�_0|j4�_4d�j'�jj,fg�_5t6��_7d�j7d<|j8g�_8t6��_9g�_:g�_;g�_<g�_=g�_>g�_?g�_@g�_Ag�_Bg�_Cg�_Dg�_Eg�_Fg�_Gg�_Hg�_Id
g�_Jg�_Kd
�_Lg�_Mg�_NtO�d��_P�jB�_Qg�_R�jdk�r�d�j�j7d<�jS�s�j�r�d�j�j7d<xH�jjd�D]8}|jT�}|dk�r�d�j7d<n|d6k�r�d#�j7d$<�q�W|j,jUd%�d7k�rT�j'jUd&�d8k�sJ�j'jUd'�d9k�rTd(�j7d)<�fd*d
�tVjW|�D��_X�jd:k�r�d�_Ynd.�j�jf�_Y|jY�r��jYd|jY7_Y|jZ�r�d/t2_[n�|j\}|dk	�rt]|t^�j.j_��}d0�j.j_k�r�|d	8}�j.j_d
d1k�r|d	8}d2|t2_[t`|d3��rT|jad	k�rTd4�j.j_d
|jad	f�j7d3<dS);N�
font_encodingr%r�z\_r�z	(\w+)(.*)�verbatimr�r*rrjcSsg|]}|r|�qSrErE)r�Z_frErErFr��sz,LaTeXTranslator.__init__.<locals>.<listcomp>z\usepackage{graphicx}�autoz\usepackage[%s]{graphicx}z\documentclass[%s]{%s}z\usepackage{ifthen}Z__staticr��asciiz\usepackage[%s]{inputenc}�	_inputencz\usepackage[%s]{fontenc}Z_fontenc�OT1z+\DeclareTextSymbol{\textquotedbl}{OT1}{`\"}Z_textquotedblOT1r2�T2A�T2B�T2C�T4�T5z,\DeclareTextSymbolDefault{\textquotedbl}{T1}Z
_textquotedblZscrZDIVZBCORz\usepackage{typearea}Ztypeareacsg|]}�j|��qSrE)�stylesheet_call)r�rS)rDrErFr�@s�0�false�Falsez(colorlinks=true,linkcolor=%s,urlcolor=%sz\setcounter{secnumdepth}{0}r�r]z\setcounter{secnumdepth}{%d}�
sectnum_startz\setcounter{%s}{%d})rjr%)r2r0r1r2r3r4r�r�r�)r6r7r8r%)br�NodeVisitorrArIr�r��warn�errorrO�to_latex_encodingZoutput_encoding�latex_encodingr+r,r�_use_latex_citationsZreference_label�_reference_labelZhyperlink_colorr.rMr*r/�section_enumerator_separatorr��literal_block_env�literal_block_options�re�splitZuse_verbatim_when_possibleZ
use_bibtex�bibtexrr�r��language_module�babelZauthor_separators�author_separatorZdocumentoptionsr�r1rTr�Z
documentclassZuse_part_section�d_classZgraphicx_option�graphicx_packagerr��
graphicx_auto�docutils_footnotesr4r�r5r6r7r8r9r:r;r<r=r>r?r@�context�title_labels�subtitle_labels�author_stack�date�pdfinfo�	pdfauthor�_section_number�_enumeration_countersZ_max_enumeration_counters�	_bibitems�table_stackr��active_table�out�	out_stack�is_xetex�strip�findrZget_stylesheet_listr'�hyperref_optionsZ
sectnum_xform�secnumdepthr3�minr�r��hasattrr9)rDrIZbabel_classrOr$Z	d_options�encr`rE)rDrFrA�s�














zLaTeXTranslator.__init__c	Cs�tjj|�\}}|dk}|jjr�|r,|d}y$tj|dd�j�}|jjj	|�WnLt
k
r�}z0d|t|j�f}|j
jj|�d|jdd�Sd	}~XnX|r�djd
|dg�}d||fS|r�|}d
}nd}|jjr�tj|jj|�}||S)z8Return code to reference or embed stylesheet file `path`�.styr%zutf-8)�source_path�encodingz#Cannot embed stylesheet '%s':
  %s.z% rz
% Nz
\makeatletterz\makeatotherz%% embedded stylesheet: %s
%sz\usepackage{%s}z
\input{%s})rdr%)rRrS�splitextrOr(rZ	FileInputrXZrecord_dependencies�addrQr�strerrorrIr�r<r�rTr&rZ
relative_pathZ_destination)	rDrS�baseZext�
is_package�content�err�msg�cmdrErErFr5{s4zLaTeXTranslator.stylesheet_callcCs\ddddddddd	d
ddd
dd�}|j�}||kr:||S|jdd�jdd�}|jd�dS)z�Translate docutils encoding name into LaTeX's.

        Default method is remove "-" and "_" chars from docutils_encoding.
        �latin1�latin2�latin3�latin4Ziso88595�latin5�latin9Zmaccyr�cp1251zkoi8-rzkoi8-u�cp1250�cp1252r-)z
iso-8859-1z
iso-8859-2z
iso-8859-3z
iso-8859-4z
iso-8859-5z
iso-8859-9ziso-8859-15�mac_cyrilliczwindows-1251zkoi8-rzkoi8-uzwindows-1250zwindows-1252zus-asciir�r%r0�:r)rr�rE)rDZdocutils_encodingr~rfrErErFr=�s&z!LaTeXTranslator.to_latex_encodingcCs|jj|S)N)rG�labels)rDZ
docutil_labelrErErF�language_label�szLaTeXTranslator.language_labelc
Cs4|jr
|Stjj�}|js&|jtj�|jr6|td�=|jd kr�|j	r�|j
rtd|td�<|j|jd<d|td�<n$d|td	�<d
|td�<d|td
�<|j
r�d|td�<|j	�sj|jjd�s�|jtj�|jtj�|jtj�|jtj�xz|D]r}t|�}|tjk�rtj|jd<q�|tjk�r2d|jd<q�|jdkr�|tjkr�d|tj|f|jdt|�<q�W|j|�}|j	�s�d}|j
�r�|d7}x*|dD]}|j|||d|�}�q�W|j�r|jd�}x8t|dd!��D]$\}}	|	j��s�||d7<�q�Wd"j|�}|j
�r0|j
�r0|jdd�}|S)#aUReturn text with 'problematic' characters escaped.

        * Escape the special printing characters ``# $ % & ~ _ ^ \ { }``,
          square brackets ``[ ]``, double quotes and (in OT1) ``< | >``.
        * Translate non-supported Unicode characters.
        * Separate ``-`` (and more in literal text) to prevent input ligatures.
        r�r/r%z
\underline{~}�graphicxz\reflectbox{/}r�z
\textbar{}r�z\textless{}�<z\textgreater{}�>r�� �utf8r�z\usepackage{pifont}r�z"\DeclareUnicodeCharacter{%04X}{%s}r.r0z,`'"<>�z{}rNr*z\\z  z ~)r/r%r�z\\
)r+r�r��copy�updater��inside_citation_reference_labelr�r*r\�literalrKr5�insert_non_breaking_blanksr>�
startswithr�r�r�r�r�rWr^r��insert_newlinerE�	enumerate�lstriprT)
rD�text�table�chZcpZseparate_chars�charr`r�linerErErF�encode�sb




"



zLaTeXTranslator.encodez[

	]cCs|j|jd|��S)z1Cleanse, encode, and return attribute value text.r�)r��sub)rDr�Z
whitespacerErErF�attvalszLaTeXTranslator.attvalcCst|jtj�S)z@Check whether a node represents an inline or block-level element)�
isinstance�parentrZTextElement)rDr	rErErF�	is_inline(szLaTeXTranslator.is_inlinecCs$|jjdjdd�|dD���dS)z)Append hypertargets for all ids of `node`z%
cSsg|]}d|�qS)z"\raisebox{1em}{\hypertarget{%s}{}}rE)r�rvrErErFr�0sz7LaTeXTranslator.append_hypertargets.<locals>.<listcomp>�idsN)rZr1rT)rDr	rErErF�append_hypertargets,sz#LaTeXTranslator.append_hypertargetsTcCs.dd�|jdg�D�}|r*|r*|jdd�|S)z�Return list of label definitions for all ids of `node`

        If `set_anchor` is True, an anchor is set with \phantomsection.
        cSsg|]}d|�qS)z
\label{%s}rE)r�rvrErErFr�8sz1LaTeXTranslator.ids_to_labels.<locals>.<listcomp>r�rz\phantomsection)r�r�)rDr	�
set_anchorr{rErErF�
ids_to_labels3szLaTeXTranslator.ids_to_labelscCsDdd�|dD�}|r@|d
jdd�|d<dd�|dD�|d<d	S)z8Convert ``align-*`` class arguments into alignment args.cSsg|]}|jd�r|�qS)zalign-)r�)r�r�rErErFr�@sz:LaTeXTranslator.set_align_from_classes.<locals>.<listcomp>r�r*zalign-r%rcSsg|]}|jd�s|�qS)zalign-)r�)r�r�rErErFr�CsNr�)r�)rDr	rrErErF�set_align_from_classes=sz&LaTeXTranslator.set_align_from_classesNcCsP|jd|�}|dkr"|jjd�n*|dkr8|jjd�n|dkrL|jjd�dS)Nrrz
\raggedright
rz\centering
rz\raggedleft
)r�rZr1)rDr	rrrErErF�insert_align_declarationFsz(LaTeXTranslator.insert_align_declarationcCs�t|jtj�s|jjd�xl|dD]`}|jd�rh|jj|dd��}|r�d|jj	|<|jjd|�q$t
j|jd<|jjd	|�q$WdS)
z6Open a group and insert declarations for class values.rr�z	language-�	NTz\begin{selectlanguage}{%s}
�DUclassz\begin{DUclass}{%s}
)
r�r�r�compoundrZr1r�rHr�r�r��duclassr7)rDr	r�r�rErErF�duclass_openOs
zLaTeXTranslator.duclass_opencCsnxht|d�D]X}|jd�rN|jj|dd��}|rfd|jj|<|jjd�qtj|j	d<|jjd�qWdS)	z$Close a group of class declarations.r�z	language-r�NTz\end{selectlanguage}
r�z\end{DUclass}
)
�reversedr�rHr�r�rZr1r�r�r7)rDr	r�r�rErErF�
duclass_close]s
zLaTeXTranslator.duclass_closecCs|jj|j�||_dS)N)r[r1rZ)rDZnew_outrErErF�push_output_collectorisz%LaTeXTranslator.push_output_collectorcCs|jj�|_dS)N)r[r!rZ)rDrErErF�pop_output_collectormsz$LaTeXTranslator.pop_output_collectorcCs|jj|j|j���dS)N)rZr1r��astext)rDr	rErErF�
visit_TextsszLaTeXTranslator.visit_TextcCsdS)NrE)rDr	rErErF�depart_TextvszLaTeXTranslator.depart_TextcCs|djdd�|j|�dS)Nr�rZabbreviation)r��visit_inline)rDr	rErErF�visit_abbreviationysz"LaTeXTranslator.visit_abbreviationcCs|j|�dS)N)�
depart_inline)rDr	rErErF�depart_abbreviation}sz#LaTeXTranslator.depart_abbreviationcCs|djdd�|j|�dS)Nr�rZacronym)r�r�)rDr	rErErF�
visit_acronym�szLaTeXTranslator.visit_acronymcCs|j|�dS)N)r�)rDr	rErErF�depart_acronym�szLaTeXTranslator.depart_acronymcCs|j|d�dS)N�address)�visit_docinfo_item)rDr	rErErF�
visit_address�szLaTeXTranslator.visit_addresscCs|j|�dS)N)�depart_docinfo_item)rDr	rErErF�depart_address�szLaTeXTranslator.depart_addresscCsXtj|jd<d|dkr$tj|jd<dd�|dD�|d<|jjddj|d��dS)N�
admonitionr<r�cSsg|]}|dkr|�qS)r�rE)r�r�rErErFr��sz4LaTeXTranslator.visit_admonition.<locals>.<listcomp>z
\DUadmonition[%s]{r�)r�r�r7r<rZr1rT)rDr	rErErF�visit_admonition�s
z LaTeXTranslator.visit_admonitioncCs|jjd�dS)Nz}
)rZr1)rDr	rErErF�depart_admonition�sz!LaTeXTranslator.depart_admonitioncCs|j|d�dS)N�author)r�)rDr	rErErF�visit_author�szLaTeXTranslator.visit_authorcCs|j|�dS)N)r�)rDr	rErErF�
depart_author�szLaTeXTranslator.depart_authorcCsdS)NrE)rDr	rErErF�
visit_authors�szLaTeXTranslator.visit_authorscCsdS)NrE)rDr	rErErF�depart_authors�szLaTeXTranslator.depart_authorscCs|j|�|jjd�dS)Nz
\begin{quote})r�rZr1)rDr	rErErF�visit_block_quote�s
z!LaTeXTranslator.visit_block_quotecCs|jjd�|j|�dS)Nz\end{quote}
)rZr1r�)rDr	rErErF�depart_block_quote�sz"LaTeXTranslator.depart_block_quotecCs.|j|�|jr|jjd�n|jjd�dS)Nz\begin{list}{}{}z\begin{itemize})r��is_toc_listrZr1)rDr	rErErF�visit_bullet_list�s
z!LaTeXTranslator.visit_bullet_listcCs.|jr|jjd�n|jjd�|j|�dS)Nz\end{list}
z\end{itemize}
)r�rZr1r�)rDr	rErErF�depart_bullet_list�sz"LaTeXTranslator.depart_bullet_listcCs"|jjd�|dr|j|�dS)Nz\textsuperscript{r�)rZr1r�)rDr	rErErF�visit_superscript�sz!LaTeXTranslator.visit_superscriptcCs"|dr|j|�|jjd�dS)Nr�r�)r�rZr1)rDr	rErErF�depart_superscript�s
z"LaTeXTranslator.depart_superscriptcCs.tj|jd<|jjd�|dr*|j|�dS)N�
textsubscriptz\textsubscript{r�)r�r�r7rZr1r�)rDr	rErErF�visit_subscript�szLaTeXTranslator.visit_subscriptcCs"|dr|j|�|jjd�dS)Nr�r�)r�rZr1)rDr	rErErF�depart_subscript�s
z LaTeXTranslator.depart_subscriptcCs|jjd�dS)Nz

\caption{)rZr1)rDr	rErErF�
visit_caption�szLaTeXTranslator.visit_captioncCs|jjd�dS)Nz}
)rZr1)rDr	rErErF�depart_caption�szLaTeXTranslator.depart_captioncCs.tj|jd<|jjd�|dr*|j|�dS)N�titlereferencez\DUroletitlereference{r�)r�r�r7rZr1r�)rDr	rErErF�visit_title_reference�sz%LaTeXTranslator.visit_title_referencecCs"|dr|j|�|jjd�dS)Nr�r�)r�rZr1)rDr	rErErF�depart_title_reference�s
z&LaTeXTranslator.depart_title_referencecCs,|jr|jg�n|jjd�|j|�dS)Nz\begin{figure}[b])r?r�rZr1r�)rDr	rErErF�visit_citation�szLaTeXTranslator.visit_citationcCsN|jr>|jd}dj|jdd��}|jj||g�|j�n|jjd�dS)Nrr%r*z
\end{figure}
)r?rZrTrWr1r�)rDr	�labelr�rErErF�depart_citation�s

zLaTeXTranslator.depart_citationcCs�|jr@|js |jjd�d|_q~|jd
dks6td��|jd=n>d}d|krV|d}nd|krn|jj|d}|jjd	|�dS)
Nz\cite{r*r�rz2unexpected non-whitespace while in reference labelr%�refid�refnamez\hyperlink{%s}{[r�)r�rr�)r?r�rZr1r@�AssertionErrorrI�nameids)rDr	�hrefrErErF�visit_citation_reference�s

z(LaTeXTranslator.visit_citation_referencecCs�|jr�d}|jdddd�}t|�dkrZ|d}t|tj�rZ|j�dkrZ|dj|jkrZd}|rl|jj	d�q�|jj	d	�d|_
n|jj	d
�dS)NFT)ZdescendZsiblingsZinclude_selfr*rr�rr�r�z]})r�r)r?Ztraverser�r�r�Textr��	__class__rZr1r�)rDr	Zfollowup_citationZ
next_siblings�nextrErErF�depart_citation_referencesz)LaTeXTranslator.depart_citation_referencecCs|jjd�dS)Nz	(\textbf{)rZr1)rDr	rErErF�visit_classifiersz LaTeXTranslator.visit_classifiercCs|jjd�dS)Nz}))rZr1)rDr	rErErF�depart_classifiersz!LaTeXTranslator.depart_classifiercCs|jj|�dS)N)rYr
)rDr	rErErFr
 szLaTeXTranslator.visit_colspeccCsdS)NrE)rDr	rErErF�depart_colspec#szLaTeXTranslator.depart_colspeccCs@t|jtj�s|jjd�|jjd|j�jdd��tj�dS)Nrz%% %s
z
% )	r�r�rr�rZr1r�r��SkipNode)rDr	rErErF�
visit_comment&szLaTeXTranslator.visit_commentcCsdS)NrE)rDr	rErErF�depart_comment-szLaTeXTranslator.depart_commentcCs8t|jtj�r|jjd�|djdd�|j|�dS)Nrr�rr�)r�r�rr�rZr1r�r�)rDr	rErErF�visit_compound0szLaTeXTranslator.visit_compoundcCs|j|�dS)N)r�)rDr	rErErF�depart_compound6szLaTeXTranslator.depart_compoundcCs|j|d�dS)N�contact)r�)rDr	rErErF�
visit_contact9szLaTeXTranslator.visit_contactcCs|j|�dS)N)r�)rDr	rErErF�depart_contact<szLaTeXTranslator.depart_contactcCs|j|�dS)N)r�)rDr	rErErF�visit_container?szLaTeXTranslator.visit_containercCs|j|�dS)N)r�)rDr	rErErF�depart_containerBsz LaTeXTranslator.depart_containercCs|j|d�dS)N�	copyright)r�)rDr	rErErF�visit_copyrightEszLaTeXTranslator.visit_copyrightcCs|j|�dS)N)r�)rDr	rErErF�depart_copyrightHsz LaTeXTranslator.depart_copyrightcCs|j|d�dS)NrR)r�)rDr	rErErF�
visit_dateKszLaTeXTranslator.visit_datecCs|j|�dS)N)r�)rDr	rErErF�depart_dateNszLaTeXTranslator.depart_datecCsdS)NrE)rDr	rErErF�visit_decorationQsz LaTeXTranslator.visit_decorationcCsdS)NrE)rDr	rErErF�depart_decorationUsz!LaTeXTranslator.depart_decorationcCsdS)NrE)rDr	rErErF�visit_definitionXsz LaTeXTranslator.visit_definitioncCs|jjd�dS)Nr)rZr1)rDr	rErErF�depart_definition[sz!LaTeXTranslator.depart_definitioncCs|j|�|jjd�dS)Nz\begin{description}
)r�rZr1)rDr	rErErF�visit_definition_list^s
z%LaTeXTranslator.visit_definition_listcCs|jjd�|j|�dS)Nz\end{description}
)rZr1r�)rDr	rErErF�depart_definition_listbsz&LaTeXTranslator.depart_definition_listcCsdS)NrE)rDr	rErErF�visit_definition_list_itemfsz*LaTeXTranslator.visit_definition_list_itemcCsdS)NrE)rDr	rErErF�depart_definition_list_itemisz+LaTeXTranslator.depart_definition_list_itemcCs|jjd�dS)Nr�)rZr1)rDr	rErErF�visit_descriptionlsz!LaTeXTranslator.visit_descriptioncCsdS)NrE)rDr	rErErF�depart_descriptionosz"LaTeXTranslator.depart_descriptioncCs|j|j�dS)N)r�r=)rDr	rErErF�
visit_docinforszLaTeXTranslator.visit_docinfocCsN|j�|jrJd|jd<tj|jd<tj|jd<|jjdd�|jjd�dS)Nz\usepackage{tabularx}Ztabularx�_providelengthr=rz@
% Docinfo
\begin{center}
\begin{tabularx}{\DUdocinfowidth}{lX}
z\end{tabularx}
\end{center}
)r�r=r5r��
providelengthr7r�r1)rDr	rErErF�depart_docinfous
zLaTeXTranslator.depart_docinfocCs|dkr|jj|j|j���|jr�|d
kr�|dks<|jrH|jjg�|dkrld|_|j|j��}d|_n|j|j��}|jdj|�tj	�n$|dkr�|j
j|j|j���tj	�|jjd	|j|��|dkr�d|_|jjd
�|j
jd�n|j
jd�dS)Nr��organizationr�r�TFr*rRz\textbf{%s}: &
	z{\raggedright
z } \\
z \\
)r�r�r�r�r�)rTr1r�r�r,rQr�r�rr�rRrZr|rN)rDr	�namer�rErErFr��s,z"LaTeXTranslator.visit_docinfo_itemcCs|jj|jj��d|_dS)NF)rZr1rNr!r�)rDr	rErErFr��sz#LaTeXTranslator.depart_docinfo_itemcCs|j|�dS)N)�visit_literal_block)rDr	rErErF�visit_doctest_block�sz#LaTeXTranslator.visit_doctest_blockcCs|j|�dS)N)�depart_literal_block)rDr	rErErF�depart_doctest_block�sz$LaTeXTranslator.depart_doctest_blockcCs:|jst|�r6t|dtj�r6|j|j|dd�7_dS)NrF)r�)r,r�r�rr9rOr�)rDr	rErErF�visit_document�szLaTeXTranslator.visit_documentcCsl|jjs|jjdkr"|j�|jd<|jj�|_|jj�|_|jjtj	|j
�|jrr|jj
|j�}|jjd|�|jr�|jdg|jdg7_|js�|jo�|js�|j�rh|jjd�|jr�|jjdd	�dj
|j�g|j}|j�r|d
ddj
|j�g|j7}|jjdd
j
|��dd�|jD�}|jjddj
|��|jjddj
|j��|jjd�|j�rFt|j�dk�rF|j�sd}x.|jD]$}t|�t|d�k�r�|d}�q�W|jjd|�x>|jD]4}|djdd�}|jjd|d||df��q�W|jjd�n,|jjd|jd�|jjd|jd�d|jk�rh|j�rh|jjd�dS) Nr%rjrHz  pdfauthor={%s}z\hypersetup{r�z%%% Title Datarz\phantomsection%
  z
\\ % subtitlez\DUdocumentsubtitle{%s}z
\title{%s}z%
  cSsg|]}dj|��qS)z\\
)rT)r�Zauthor_entryrErErFr��sz3LaTeXTranslator.depart_document.<locals>.<listcomp>z\author{%s}z \and
z	\date{%s}z, z\maketitle
z
\begin{thebibliography}{%s}
z\_r�z\bibitem[%s]{%s}{%s}
r*z\end{thebibliography}
z
\bibliographystyle{%s}
z\bibliography{%s}
�minitocz'
\faketableofcontents % for local ToCs
)r%rj) rHr�r�r5r�r7r8r1r��linkingr_rTrIrTrSr9r,rQrRr;r�rOr:rPr<r?r�rWrFrZr��
has_latex_toc)rDr	Zauthorsr9Zwidest_labelZbiZcite_keyrErErF�depart_document�s\

zLaTeXTranslator.depart_documentcCs"|jjd�|dr|j|�dS)Nz\emph{r�)rZr1r�)rDr	rErErF�visit_emphasis�szLaTeXTranslator.visit_emphasiscCs"|dr|j|�|jjd�dS)Nr�r�)r�rZr1)rDr	rErErF�depart_emphasis�s
zLaTeXTranslator.depart_emphasiscCs2x,|jj|jj��r,|jjd�|jj�qWdS)Nz & )rYr&r'rZr1r()rDrErErF�(insert_additional_table_colum_delimiterssz8LaTeXTranslator.insert_additional_table_colum_delimiterscCs�|jj�dkr|j�n|jjd�d|kr<d|kr<td��d|kr�d|jd<|dd}|jj|jj�|�|jjd	||jj�f�|j	jd
�n|d|k�r|jj�dkr�|jj
�}nd}|dd}|jjd|||jj|jj�|�|jj
�f�|j	jd
�n|j	jd�t|��rTt
|jjtj��s:|jj��rT|jjd
�|j	jd
�n|j	jd�|jj�r�|jdjd��r�|jjd�|jj�dS)Nrz & ZmorerowsZmorecolszKCells that span multiple rows *and* columns currently not supported, sorry.z\usepackage{multirow}Zmultirowr*z\multirow{%d}{%s}{r�r%z\multicolumn{%d}{%s%s%s}{z\textbf{r�r�r�)rYr'rrZr1�NotImplementedErrorr5r%rrNr�rr�r�r�rZtheadr)r��endswithr()rDr	ZmrowsZbar1ZmcolsrErErFr(sD


zLaTeXTranslator.visit_entrycCs0|jj|jj��|jj|jj��|j�dS)N)rZr1rNr!r)rDr	rErErF�depart_entry>szLaTeXTranslator.depart_entrycCs|jj�dS)N)rYr)rDr	rErErFrDszLaTeXTranslator.visit_rowcCs|jj|jj��dS)N)rZr�rYr#)rDr	rErErFr#GszLaTeXTranslator.depart_rowc
Cs�ddddddd�}ddddg}d}|jrv|jrb|jrb|jrbdjdd�|jd|j�D��|j}|jrv||jd 7}||jdd�7}||jd�}|jdd�}t|j�d
}dt	j
|�j�}d||||f}	|jj|	�|j
|�|dk�r*|jjd�|||f||d
k�rd|jjd||	f�n:d||j|<|jjd�|jjd|	�|jjd|�d|k�r�|jjd||dd
f�dS)!Nr%rh�alph�Alphr�ZRoman)r%rhZ
loweralphaZ
upperalphaZ
lowerromanZ
upperromanr)�(�)cSsg|]}t|��qSrE)rW)r��nrErErFr�\sz9LaTeXTranslator.visit_enumerated_list.<locals>.<listcomp>r*�prefix�enumtype�suffix�enumz%s\%s{%s}%s�z\begin{enumerate}z
\renewcommand{\label%s}{%s}z\newcounter{%s}z\begin{list}z{%s}z{\usecounter{%s}}rz
\setcounter{%s}{%d})r%rhr))rr	r)r%r�r))r%r
r)r�)r.r/�
section_levelrVrTrUrAr�r�r�r�rr1r�rZr7)
rDr	�typesr{rrrZenumeration_levelZcounter_namer�rErErF�visit_enumerated_listJsP



z%LaTeXTranslator.visit_enumerated_listcCs@t|j�dkr|jjd�n|jjd�|j|�|jj�dS)Nrz\end{enumerate}
z\end{list}
)r�rVrZr1r�r!)rDr	rErErF�depart_enumerated_list}s

z&LaTeXTranslator.depart_enumerated_listcCsdS)NrE)rDr	rErErF�visit_field�szLaTeXTranslator.visit_fieldcCsdS)NrE)rDr	rErErF�depart_field�szLaTeXTranslator.depart_fieldcCs|jjd�dS)Nz%[visit_field_argument]
)rZr1)rDr	rErErF�visit_field_argument�sz$LaTeXTranslator.visit_field_argumentcCs|jjd�dS)Nz%[depart_field_argument]
)rZr1)rDr	rErErF�depart_field_argument�sz%LaTeXTranslator.depart_field_argumentcCsdS)NrE)rDr	rErErF�visit_field_body�sz LaTeXTranslator.visit_field_bodycCs|j|jkr|jjd�dS)Nz\\rz\\
)rZr=r1)rDr	rErErF�depart_field_body�sz!LaTeXTranslator.depart_field_bodycCs2|j|�|j|jk	r.tj|jd<|jjd�dS)N�	fieldlistz\begin{DUfieldlist})r�rZr=r�rr7r1)rDr	rErErF�visit_field_list�s
z LaTeXTranslator.visit_field_listcCs&|j|jk	r|jjd�|j|�dS)Nz\end{DUfieldlist}
)rZr=r1r�)rDr	rErErF�depart_field_list�sz!LaTeXTranslator.depart_field_listcCs*|j|jkr|jjd�n|jjd�dS)Nz\textbf{z
\item[{)rZr=r1)rDr	rErErF�visit_field_name�sz LaTeXTranslator.visit_field_namecCs*|j|jkr|jjd�n|jjd�dS)Nz}: &z:}])rZr=r1)rDr	rErErF�depart_field_name�sz!LaTeXTranslator.depart_field_namecCsrtj|jd<|j|�|jjdd�}|dkr>|jjd|�n|jjd�|jd�rn|j|j|�dg7_dS)N�float_settingsrrz\begin{figure} %% align = "%s"
z\begin{figure}
r�r)	r�r"r5r�rr�rZr1r�)rDr	Z	alignmentrErErF�visit_figure�s

zLaTeXTranslator.visit_figurecCs|jjd�|j|�dS)Nz
\end{figure}
)rZr1r�)rDr	rErErF�
depart_figure�szLaTeXTranslator.depart_figurecCs|jg�|jjd�dS)Nz\newcommand{\DUfooter}{)r�rZr1)rDr	rErErF�visit_footer�s
zLaTeXTranslator.visit_footercCs*|jjd�dj|j�|jd<|j�dS)Nr�r%z~footer)rZr1rTr5r�)rDr	rErErF�
depart_footer�szLaTeXTranslator.depart_footercCs�y|dd}Wn tk
r0|dd}YnX|jr�tj|jd<|dj�}|jjdkrdd|}|jj	d|dd||j
|�f�|d|dkr�|j|j|�7_|d	d�r�t|d	t
j�r�|jj	d
�dS)N�backrefsrr��	footnotesrz[%s]z%%
\DUfootnotetext{%s}{%s}{%s}{�namesr*r�)r�rMr�r(r7r�rO�footnote_referencesrZr1r�r�r�rr�)rDr	ZbackrefZnumrErErF�visit_footnote�szLaTeXTranslator.visit_footnotecCs|jjd�dS)Nz}
)rZr1)rDr	rErErF�depart_footnote�szLaTeXTranslator.depart_footnotecCs�d}d|kr|d}nd|kr.|jj|d}|jj}|dkrf|j|�|jjd|�|jjd�n4tj	|j
d<|jjd|d	d
|f�|jjd�dS)Nr%r�r�rz\hyperlink{%s}{[z]}r(z\DUfootnotemark{%s}{%s}{r�rr�)rIr�rOr*r�rZr1rNr�r(r7)rDr	r��formatrErErF�visit_footnote_reference�s

z(LaTeXTranslator.visit_footnote_referencecCs|jj|jj��dS)N)rZr1rNr!)rDr	rErErF�depart_footnote_reference	sz)LaTeXTranslator.depart_footnote_referencecCs>t|jtj�rtj�n$t|jtj�s(t�|js:|jj	|�dS)N)
r�r�rZfootnoter�Zcitationr�r?rZr1)rDr	ZbracketrrErErF�label_delim	s
zLaTeXTranslator.label_delimcCs|j|dd�dS)z9footnote or citation label: in brackets or as superscriptr�z\textsuperscript{N)r0)rDr	rErErF�visit_label
	szLaTeXTranslator.visit_labelcCs|j|dd�dS)Nr�r�)r0)rDr	rErErF�depart_label	szLaTeXTranslator.depart_labelcCsdS)NrE)rDr	rErErF�visit_generated	szLaTeXTranslator.visit_generatedcCsdS)NrE)rDr	rErErF�depart_generated	sz LaTeXTranslator.depart_generatedcCs|jg�|jjd�dS)Nz\newcommand{\DUheader}{)r�rZr1)rDr	rErErF�visit_header	s
zLaTeXTranslator.visit_headercCs*|jjd�dj|j�|jd<|j�dS)Nr�r%z~header)rZr1rTr5r�)rDr	rErErF�
depart_header	szLaTeXTranslator.depart_headercCs�|dk	rtjjd�tjd|�}|s(|S|j�dd�\}}|dkrNd|}nF|dkrhd	t|�d
}n,|jr�|dkr�tj	|j
d<d
|j
d<d|}|S)z=Convert `length_str` with rst lenght to LaTeX length
        NzWdeprecation warning: LaTeXTranslator.to_latex_length() option `pxunit` will be removed.z(\d*\.?\d*)\s*(\S*)r�r%r|z%sbpr�z%.3f\linewidthgY@Zpxr�z$
\DUprovidelength{\pdfpxdimen}{1bp}
z
%s\pdfpxdimen)r%r|)�sys�stderr�writerD�match�groupsr
r\r�r�r7)rDZ
length_strZpxunitr:r�ZunitrErErF�to_latex_length$	s

zLaTeXTranslator.to_latex_lengthc

Cs�|j|jd<|j}tjj|d�jdd�}d|krRt|jt	j
�rHd|d<|j|�g}g}g}dddd d!d"d�}d|kr�y,||d}|j|d�|j|d�Wnt
k
r�YnXd|kr�|jd|j|d��d|k�r�|jd|dd�d|k�r|jd|j|d��|j|��p:t|jt	j
t	jf��sH|jd�|j|��p`t|jt	j
��sn|jd�|j�|jj|�d}	|�r�ddj|�}	|jjd|	|f�|jj|�dS)#Nr}Zurir��/rrr%�\raisebox{-0.5\height}{r��\raisebox{-\height}{�!\noindent\makebox[\linewidth][c]{�
\noindent{�\hfill}�\noindent{\hfill)ZbottomZmiddle�toprrrrr*Zheightz	height=%sZscalezscale=%fgY@rzwidth=%srz[%s]r�z\includegraphics%s{%s})r%r%)r>r�)r?r�)r@r�)rArB)rCr�)rKr5r�urllibZrequestZurl2pathnamer�r�r�rZfigurer�r1r�r<r�r�r rZr�rT)
rDr	ZattrsZ	imagepathZpreZpostZinclude_graphics_optionsZalign_codesZ
align_codeZoptionsrErErF�visit_image=	sZ




zLaTeXTranslator.visit_imagecCs(|jd�r$|j|j|�dg7_dS)Nr�r)r�rZr�)rDr	rErErF�depart_imaget	s
zLaTeXTranslator.depart_imagecCsrxl|dD]`}|jd�rN|jj|dd��}|rjd|jj|<|jjd|�q
tj|jd<|jjd|�q
WdS)Nr�z	language-r�Tz\foreignlanguage{%s}{�inlinez\DUrole{%s}{)	r�rHr�r�rZr1r�rHr7)rDr	r�r�rErErFr�x	s
zLaTeXTranslator.visit_inlinecCs|jjdt|d��dS)Nr�r�)rZr1r�)rDr	rErErFr��	szLaTeXTranslator.depart_inlinecCs|j|�dS)N)�
visit_literal)rDr	rErErF�visit_interpreted�	sz!LaTeXTranslator.visit_interpretedcCs|j|�dS)N)�depart_literal)rDr	rErErF�depart_interpreted�	sz"LaTeXTranslator.depart_interpretedcCstj|jd<|jjd�dS)N�legendz\begin{DUlegend})r�rMr7rZr1)rDr	rErErF�visit_legend�	szLaTeXTranslator.visit_legendcCs|jjd�dS)Nz\end{DUlegend}
)rZr1)rDr	rErErF�
depart_legend�	szLaTeXTranslator.depart_legendcCs|jjd�dS)Nz\item[] )rZr1)rDr	rErErF�
visit_line�	szLaTeXTranslator.visit_linecCs|jjd�dS)Nr)rZr1)rDr	rErErF�depart_line�	szLaTeXTranslator.depart_linecCsbtj|jd<tj|jd<|j|�t|jtj�r>|j	j
d�n |j|�|j	j
d�|j|�dS)Nr��	lineblockz0\item[]
\begin{DUlineblock}{\DUlineblockindent}
z\begin{DUlineblock}{0em}
)
r�r�r7rRr�r�r�rZ
line_blockrZr1r�r�)rDr	rErErF�visit_line_block�	s

z LaTeXTranslator.visit_line_blockcCs|jjd�|j|�dS)Nz\end{DUlineblock}
)rZr1r�)rDr	rErErF�depart_line_block�	sz!LaTeXTranslator.depart_line_blockcCs|jjd�dS)Nz
\item )rZr1)rDr	rErErF�visit_list_item�	szLaTeXTranslator.visit_list_itemcCsdS)NrE)rDr	rErErF�depart_list_item�	sz LaTeXTranslator.depart_list_itemcCsXd|_d|dkr6|jjdkr6tj|jd<tj|jd<|jj	d�|drT|j
|�dS)NT�coder�r$�colorz\texttt{)r�rO�syntax_highlightr�rXr5�highlight_rulesr7rZr1r�)rDr	rErErFrI�	szLaTeXTranslator.visit_literalcCs(d|_|dr|j|�|jjd�dS)NFr�r�)r�r�rZr1)rDr	rErErFrK�	s
zLaTeXTranslator.depart_literalcCst|�dkot|dtj�S)z,Check whether a node can be typeset verbatimr*r)r�r�rr�)rDr	rErErF�is_plaintext�	szLaTeXTranslator.is_plaintextcCs.dddddd�}|jd�r4|jdg|j|�7_|j|�|jj�sb|jjd�|jjd	�n|jjd�|j|�r�|j	}|j|d
�|j
d<|dkr�d
|_nd
|_|jjd||j
f�|jjd|�n\d
|_d
|_d
|_d|dko�|jjdk�rtj|j
d<tj|jd<|jjd�|jjd�dS)zRender a literal block.z\usepackage{alltt}z\usepackage{moreverb}z\usepackage{listings}z\usepackage{fancyvrb})r�ZlistingZ
lstlistingZVerbatimZverbatimtabr�rz\begin{quote}
z
\end{quote}
r%Z
literal_blockr�Tz
\begin{%s}%s
z	
\end{%s}rWr�r$rXz"{\ttfamily \raggedright \noindent
z
}N)r�rZr�r�rYr�r1rNr[rBr5r�r+rCr�r�r�rOrYr�rXrZr7)rDr	ZpackagesZenvironmentrErErFr��	s<



z#LaTeXTranslator.visit_literal_blockcCsPd|_d|_d|_d|_d|_|jj|jj��|jj|jj��|j	|�dS)NF)
r�r�r�r+r�rZr1rNr!r�)rDr	rErErFr�
sz$LaTeXTranslator.depart_literal_blockr�cCs�|dr|j|�d|jd<|j�jtj�}|jd�rLdj|g|j|��}|dkrf|j	r`d}q�d}ndjd	d
|dd|g�}|j
j||�|dr�|j|�t
j�d
S)z	math roler�z\usepackage{amsmath}Zamsmathr�rr�z\(%s\)z$%s$z%%z
\begin{%s}z%sz\end{%s}N)r�r5r�r^rZ
uni2tex_tabler�rTr�r�rZr1r�rr�)rDr	�math_envZ	math_code�wrapperrErErF�
visit_math
s$



zLaTeXTranslator.visit_mathcCsdS)NrE)rDr	rErErF�depart_math5
szLaTeXTranslator.depart_mathcCst|j��}|j||d�dS)N)r\)r
r�r^)rDr	r\rErErF�visit_math_block8
sz LaTeXTranslator.visit_math_blockcCsdS)NrE)rDr	rErErF�depart_math_block<
sz!LaTeXTranslator.depart_math_blockcCs|jdr|jjd�dS)Nr*z, r�)rNrZr1)rDr	rErErF�visit_option?
s
zLaTeXTranslator.visit_optioncCs|jdd7<dS)Nr*r�)rN)rDr	rErErF�
depart_optionD
szLaTeXTranslator.depart_optioncCs|jj|jdd��dS)zAAppend the delimiter betweeen an option and its argument to body.Z	delimiterr�N)rZr1r�)rDr	rErErF�visit_option_argumentH
sz%LaTeXTranslator.visit_option_argumentcCsdS)NrE)rDr	rErErF�depart_option_argumentL
sz&LaTeXTranslator.depart_option_argumentcCs|jjd�|jjd�dS)Nz
\item[r)rZr1rN)rDr	rErErF�visit_option_groupO
sz"LaTeXTranslator.visit_option_groupcCs|jj�|jjd�dS)Nz] )rNr!rZr1)rDr	rErErF�depart_option_groupT
s
z#LaTeXTranslator.depart_option_groupcCs2tj|jd<tj|jd<|j|�|jjd�dS)Nr��
optionlistz\begin{DUoptionlist})r�r�r7rhr�rZr1)rDr	rErErF�visit_option_listX
s
z!LaTeXTranslator.visit_option_listcCs|jjd�|j|�dS)Nz\end{DUoptionlist}
)rZr1r�)rDr	rErErF�depart_option_list^
sz"LaTeXTranslator.depart_option_listcCsdS)NrE)rDr	rErErF�visit_option_list_itemb
sz&LaTeXTranslator.visit_option_list_itemcCsdS)NrE)rDr	rErErF�depart_option_list_iteme
sz'LaTeXTranslator.depart_option_list_itemcCsdS)NrE)rDr	rErErF�visit_option_stringh
sz#LaTeXTranslator.visit_option_stringcCsdS)NrE)rDr	rErErF�depart_option_stringl
sz$LaTeXTranslator.depart_option_stringcCs|j|d�dS)Nr�)r�)rDr	rErErF�visit_organizationp
sz"LaTeXTranslator.visit_organizationcCs|j|�dS)N)r�)rDr	rErErF�depart_organizations
sz#LaTeXTranslator.depart_organizationcCs�|jj|�}|dkr.t|jtjtjtjf�r.n�|dkrvt|jtj�rvt|j|dtj�rvt|j|dtj�rvn@|jj	r�|dkr�|j
d|d�|dkr�|jjd�n|jjd�|j
d�r�|j|j|�dg7_|dr�|j|�dS)Nrr*z:LaTeX merges paragraphs in tables with auto-sized columns!)�	base_noderr�r�)r��indexr�rZ	list_item�descriptionr�r�rYr�r;rZr1r�r�r�)rDr	rrrErErF�visit_paragraphv
s&
zLaTeXTranslator.visit_paragraphcCs*|dr|j|�|jjs&|jjd�dS)Nr�r)r�rYr�rZr1)rDr	rErErF�depart_paragraph�
s
z LaTeXTranslator.depart_paragraphcCs:tj|jd<|jjd�|j|�|jjd|d�dS)NrXz%
z"\hyperlink{%s}{\textbf{\color{red}r�)r�rXr5rZr1r�)rDr	rErErF�visit_problematic�
s
z!LaTeXTranslator.visit_problematiccCs|jjd�dS)Nz}})rZr1)rDr	rErErF�depart_problematic�
sz"LaTeXTranslator.depart_problematiccCsLd|jdd�j�krtj�|j|�s0|jjd�|drB|j|�d|_dS)Nr
r-r%rr�T)	r�rErr�r�rZr1r�r+)rDr	rErErF�	visit_raw�
s

zLaTeXTranslator.visit_rawcCs2d|_|dr|j|�|j|�s.|jjd�dS)NFr�r)r+r�r�rZr1)rDr	rErErF�
depart_raw�
s


zLaTeXTranslator.depart_rawcCsFd}x8|D]0}|dkr|d7}|dkr.|d8}|dkr
dSq
W|dkS)z7Test whether there are unmatched '{' or '}' characters.rr�r*r�TrE)rDrVr�r�rErErF�has_unbalanced_braces�
s
z%LaTeXTranslator.has_unbalanced_bracescCs td�dtd�dtd�di}d|kr�t|d�j|�}|jd�dksN|j|�r\|jd
|�|d|j�kr�|jjd|�t	j
�|jjd|�dSd
|kr�|d
}n"d|kr�|jj|d}nt
d��|j|�s�|jjd�|jjd|�|j�r|jjd|j|jdd�f�t	j
�dS)Nr�z\#r�z\%r�z\\�refuriz^^r*zYExternal link "%s" not supported by LaTeX.
 (Must not contain "^^" or unbalanced braces.)z\url{%s}z
\href{%s}{r�r�zUnknown reference.rz\hyperref[%s]{z\%s{%s}}r%r�)r�rWr^r^rzr<r�rZr1rr�rIr�r�r�r@r�)rDr	Z
special_charsr�rErErF�visit_reference�
s4

zLaTeXTranslator.visit_referencecCs&|jjd�|j|�s"|jjd�dS)Nr�r)rZr1r�)rDr	rErErF�depart_reference�
s
z LaTeXTranslator.depart_referencecCs|j|d�dS)NZrevision)r�)rDr	rErErF�visit_revision�
szLaTeXTranslator.visit_revisioncCs|j|�dS)N)r�)rDr	rErErF�depart_revision�
szLaTeXTranslator.depart_revisioncCs&tj|jd<|j|�|jjd�dS)N�rubricz
\DUrubric{)r�r�r7r�rZr1)rDr	rErErF�visit_rubric�
s
zLaTeXTranslator.visit_rubriccCs|jjd�|j|�dS)Nz}
)rZr1r�)rDr	rErErF�
depart_rubric�
szLaTeXTranslator.depart_rubriccCs6|jd7_|jjd�|j|jdd7<dS)Nr*r)rrUr1)rDr	rErErF�
visit_section�
szLaTeXTranslator.visit_sectioncCs|jj�|jd8_dS)Nr*)rUr!r)rDr	rErErF�depart_section�
s
zLaTeXTranslator.depart_sectioncCs2|j|�tj|jd<tj|jd<|jjd�dS)NrX�sidebarz\DUsidebar{)r�r�rXr5r�r7rZr1)rDr	rErErF�
visit_sidebar�
s
zLaTeXTranslator.visit_sidebarcCs|jjd�|j|�dS)Nz}
)rZr1r�)rDr	rErErF�depart_sidebarszLaTeXTranslator.depart_sidebar�—r%rr)r!r"r#r$cCs:|j|jj\}}|jjd�|jj|�|jj|�dS)Nz\nopagebreak

\raggedleft )�attribution_formatsrOZattributionrZr1rN)rDr	rrrErErF�visit_attribution
sz!LaTeXTranslator.visit_attributioncCs|jj|jj�d�dS)Nr)rZr1rNr!)rDr	rErErF�depart_attributionsz"LaTeXTranslator.depart_attributioncCs|j|d�dS)NZstatus)r�)rDr	rErErF�visit_statusszLaTeXTranslator.visit_statuscCs|j|�dS)N)r�)rDr	rErErF�
depart_statusszLaTeXTranslator.depart_statuscCs"|jjd�|dr|j|�dS)Nz\textbf{r�)rZr1r�)rDr	rErErF�visit_strongszLaTeXTranslator.visit_strongcCs"|dr|j|�|jjd�dS)Nr�r�)r�rZr1)rDr	rErErF�
depart_strong!s
zLaTeXTranslator.depart_strongcCs
tj�dS)N)rr�)rDr	rErErF�visit_substitution_definition&sz-LaTeXTranslator.visit_substitution_definitioncCs|j|�dS)N)�unimplemented_visit)rDr	rErErF�visit_substitution_reference)sz,LaTeXTranslator.visit_substitution_referencecCs�t|jtj�r@|j|j�tj|jd<|j	|j
|dd�7_	nNt|jtj�rn|jj
d|jj|jd��n tj|jd<|jj
d|jj�dS)N�documentsubtitleF)r�z\%s*{r*r:z
\DUsubtitle[%s]{)r�r�rrIr�r:r�r�r7rPr�r�rZr1rJr�tagname)rDr	rErErF�visit_subtitle,szLaTeXTranslator.visit_subtitlecCs(t|jtj�r|j�n|jjd�dS)Nz}
)r�r�rrIr�rZr1)rDr	rErErF�depart_subtitle9s
zLaTeXTranslator.depart_subtitlecCs�tj|jd<tj|jd<dg|d<|j|�|jjd�|j|�yd|d}Wnt	k
rjd}YnX|jjd	|d
|d|j
|d�|f�t|d
�dkr�|jjd|d
d�|jjd�n,dd�t
|d
�D�}|jjddj|��dS)NrXr9zsystem-messager�z*
\DUtitle[system-message]{system-message}
z	, line~%sr�r%z&

{\color{red}%s/%s} in \texttt{%s}%s
�typer��sourcer'r*z
\hyperlink{%s}{rr�cSs g|]\}}d||df�qS)z\hyperlink{%s}{%d}r*rE)r�rr�rErErFr�Qsz8LaTeXTranslator.visit_system_message.<locals>.<listcomp>z
backrefs: r�)r�rXr5r9r7r�rZr1r�r�r�r�rNr�rT)rDr	r�r'rErErF�visit_system_message?s&



z$LaTeXTranslator.visit_system_messagecCs|jj|jj��|j�dS)N)rZr1rNr!r�)rDr	rErErF�depart_system_messageUsz%LaTeXTranslator.depart_system_messagecCs�tj|jd<|jj�r0|jj|j�t|d�|_|jjdkr~t	|j
tj�r~|j
j
|�dkr~|jj|j�jd�dkr~|jjd�|jj�|jj|jj|d�d|kr�|jjd|d�|jjd	kr�d
|jd	<|jg�dS)Nr�Ztabularr�r*r�z\leavevmoder�rrz\usepackage{booktabs}r�)r�r�r5rYr�rXr1r�r�r�r�rr�rrrJrr^rZrNr�rOr�r�r�r�)rDr	rErErF�visit_tableYs"



zLaTeXTranslator.visit_tablecCs�|j}|j�|jjd|jj��|j|7_|jj|jj�d�|jj�t|j�dkrl|jj	�|_|j
d�r�|j|j|dd�dg7_dS)Nrrr�F)r�)rZr�r1rYrrrYr�rXr!r�r�)rDr	rlrErErF�depart_tableos

zLaTeXTranslator.depart_tablecCs`d|ksd|ksd|krdS|jjd�t|jtj�pBt|jtj�}|j|j||�7_dS)Nr{r�r�z%
)rZr1r�r�rr�r9r�)rDr	r�rErErF�visit_target~szLaTeXTranslator.visit_targetcCsdS)NrE)rDr	rErErF�
depart_target�szLaTeXTranslator.depart_targetcCs$|jjd�s |j|�|jd�dS)Nzpreamble written)rYr�rr)rDr	rErErF�visit_tbody�s
zLaTeXTranslator.visit_tbodycCsdS)NrE)rDr	rErErF�depart_tbody�szLaTeXTranslator.depart_tbodycCs|jjd�dS)zdefinition list termz\item[{N)rZr1)rDr	rErErF�
visit_term�szLaTeXTranslator.visit_termcCs|jjd�dS)Nz}] \leavevmode )rZr1)rDr	rErErF�depart_term�szLaTeXTranslator.depart_termcCsdS)NrE)rDr	rErErF�visit_tgroup�szLaTeXTranslator.visit_tgroupcCsdS)NrE)rDr	rErErF�
depart_tgroup�szLaTeXTranslator.depart_tgroupcCs|jS)N)�_thead_depth)rDrErErFr�szLaTeXTranslator.thead_depthcCsh|jd7_d|j�kr@|jjd|jj|��|jjdd�|jj|jj��|jj|jj	��dS)Nr*z{%s}
zpreamble written)
r�rrZr1rYrr�rr�r)rDr	rErErFr�szLaTeXTranslator.visit_theadcCs@|dk	r.|jj|jj��|jj�r.|j|�|jd8_dS)Nr*)rZr�rYrrrJr�)rDr	rErErFr�s


zLaTeXTranslator.depart_theadcCs�|jjdkrB|j|j�|jjd�|jjd|j|j����nht	|jt
j�slt	|jt
j�slt	|jt
j
�r�tj|jd<dj|jd�}|s�|j}|jjd|�|jjd�n�t	|jt
j�r�|j|jj�|jjd�n�ttd	�r�tj|jd	<|jj|j�}|jjd
�d|jdk�rJtj|jd<|j|j��}|jjd
||f�n|jjd|�|jt|jj�k�rztj|jd<dg}||j|jdd�7}|jjdj|�d�dS)z Append section and other titles.rIr%z  pdftitle={%s},r9r�r�z
\DUtitle[%s]{z}
r`z

zsystem-messagesrXz\%s[%s]{\color{red}z\%s{F)r�z%
  z%
}
N)r�r�r�r9rNr1rSr�r�r�r�topicr�r�r�r7rTrZr�rYr�rbr`r5rJr�rrXr�r�r�)rDr	r��section_nameZ
section_titleZbookmarkrErErF�visit_title�s@
zLaTeXTranslator.visit_titlecCs8|jj|jj��t|jtj�s,|jjdkr4|j	�dS)NrI)
rZr1rNr!r�r�rr�r�r�)rDr	rErErF�depart_title�szLaTeXTranslator.depart_titlec	Cs|jj|j�}ddd�}d|jjkr,d|d<y||}Wn*tk
rb|jd|d|d	�d
SXtj|jd<d||jd
|<t	|jj�}d||f|jd|<dddd�}d|jjkr�d|d<|r�|j
jd||||f�|j
jd||f�|j
jd|�d
S)z=Generate a local table of contents with LaTeX package minitocr]�mini)r]r�r��sectr�z Skipping local ToC at %s level.
z3  Feature not supported with option "use-latex-toc")rqNr�z\do%stoczminitoc-z\mtcsetdepth{%stoc}{%d}zminitoc-%s-depthr*r)r�r�r]z\setcounter{%stocdepth}{%d}z\mtcsettitle{%stoc}{%s}
z\%stoc
r�)rJr�rr�r�r;r�r�r5r�rZr1)	rDr	r9�depthr�Z
minitoc_namesZminitoc_nameZmaxdepth�offsetrErErFr��s0

zLaTeXTranslator.minitoccCs�d|dk�r|jjd�|j|j|�7_t|j�tj�rp|jjd|jd|j�j�|j	ddg�df�|j
�r
d}t|j�tj�r�|j|jd�j��}|j	d	d�}d
|dkr�|j
|||�dS|r�|jjd|�|dkr�|jjd
|�|jjd�d|_nd|_n�d|dk�r`|jj�r`|j|j�|jjd�t|j�tj��r�|jd�njd|dk�r�tj|jd<|j|j�n8d|dk�r�tj|jd<|j|j�n|djdd�|j|�dS)N�contentsr�rz
\pdfbookmark[%d]{%s}{%s}r*r�rr%r�Zlocalz\setcounter{tocdepth}{%d}
ZContentsz!
\renewcommand{\contentsname}{%s}z
\tableofcontents
Tr?z\begin{abstract}r>r�)rZr1r�r�Z	next_noderr9rr�r�r+r�r!r�rr�rOr-r�r?r�r7r>r�r�)rDr	r9r�rErErF�visit_topicsL

zLaTeXTranslator.visit_topiccCsbd|_d|dkr(|jjr(|jjd�nd|dkr>|j|�d|dksVd|dkr^|j�dS)NFr?r�z\end{abstract}
r�r>)r�rOr-rZr1r�r�)rDr	rErErF�depart_topicNs
zLaTeXTranslator.depart_topiccCs4tj|jd<|jjdddd�|jjd�dS)N�
transitionz
%r��Krz\DUtransition
)r�r�r7rZr1)rDr	rErErF�visit_transitionYsz LaTeXTranslator.visit_transitioncCsdS)NrE)rDr	rErErF�depart_transition^sz!LaTeXTranslator.depart_transitioncCs|j|d�dS)N�version)r�)rDr	rErErF�
visit_versionaszLaTeXTranslator.visit_versioncCs|j|�dS)N)r�)rDr	rErErF�depart_versiondszLaTeXTranslator.depart_versioncCstd|jj��dS)Nz$visiting unimplemented node type: %s)rr�ra)rDr	rErErFr�gsz#LaTeXTranslator.unimplemented_visit)T)N)N)N)r�)r�r%)rr)rr)r%r%)�rarbrcr�r\r.r/rArr�rr�r+r�r�r�r�rgrAr5r=r|r�rD�compiler�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr(rrr#rrrrrrrrrrr r!r#r$r%r&r+r,r.r/r0r1r2r3r4r5r6r<rFrGr�r�rJrLrNrOrPrQrSrTrUrVrIrKr[r�r�r^r_r`rarbrcrdrerfrgrirjrkrlrmrnrorprtrurvrwrxryrzr|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�r�r�r�r�r�r�r�r�r�rErErErFrBps�
[")T
			
	C737

-
"
5#1rB)Dr�Z
__docformat__r7rRZtimerDrVZurllib.requestrEZurllib.parseZurllib.errorr��ImportErrorZdocutils.utils.romanrZdocutilsrrrrrZdocutils.utils.error_reportingrZdocutils.transformsr	Zdocutils.utils.mathr
rr�objectrgr�r�r�r?r�rXr=r>r�r<rr"r(rLrZrHrMrRrr�rhr�r�r�r:r�r�r�r�r�r9r�r�r�r�r:rBrErErErF�<module>sp r1
	,u