class LatexFormatter(Formatter):
Format tokens as LaTeX code. This needs the fancyvrb
and color
standard packages.
Without the full
option, code is formatted as one Verbatim
environment, like this:
\begin{Verbatim}[commandchars=\\\{\}] \PY{k}{def }\PY{n+nf}{foo}(\PY{n}{bar}): \PY{k}{pass} \end{Verbatim}
The special command used here (\PY) and all the other macros it needs
are output by the get_style_defs
method.
With the full
option, a complete LaTeX document is output, including
the command definitions in the preamble.
The get_style_defs()
method of a LatexFormatter
returns a string
containing \def commands defining the macros needed inside the
Verbatim environments.
Additional options accepted:
style
full
title
full
is true, the title that should be used to caption the
document (default: '').docclass
full
option is enabled, this is the document class to use
(default: 'article').preamble
full
option is enabled, this can be further preamble commands,
e.g. \usepackage (default: '').linenos
linenostart
linenostep
verboptions
commandprefix
The LaTeX commands used to produce colored output are constructed using this prefix and some letters (default: 'PY').
texcomments
If set to True, enables LaTeX comment lines. That is, LaTex markup in comment tokens is not escaped so that LaTeX can render it (default: False).
mathescape
If set to True, enables LaTeX math mode escape in comments. That is, '$...$' inside a comment will trigger math mode (default: False).
escapeinside
If set to a string of length 2, enables escaping to LaTeX. Text
delimited by these 2 characters is read as LaTeX code and
typeset accordingly. It has no effect in string literals. It has
no effect in comments if texcomments
or mathescape
is
set. (default: '').
envname
Allows you to pick an alternative environment name replacing Verbatim. The alternate environment still has to support Verbatim's option syntax. (default: 'Verbatim').
Method | __init__ |
Undocumented |
Method | _create_stylesheet |
Undocumented |
Method | format_unencoded |
Undocumented |
Method | get_style_defs |
Return the command sequences needed to define the commands used to format text in the verbatim environment. arg is ignored. |
Class Variable | aliases |
Undocumented |
Class Variable | filenames |
Undocumented |
Class Variable | name |
Undocumented |
Instance Variable | cmd2def |
Undocumented |
Instance Variable | commandprefix |
Undocumented |
Instance Variable | docclass |
Undocumented |
Instance Variable | envname |
Undocumented |
Instance Variable | escapeinside |
Undocumented |
Instance Variable | left |
Undocumented |
Instance Variable | linenos |
Undocumented |
Instance Variable | linenostart |
Undocumented |
Instance Variable | linenostep |
Undocumented |
Instance Variable | mathescape |
Undocumented |
Instance Variable | nobackground |
Undocumented |
Instance Variable | preamble |
Undocumented |
Instance Variable | right |
Undocumented |
Instance Variable | texcomments |
Undocumented |
Instance Variable | ttype2name |
Undocumented |
Instance Variable | verboptions |
Undocumented |
Inherited from Formatter
:
Method | format |
Format tokensource, an iterable of (tokentype, tokenstring) tuples and write it into outfile. |
Class Variable | unicodeoutput |
Undocumented |
Instance Variable | encoding |
Undocumented |
Instance Variable | full |
Undocumented |
Instance Variable | options |
Undocumented |
Instance Variable | style |
Undocumented |
Instance Variable | title |
Undocumented |