docutils.writers.latex2e package

LaTeX2e document tree Writer.

class Writer[source]

Bases: Writer

supported = ('latex', 'latex2e')

Formats this writer supports.

default_template = 'default.tex'
default_template_path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/sphinx-docutils/envs/latest/lib/python3.12/site-packages/docutils/writers/latex2e')
default_preamble = '% PDF Standard Fonts\n\\usepackage{mathptmx} % Times\n\\usepackage[scaled=.90]{helvet}\n\\usepackage{courier}'
table_style_values = ['booktabs', 'borderless', 'colwidths-auto', 'nolines', 'standard']
settings_spec = ('LaTeX-Specific Options', None, (('Specify LaTeX documentclass.  Default: "article".', ['--documentclass'], {'default': 'article'}), ('Specify document options.  Multiple options can be given, separated by commas.  Default: "a4paper".', ['--documentoptions'], {'default': 'a4paper'}), ('Format for footnote references: one of "superscript" or "brackets".  Default: "superscript".', ['--footnote-references'], {'choices': ['superscript', 'brackets'], 'default': 'superscript', 'metavar': '<format>', 'overrides': 'trim_footnote_reference_space'}), ('Use \\cite command for citations. (future default)', ['--use-latex-citations'], {'action': 'store_true', 'default': None, 'validator': <function validate_boolean>}), ('Use figure floats for citations (might get mixed with real figures). (provisional default)', ['--figure-citations'], {'action': 'store_false', 'dest': 'use_latex_citations', 'validator': <function validate_boolean>}), ('Format for block quote attributions: one of "dash" (em-dash prefix), "parentheses"/"parens", or "none".  Default: "dash".', ['--attribution'], {'choices': ['dash', 'parentheses', 'parens', 'none'], 'default': 'dash', 'metavar': '<format>'}), ('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.', ['--stylesheet'], {'default': '', 'metavar': '<file[,file,...]>', 'overrides': 'stylesheet_path', 'validator': <function validate_comma_separated_list>}), ('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. ', ['--stylesheet-path'], {'metavar': '<file[,file,...]>', 'overrides': 'stylesheet', 'validator': <function validate_comma_separated_list>}), ('Link to the stylesheet(s) in the output file. (default)', ['--link-stylesheet'], {'action': 'store_false', 'dest': 'embed_stylesheet'}), ('Embed the stylesheet(s) in the output file. Stylesheets must be accessible during processing. ', ['--embed-stylesheet'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Comma-separated list of directories where stylesheets are found. Used by --stylesheet-path when expanding relative path arguments. Default: ".".', ['--stylesheet-dirs'], {'default': ['.'], 'metavar': '<dir[,dir,...]>', 'validator': <function validate_comma_separated_list>}), ('Customization by LaTeX code in the preamble. Default: select PDF standard fonts (Times, Helvetica, Courier).', ['--latex-preamble'], {'default': '% PDF Standard Fonts\n\\usepackage{mathptmx} % Times\n\\usepackage[scaled=.90]{helvet}\n\\usepackage{courier}'}), ('Specify the template file. Default: "default.tex".', ['--template'], {'default': 'default.tex', 'metavar': '<file>'}), ('Table of contents by LaTeX. (default)', ['--use-latex-toc'], {'action': 'store_true', 'default': True, 'validator': <function validate_boolean>}), ('Table of contents by Docutils (without page numbers).', ['--use-docutils-toc'], {'action': 'store_false', 'dest': 'use_latex_toc', 'validator': <function validate_boolean>}), ('Add parts on top of the section hierarchy.', ['--use-part-section'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Attach author and date to the document info table. (default)', ['--use-docutils-docinfo'], {'action': 'store_false', 'dest': 'use_latex_docinfo', 'validator': <function validate_boolean>}), ('Attach author and date to the document title.', ['--use-latex-docinfo'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Typeset abstract as topic. (default)', ['--topic-abstract'], {'action': 'store_false', 'dest': 'use_latex_abstract', 'validator': <function validate_boolean>}), ("Use LaTeX abstract environment for the document's abstract.", ['--use-latex-abstract'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Color of any hyperlinks embedded in text. Default: "blue" (use "false" to disable).', ['--hyperlink-color'], {'default': 'blue'}), ('Additional options to the "hyperref" package.', ['--hyperref-options'], {'default': ''}), ('Enable compound enumerators for nested enumerated lists (e.g. "1.2.a.ii").', ['--compound-enumerators'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Disable compound enumerators for nested enumerated lists. (default)', ['--no-compound-enumerators'], {'action': 'store_false', 'dest': 'compound_enumerators'}), ('Enable section ("." subsection ...) prefixes for compound enumerators.  This has no effect without --compound-enumerators.', ['--section-prefix-for-enumerators'], {'action': 'store_true', 'default': None, 'validator': <function validate_boolean>}), ('Disable section prefixes for compound enumerators. (default)', ['--no-section-prefix-for-enumerators'], {'action': 'store_false', 'dest': 'section_prefix_for_enumerators'}), ('Set the separator between section number and enumerator for compound enumerated lists.  Default: "-".', ['--section-enumerator-separator'], {'default': '-', 'metavar': '<char>'}), ('When possible, use the specified environment for literal-blocks. Default: "" (fall back to "alltt").', ['--literal-block-env'], {'default': ''}), ('Deprecated alias for "--literal-block-env=verbatim".', ['--use-verbatim-when-possible'], {'action': 'store_true', 'validator': <function validate_boolean>}), ('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"', ['--table-style'], {'action': 'append', 'choices': ['booktabs', 'borderless', 'colwidths-auto', 'nolines', 'standard'], 'default': ['standard'], 'metavar': '<format>', 'validator': <function validate_comma_separated_list>}), ('LaTeX graphicx package option. Possible values are "dvipdfmx", "dvips", "dvisvgm", "luatex", "pdftex", and "xetex".Default: "".', ['--graphicx-option'], {'default': ''}), ('LaTeX font encoding. Possible values are "", "T1" (default), "OT1", "LGR,T1" or any other combination of options to the `fontenc` package. ', ['--font-encoding'], {'default': 'T1'}), ('Per default the latex-writer puts the reference title into hyperreferences. Specify "ref*" or "pageref*" to get the section number or the page number.', ['--reference-label'], {'default': ''}), ('Specify style and database(s) for bibtex, for example "--use-bibtex=unsrt,mydb1,mydb2". Provisional!', ['--use-bibtex'], {'default': '', 'metavar': '<style,bibfile[,bibfile,...]>', 'validator': <function validate_comma_separated_list>}), ('Use legacy functions with class value list for \\DUtitle and \\DUadmonition.', ['--legacy-class-functions'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Use \\DUrole and "DUclass" wrappers for class values. Place admonition content in an environment. (default)', ['--new-class-functions'], {'action': 'store_false', 'dest': 'legacy_class_functions', 'validator': <function validate_boolean>}), ('Use legacy algorithm to determine table column widths. (provisional default)', ['--legacy-column-widths'], {'action': 'store_true', 'default': None, 'validator': <function validate_boolean>}), ('Use new algorithm to determine table column widths. (future default)', ['--new-column-widths'], {'action': 'store_false', 'dest': 'legacy_column_widths', 'validator': <function validate_boolean>}), ('Footnotes with numbers/symbols by Docutils. (default) (The alternative, --latex-footnotes, is not implemented yet.)', ['--docutils-footnotes'], {'action': 'store_true', 'default': True, 'validator': <function validate_boolean>})))

Runtime settings specification. Override in subclasses.

Defines runtime settings and associated command-line options, as used by docutils.frontend.OptionParser. This is a tuple of:

  • Option group title (string or None which implies no group, just a list of single options).

  • Description (string or None).

  • A sequence of option tuples. Each consists of:

    • Help text (string)

    • List of option strings (e.g. ['-Q', '--quux']).

    • Dictionary of keyword arguments sent to the OptionParser/OptionGroup add_option method.

      Runtime setting names are derived implicitly from long option names (’–a-setting’ becomes settings.a_setting) or explicitly from the ‘dest’ keyword argument.

      Most settings will also have a ‘validator’ keyword & function. The validator function validates setting values (from configuration files and command-line option arguments) and converts them to appropriate types. For example, the docutils.frontend.validate_boolean function, required by all boolean settings, converts true values (‘1’, ‘on’, ‘yes’, and ‘true’) to 1 and false values (‘0’, ‘off’, ‘no’, ‘false’, and ‘’) to 0. Validators need only be set once per setting. See the docutils.frontend.validate_* functions.

      See the optparse docs for more details.

  • More triples of group title, description, options, as many times as needed. Thus, settings_spec tuples can be simply concatenated.

settings_defaults = {'sectnum_depth': 0}

A dictionary of defaults for settings not in settings_spec (internal settings, intended to be inaccessible by command-line and config file). Override in subclasses.

config_section = 'latex2e writer'

The name of the config file section specific to this component (lowercase, no brackets). Override in subclasses.

config_section_dependencies = ('writers', 'latex writers')

A list of names of config file sections that are to be applied before config_section, in order (from general to specific). In other words, the settings in config_section are to be overlaid on top of the settings from these sections. The “general” section is assumed implicitly. Override in subclasses.

head_parts = ('head_prefix', 'requirements', 'latex_preamble', 'stylesheet', 'fallbacks', 'pdfsetup', 'titledata')
visitor_attributes = ('head_prefix', 'requirements', 'latex_preamble', 'stylesheet', 'fallbacks', 'pdfsetup', 'titledata', 'title', 'subtitle', 'body_pre_docinfo', 'docinfo', 'dedication', 'abstract', 'body')
output = None

Final translated form of document.

get_transforms()[source]

Transforms required by this class. Override in subclasses.

translate()[source]

Do final translation of self.document into self.output. Called from write. Override in subclasses.

Usually done with a docutils.nodes.NodeVisitor subclass, in combination with a call to docutils.nodes.Node.walk() or docutils.nodes.Node.walkabout(). The NodeVisitor subclass must support all standard elements (listed in docutils.nodes.node_class_names) and possibly non-standard elements used by the current Reader as well.

assemble_parts()[source]

Assemble the self.parts dictionary of output fragments.

class Babel(language_code, reporter=None)[source]

Bases: object

Language specifics for LaTeX.

language_codes = {'af': 'afrikaans', 'ar': 'arabic', 'bg': 'bulgarian', 'br': 'breton', 'ca': 'catalan', 'cs': 'czech', 'cy': 'welsh', 'da': 'danish', 'de': 'ngerman', 'de-1901': 'german', 'de-at': 'naustrian', 'de-at-1901': 'austrian', 'dsb': 'lowersorbian', 'el': 'greek', 'el-polyton': 'polutonikogreek', 'en': 'english', 'en-au': 'australian', 'en-ca': 'canadian', 'en-gb': 'british', 'en-nz': 'newzealand', 'en-us': 'american', 'eo': 'esperanto', 'es': 'spanish', 'et': 'estonian', 'eu': 'basque', 'fi': 'finnish', 'fr': 'french', 'fr-ca': 'canadien', 'ga': 'irish', 'gl': 'galician', 'grc-ibycus': 'ibycus', 'he': 'hebrew', 'hr': 'croatian', 'hsb': 'uppersorbian', 'hu': 'magyar', 'ia': 'interlingua', 'id': 'bahasai', 'is': 'icelandic', 'it': 'italian', 'ja': 'japanese', 'kk': 'kazakh', 'la': 'latin', 'lt': 'lithuanian', 'lv': 'latvian', 'mn': 'mongolian', 'ms': 'bahasam', 'nb': 'norsk', 'nl': 'dutch', 'nn': 'nynorsk', 'no': 'norsk', 'pl': 'polish', 'pt': 'portuges', 'pt-br': 'brazil', 'ro': 'romanian', 'ru': 'russian', 'se': 'samin', 'sh-cyrl': 'serbianc', 'sh-latn': 'serbian', 'sk': 'slovak', 'sl': 'slovene', 'sq': 'albanian', 'sr': 'serbianc', 'sr-latn': 'serbian', 'sv': 'swedish', 'tr': 'turkish', 'uk': 'ukrainian', 'vi': 'vietnam'}
warn_msg = 'Language "%s" not supported by LaTeX (babel)'
active_chars = {'galician': '.<>', 'spanish': '.<>'}
__call__()[source]

Return the babel call with correct options and settings

language_name(language_code)[source]

Return TeX language name for language_code

get_language()[source]
class SortableDict[source]

Bases: dict

Dictionary with additional sorting methods

Tip: use key starting with with ‘_’ for sorting before small letters

and with ‘~’ for sorting after small letters.

sortedkeys()[source]

Return sorted list of keys

sortedvalues()[source]

Return list of values sorted by keys

class PreambleCmds[source]

Bases: object

Building blocks for the latex preamble.

abstract = '\n\\providecommand*{\\DUCLASSabstract}{\n  \\renewcommand{\\DUtitle}[1]{\\centerline{\\textbf{##1}}}\n}'
abstract_legacy = '\n% abstract title\n\\providecommand*{\\DUtitleabstract}[1]{\\centerline{\\textbf{#1}}}'
admonition = '\n% admonition environment (specially marked topic)\n\\ifx\\DUadmonition\\undefined % poor man\'s "provideenvironment"\n \\newbox{\\DUadmonitionbox}\n \\newenvironment{DUadmonition}%\n  {\\begin{center}\n     \\begin{lrbox}{\\DUadmonitionbox}\n       \\begin{minipage}{0.9\\linewidth}\n  }%\n  {    \\end{minipage}\n     \\end{lrbox}\n     \\fbox{\\usebox{\\DUadmonitionbox}}\n   \\end{center}\n  }\n\\fi'
admonition_legacy = '\n% admonition (specially marked topic)\n\\providecommand{\\DUadmonition}[2][class-arg]{%\n  % try \\DUadmonition#1{#2}:\n  \\ifcsname DUadmonition#1\\endcsname%\n    \\csname DUadmonition#1\\endcsname{#2}%\n  \\else\n    \\begin{center}\n      \\fbox{\\parbox{0.9\\linewidth}{#2}}\n    \\end{center}\n  \\fi\n}'
color = '\\usepackage{color}'
dedication = '\n% special topic for dedications\n\\providecommand*{\\DUCLASSdedication}{%\n  \\renewenvironment{quote}{\\begin{center}}{\\end{center}}%\n}'
docinfo = '\n% width of docinfo table\n\\DUprovidelength{\\DUdocinfowidth}{0.9\\linewidth}'
documentsubtitle = '\n% subtitle (in document title)\n\\providecommand*{\\DUdocumentsubtitle}[1]{{\\large #1}}'
duclass = '\n% class handling for environments (block-level elements)\n% \\begin{DUclass}{spam} tries \\DUCLASSspam and\n% \\end{DUclass}{spam} tries \\endDUCLASSspam\n\\ifx\\DUclass\\undefined % poor man\'s "provideenvironment"\n \\newenvironment{DUclass}[1]%\n  {% "#1" does not work in end-part of environment.\n   \\def\\DocutilsClassFunctionName{DUCLASS#1}\n     \\csname \\DocutilsClassFunctionName \\endcsname}%\n  {\\csname end\\DocutilsClassFunctionName \\endcsname}%\n\\fi'
error = '\n\\providecommand*{\\DUCLASSerror}{\\color{red}}'
error_legacy = '\n% error admonition title\n\\providecommand*{\\DUtitleerror}[1]{\\DUtitle{\\color{red}#1}}'
fieldlist = '\n% field list environment (for separate configuration of `field lists`)\n\\ifthenelse{\\isundefined{\\DUfieldlist}}{\n  \\newenvironment{DUfieldlist}%\n    {\\quote\\description}\n    {\\enddescription\\endquote}\n}{}'
float = '\\usepackage{float} % extended float configuration\n\\floatplacement{figure}{H} % place figures here definitely'
footnotes = '\n% numerical or symbol footnotes with hyperlinks and backlinks\n\\providecommand*{\\DUfootnotemark}[3]{%\n  \\raisebox{1em}{\\hypertarget{#1}{}}%\n  \\hyperlink{#2}{\\textsuperscript{#3}}%\n}\n\\providecommand{\\DUfootnotetext}[4]{%\n  \\begingroup%\n  \\renewcommand{\\thefootnote}{%\n    \\protect\\raisebox{1em}{\\protect\\hypertarget{#1}{}}%\n    \\protect\\hyperlink{#2}{#3}}%\n  \\footnotetext{#4}%\n  \\endgroup%\n}'
highlight_rules = '\n% basic code highlight:\n\\providecommand*\\DUrolecomment[1]{\\textcolor[rgb]{0.40,0.40,0.40}{#1}}\n\\providecommand*\\DUroledeleted[1]{\\textcolor[rgb]{0.40,0.40,0.40}{#1}}\n\\providecommand*\\DUrolekeyword[1]{\\textbf{#1}}\n\\providecommand*\\DUrolestring[1]{\\textit{#1}}'
inline = '\n% custom inline roles: \\DUrole{#1}{#2} tries \\DUrole#1{#2}\n\\providecommand*{\\DUrole}[2]{%\n  \\ifcsname DUrole#1\\endcsname%\n    \\csname DUrole#1\\endcsname{#2}%\n  \\else%\n    #2%\n  \\fi%\n}'
legend = '\n% legend environment (in figures and formal tables)\n\\ifthenelse{\\isundefined{\\DUlegend}}{\n  \\newenvironment{DUlegend}{\\small}{}\n}{}'
lineblock = '\n% line block environment\n\\DUprovidelength{\\DUlineblockindent}{2.5em}\n\\ifthenelse{\\isundefined{\\DUlineblock}}{\n  \\newenvironment{DUlineblock}[1]{%\n    \\list{}{\\setlength{\\partopsep}{\\parskip}\n            \\addtolength{\\partopsep}{\\baselineskip}\n            \\setlength{\\topsep}{0pt}\n            \\setlength{\\itemsep}{0.15\\baselineskip}\n            \\setlength{\\parsep}{0pt}\n            \\setlength{\\leftmargin}{#1}}\n    \\raggedright\n  }\n  {\\endlist}\n}{}'
linking = '%% hyperlinks:\n\\ifthenelse{\\isundefined{\\hypersetup}}{\n  \\usepackage[%s]{hyperref}\n  \\usepackage{bookmark}\n  \\urlstyle{same} %% normal text font (alternatives: tt, rm, sf)\n}{}'
minitoc = '%% local table of contents\n\\usepackage{minitoc}'
optionlist = '\n% list of command line options\n\\providecommand*{\\DUoptionlistlabel}[1]{\\bfseries #1 \\hfill}\n\\DUprovidelength{\\DUoptionlistindent}{3cm}\n\\ifthenelse{\\isundefined{\\DUoptionlist}}{\n  \\newenvironment{DUoptionlist}{%\n    \\list{}{\\setlength{\\labelwidth}{\\DUoptionlistindent}\n            \\setlength{\\rightmargin}{1cm}\n            \\setlength{\\leftmargin}{\\rightmargin}\n            \\addtolength{\\leftmargin}{\\labelwidth}\n            \\addtolength{\\leftmargin}{\\labelsep}\n            \\renewcommand{\\makelabel}{\\DUoptionlistlabel}}\n  }\n  {\\endlist}\n}{}'
providelength = '\n% Provide a length variable and set default, if it is new\n\\providecommand*{\\DUprovidelength}[2]{\n  \\ifthenelse{\\isundefined{#1}}{\\newlength{#1}\\setlength{#1}{#2}}{}\n}'
rubric = '\n% informal heading\n\\providecommand*{\\DUrubric}[1]{\\subsubsection*{\\emph{#1}}}'
sidebar = '\n% text outside the main text flow\n\\providecommand{\\DUsidebar}[1]{%\n  \\begin{center}\n    \\colorbox[gray]{0.80}{\\parbox{0.9\\linewidth}{#1}}\n  \\end{center}\n}'
subtitle = '\n% subtitle (for sidebar)\n\\providecommand*{\\DUsubtitle}[1]{\\par\\emph{#1}\\smallskip}'
table = '\\usepackage{longtable,ltcaption,array}\n\\setlength{\\extrarowheight}{2pt}\n\\newlength{\\DUtablewidth} % internal use in tables'
table_columnwidth = '\\newcommand{\\DUcolumnwidth}[1]{\\dimexpr#1\\DUtablewidth-2\\tabcolsep\\relax}'
textcomp = '\\usepackage{textcomp} % text symbol macros'
title = '\n% title for topics, admonitions, unsupported section levels, and sidebar\n\\providecommand*{\\DUtitle}[1]{%\n  \\smallskip\\noindent\\textbf{#1}\\smallskip}'
title_legacy = '\n% title for topics, admonitions, unsupported section levels, and sidebar\n\\providecommand*{\\DUtitle}[2][class-arg]{%\n  % call \\DUtitle#1{#2} if it exists:\n  \\ifcsname DUtitle#1\\endcsname%\n    \\csname DUtitle#1\\endcsname{#2}%\n  \\else\n    \\smallskip\\noindent\\textbf{#2}\\smallskip%\n  \\fi\n}'
titlereference = '\n% titlereference standard role\n\\providecommand*{\\DUroletitlereference}[1]{\\textsl{#1}}'
toc_list = '\n\\providecommand*{\\DUCLASScontents}{%\n  \\renewenvironment{itemize}%\n    {\\begin{list}{}{\\setlength{\\partopsep}{0pt}\n                    \\setlength{\\parsep}{0pt}}\n                   }%\n    {\\end{list}}%\n}'
transition = '\n% transition (break / fancybreak / anonymous section)\n\\providecommand*{\\DUtransition}{%\n  \\hspace*{\\fill}\\hrulefill\\hspace*{\\fill}\n  \\vskip 0.5\\baselineskip\n}'
ttem = '\n% character width in monospaced font\n\\newlength{\\ttemwidth}\n\\settowidth{\\ttemwidth}{\\ttfamily M}'
_read_block(fp)[source]
class CharMaps[source]

Bases: object

LaTeX representations for active and Unicode characters.

alltt = {92: '\\textbackslash{}', 123: '\\{', 125: '\\}'}
special = {34: '\\textquotedbl{}', 35: '\\#', 36: '\\$', 37: '\\%', 38: '\\&', 91: '{[}', 93: '{]}', 94: '\\textasciicircum{}', 95: '\\_', 126: '\\textasciitilde{}', 173: '\\-'}
unsupported_unicode = {8192: '\\enskip', 8193: '\\quad', 8194: '\\enskip', 8195: '\\quad', 8200: '\\,', 8203: '\\hspace{0pt}', 8209: '\\hbox{-}', 8239: '\\,', 8491: '\\AA', 8660: '\\ensuremath{\\Leftrightarrow}', 8800: '\\ensuremath{\\neq}', 8801: '\\ensuremath{\\equiv}', 8804: '\\ensuremath{\\le}', 8805: '\\ensuremath{\\ge}', 9824: '\\ensuremath{\\spadesuit}', 9827: '\\ensuremath{\\clubsuit}', 64256: 'ff', 64257: 'fi', 64258: 'fl', 64259: 'ffi', 64260: 'ffl'}
utf8_supported_unicode = {160: '~', 171: '\\guillemotleft{}', 187: '\\guillemotright{}', 8204: '\\textcompwordmark{}', 8211: '\\textendash{}', 8212: '\\textemdash{}', 8216: '\\textquoteleft{}', 8217: '\\textquoteright{}', 8218: '\\quotesinglbase{}', 8220: '\\textquotedblleft{}', 8221: '\\textquotedblright{}', 8222: '\\quotedblbase{}', 8224: '\\dag{}', 8225: '\\ddag{}', 8230: '\\dots{}', 8240: '\\textperthousand{}', 8241: '\\textpertenthousand{}', 8249: '\\guilsinglleft{}', 8250: '\\guilsinglright{}', 8482: '\\texttrademark{}', 9251: '\\textvisiblespace{}'}
textcomp = {162: '\\textcent{}', 164: '\\textcurrency{}', 165: '\\textyen{}', 166: '\\textbrokenbar{}', 167: '\\textsection{}', 168: '\\textasciidieresis{}', 169: '\\textcopyright{}', 170: '\\textordfeminine{}', 172: '\\textlnot{}', 174: '\\textregistered{}', 175: '\\textasciimacron{}', 176: '\\textdegree{}', 177: '\\textpm{}', 178: '\\texttwosuperior{}', 179: '\\textthreesuperior{}', 180: '\\textasciiacute{}', 181: '\\textmu{}', 182: '\\textparagraph{}', 185: '\\textonesuperior{}', 186: '\\textordmasculine{}', 188: '\\textonequarter{}', 189: '\\textonehalf{}', 190: '\\textthreequarters{}', 215: '\\texttimes{}', 247: '\\textdiv{}', 402: '\\textflorin{}', 697: '\\textasciiacute{}', 698: '\\textacutedbl{}', 8214: '\\textbardbl{}', 8226: '\\textbullet{}', 8242: '\\textasciiacute{}', 8243: '\\textacutedbl{}', 8245: '\\textasciigrave{}', 8246: '\\textgravedbl{}', 8251: '\\textreferencemark{}', 8253: '\\textinterrobang{}', 8260: '\\textfractionsolidus{}', 8261: '\\textlquill{}', 8262: '\\textrquill{}', 8274: '\\textdiscount{}', 8353: '\\textcolonmonetary{}', 8355: '\\textfrenchfranc{}', 8356: '\\textlira{}', 8358: '\\textnaira{}', 8361: '\\textwon{}', 8363: '\\textdong{}', 8364: '\\texteuro{}', 8369: '\\textpeso{}', 8370: '\\textguarani{}', 8451: '\\textcelsius{}', 8470: '\\textnumero{}', 8471: '\\textcircledP{}', 8478: '\\textrecipe{}', 8480: '\\textservicemark{}', 8482: '\\texttrademark{}', 8486: '\\textohm{}', 8487: '\\textmho{}', 8494: '\\textestimated{}', 8592: '\\textleftarrow{}', 8593: '\\textuparrow{}', 8594: '\\textrightarrow{}', 8595: '\\textdownarrow{}', 8722: '\\textminus{}', 8727: '\\textasteriskcentered{}', 8730: '\\textsurd{}', 9250: '\\textblank{}', 9702: '\\textopenbullet{}', 9711: '\\textbigcircle{}', 9834: '\\textmusicalnote{}', 9901: '\\textmarried{}', 9902: '\\textdivorced{}', 10216: '\\textlangle{}', 10217: '\\textrangle{}'}
pifont = {9829: '\\ding{170}', 9830: '\\ding{169}', 10003: '\\ding{51}', 10007: '\\ding{55}'}
class DocumentClass(document_class, with_part=False)[source]

Bases: object

Details of a LaTeX document class.

section(level)[source]

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.

latex_section_depth(depth)[source]

Return LaTeX equivalent of Docutils section level depth.

Given the value of the :depth: option of the “contents” or “sectnum” directive, return the corresponding value for the LaTeX tocdepth or secnumdepth counters.

class Table(translator, latex_type)[source]

Bases: object

Manage a table while traversing.

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

open()[source]
close()[source]
is_open()[source]
set_table_style(node, settings)[source]
get_latex_type()[source]
set(attr, value)[source]
get(attr)[source]
get_vertical_bar()[source]
get_opening(width='\\linewidth')[source]
get_closing()[source]
visit_colspec(node)[source]
get_colspecs(node)[source]

Return column specification for longtable.

get_column_width()[source]

Return columnwidth for current cell (not multicell).

get_multicolumn_width(start, len_)[source]

Return sum of columnwidths for multicell.

get_caption()[source]
need_recurse()[source]
visit_thead()[source]
depart_thead()[source]
visit_row()[source]
depart_row()[source]
set_rowspan(cell, value)[source]
get_rowspan(cell)[source]
get_entry_number()[source]
visit_entry()[source]
is_stub_column()[source]
class LaTeXTranslator(document, babel_class=<class 'docutils.writers.latex2e.Babel'>)[source]

Bases: NodeVisitor

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.

is_xetex = False
has_latex_toc = False
section_level = 0
inside_citation_reference_label = False
verbatim = False
insert_non_breaking_blanks = False
insert_newline = False
literal = False
alltt = False
compound_enumerators = False
section_prefix_for_enumerators = False
section_enumerator_separator = '-'
context

Heterogeneous stack.

Used by visit_* and depart_* functions in conjunction with the tree traversal. Make sure that the pops correspond to the pushes.

stylesheet_call(path)[source]

Return code to reference or embed stylesheet file path

to_latex_encoding(docutils_encoding)[source]

Translate docutils encoding name into LaTeX’s.

Default method is remove “-” and “_” chars from docutils_encoding.

language_label(docutil_label)[source]
encode(text)[source]

Return 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.

attval(text, whitespace=re.compile('[\n\r\t\x0b\x0c]'))[source]

Cleanse, encode, and return attribute value text.

is_inline(node)[source]

Check whether a node represents an inline or block-level element

append_hypertargets(node)[source]

Append hypertargets for all ids of node

ids_to_labels(node, set_anchor=True, protect=False, newline=False)[source]

Return list of label definitions for all ids of node

If set_anchor is True, an anchor is set with phantomsection. If protect is True, the label cmd is made robust. If newline is True, a newline is added if there are labels.

set_align_from_classes(node)[source]

Convert align-* class arguments into alignment args.

insert_align_declaration(node, default=None)[source]
duclass_open(node)[source]

Open a group and insert declarations for class values.

duclass_close(node)[source]

Close a group of class declarations.

push_output_collector(new_out)[source]
pop_output_collector()[source]
term_postfix(node)[source]

Return LaTeX code required between term or field name and content.

In a LaTeX “description” environment (used for definition lists and non-docinfo field lists), a \leavevmode between an item’s label and content ensures the correct placement of certain block constructs.

visit_Text(node)[source]
depart_Text(node)[source]
visit_abbreviation(node)[source]
depart_abbreviation(node)[source]
visit_acronym(node)[source]
depart_acronym(node)[source]
visit_address(node)[source]
depart_address(node)[source]
visit_admonition(node)[source]
depart_admonition(node)[source]
visit_author(node)[source]
depart_author(node)[source]
visit_authors(node)[source]
depart_authors(node)[source]
visit_block_quote(node)[source]
depart_block_quote(node)[source]
visit_bullet_list(node)[source]
depart_bullet_list(node)[source]
visit_superscript(node)[source]
depart_superscript(node)[source]
visit_subscript(node)[source]
depart_subscript(node)[source]
visit_caption(node)[source]
depart_caption(node)[source]
visit_title_reference(node)[source]
depart_title_reference(node)[source]
visit_citation(node)[source]
depart_citation(node)[source]
visit_citation_reference(node)[source]
depart_citation_reference(node)[source]
visit_classifier(node)[source]
depart_classifier(node)[source]
visit_colspec(node)[source]
depart_colspec(node)[source]
visit_comment(node)[source]
depart_comment(node)[source]
visit_compound(node)[source]
depart_compound(node)[source]
visit_contact(node)[source]
depart_contact(node)[source]
visit_container(node)[source]
depart_container(node)[source]
visit_date(node)[source]
depart_date(node)[source]
visit_decoration(node)[source]
depart_decoration(node)[source]
visit_definition(node)[source]
depart_definition(node)[source]
visit_definition_list(node)[source]
depart_definition_list(node)[source]
visit_definition_list_item(node)[source]
depart_definition_list_item(node)[source]
visit_description(node)[source]
depart_description(node)[source]
visit_docinfo(node)[source]
depart_docinfo(node)[source]
visit_docinfo_item(node, name)[source]
depart_docinfo_item(node)[source]
visit_doctest_block(node)[source]
depart_doctest_block(node)[source]
visit_document(node)[source]
depart_document(node)[source]
make_title()[source]
append_bibliogaphy()[source]
visit_emphasis(node)[source]
depart_emphasis(node)[source]
insert_additional_table_colum_delimiters()[source]
visit_entry(node)[source]
depart_entry(node)[source]
visit_row(node)[source]
depart_row(node)[source]
visit_enumerated_list(node)[source]
depart_enumerated_list(node)[source]
visit_field(node)[source]
depart_field(node)[source]
visit_field_body(node)[source]
depart_field_body(node)[source]
visit_field_list(node)[source]
depart_field_list(node)[source]
visit_field_name(node)[source]
depart_field_name(node)[source]
visit_figure(node)[source]
depart_figure(node)[source]
visit_footnote(node)[source]
depart_footnote(node)[source]
visit_footnote_reference(node)[source]
depart_footnote_reference(node)[source]
label_delim(node, bracket, superscript)[source]
visit_label(node)[source]

footnote or citation label: in brackets or as superscript

depart_label(node)[source]
visit_generated(node)[source]
depart_generated(node)[source]
visit_header(node)[source]
depart_header(node)[source]
to_latex_length(length_str, pxunit=None)[source]

Convert length_str with rst length to LaTeX length

visit_image(node)[source]
depart_image(node)[source]
visit_inline(node)[source]
depart_inline(node)[source]
visit_legend(node)[source]
depart_legend(node)[source]
visit_line(node)[source]
depart_line(node)[source]
visit_line_block(node)[source]
depart_line_block(node)[source]
visit_list_item(node)[source]
depart_list_item(node)[source]
visit_literal(node)[source]
depart_literal(node)[source]
is_plaintext(node)[source]

Check whether a node can be typeset verbatim

visit_literal_block(node)[source]

Render a literal block.

Corresponding rST elements: literal block, parsed-literal, code.

depart_literal_block(node)[source]
visit_meta(node)[source]
depart_meta(node)[source]
visit_math(node, math_env='$')[source]

math role

depart_math(node)[source]
visit_math_block(node)[source]
depart_math_block(node)[source]
visit_option(node)[source]
depart_option(node)[source]
visit_option_argument(node)[source]

Append the delimiter between an option and its argument to body.

depart_option_argument(node)[source]
visit_option_group(node)[source]
depart_option_group(node)[source]
visit_option_list(node)[source]
depart_option_list(node)[source]
visit_option_list_item(node)[source]
depart_option_list_item(node)[source]
visit_option_string(node)[source]
depart_option_string(node)[source]
visit_organization(node)[source]
depart_organization(node)[source]
visit_paragraph(node)[source]
depart_paragraph(node)[source]
visit_problematic(node)[source]
depart_problematic(node)[source]
visit_raw(node)[source]
depart_raw(node)[source]
has_unbalanced_braces(string)[source]

Test whether there are unmatched ‘{’ or ‘}’ characters.

visit_reference(node)[source]
depart_reference(node)[source]
visit_revision(node)[source]
depart_revision(node)[source]
visit_rubric(node)[source]
depart_rubric(node)[source]
visit_section(node)[source]
depart_section(node)[source]
visit_sidebar(node)[source]
depart_sidebar(node)[source]
attribution_formats = {'dash': ('—', ''), 'none': ('', ''), 'parens': ('(', ')'), 'parentheses': ('(', ')')}
visit_attribution(node)[source]
depart_attribution(node)[source]
visit_status(node)[source]
depart_status(node)[source]
visit_strong(node)[source]
depart_strong(node)[source]
visit_substitution_definition(node)[source]
visit_substitution_reference(node)[source]
visit_subtitle(node)[source]
depart_subtitle(node)[source]
visit_system_message(node)[source]
depart_system_message(node)[source]
visit_table(node)[source]
depart_table(node)[source]
visit_target(node)[source]
depart_target(node)[source]
visit_tbody(node)[source]
depart_tbody(node)[source]
visit_term(node)[source]

definition list term

depart_term(node)[source]
visit_tgroup(node)[source]
depart_tgroup(node)[source]
_thead_depth = 0
thead_depth()[source]
visit_thead(node)[source]
depart_thead(node)[source]
visit_title(node)[source]

Append section and other titles.

depart_title(node)[source]
visit_contents(node)[source]

Write the table of contents.

Called from visit_topic() for “contents” topics.

visit_topic(node)[source]
depart_topic(node)[source]
visit_transition(node)[source]
depart_transition(node)[source]
visit_version(node)[source]
depart_version(node)[source]
unimplemented_visit(node)[source]