Unlike the HTML builders, the latex builder does notbenefit from prepared themes. The Options for LaTeX output, and particularly thelatex_elements variable, provides much of theinterface for customization. For example:
A dictionary that contains LaTeX snippets overriding those Sphinx usually putsinto the generated .tex files. Its 'sphinxsetup' key is describedseparately. It allows also local configurationsinserted in generated files, via raw directives. For example, inthe PDF documentation this chapter is styled especially, as will be describedlater.
With XeLaTeX and LuaLaTeX, Sphinx configures the LaTeX document to usepolyglossia, but one should be aware that current babel hasimproved its support for Unicode engines in recent years and for somelanguages it may make sense to prefer babel over polyglossia.
The default font setting has changed: it still uses Times andHelvetica clones for serif and sans serif, but via better, morecomplete TeX fonts and associated LaTeX packages. Themonospace font has been changed to better match the Times clone.
LaTeX allows by default at most 6 levels for nesting list andquote-like environments, with at most 4 enumerated lists, and 4 bulletlists. Setting this key for example to '10' (as a string) willallow up to 10 nested levels (of all sorts). Leaving it to the emptystring means to obey the LaTeX default.
If using utf8x in place of utf8 it is mandatory to extend theLaTeX preamble with suitable \PreloadUnicodePage commands,as per the utf8x documentation (texdoc ucs on a TeXLive basedTeX installation). Else, unexpected and possibly hard-to-spot problems(i.e. not causing a build crash) may arise in the PDF, in particularregarding hyperlinks.
Even if these precautions are taken, PDF build via pdflatex enginemay crash due to upstream LaTeX not being fully compatible withutf8x. For example, in certain circumstances related tocode-blocks, or attempting to include images whose filenames containUnicode characters. Indeed, starting in 2015, upstream LaTeX withpdflatex engine has somewhat enhanced native support for Unicode andis becoming more and more incompatible with utf8x. In particular,since the October 2019 LaTeX release, filenames can use Unicodecharacters, and even spaces. At Sphinx level this means e.g. that theimage and figure directives are now compatible withsuch filenames for PDF via LaTeX output. But this is broken ifutf8x is in use.
The TeX installation may need some extra packages. For example,on Ubuntu xenial, packages texlive-lang-greek and cm-superare needed for LGR to work. And texlive-lang-cyrillic andcm-super are needed for support of Cyrillic.
Changed in version 2.3.0: 'xelatex' executes\defaultfontfeatures[\rmfamily,\sffamily] in order to avoidcontractions of -- into en-dash or transforms of straight quotesinto curly ones in PDF (in non-literal text paragraphs) despitesmartquotes being set to False.
Ignored if 'fontenc' was not configured to use LGR or X2 (orT2A). In case 'fontpkg' key is configured for usage with someTeX fonts known to be available in the LGR or X2 encodings, setthis one to be the empty string. Else leave to its default.
It is ignored with 'platex', 'xelatex' or 'lualatex' aslatex_engine and defaults to either the empty string orto '\\usepackagetextalpha' for 'pdflatex' depending onwhether the 'fontenc' key was used with LGR or not. Onlyexpert LaTeX users may want to customize this key.
Changed in version 1.5.3: The location in the LaTeX file has been moved to after\usepackagesphinx and \sphinxsetup.., hence also afterinsertion of 'fontpkg' key. This is in order to handle the paperlayout options in a special way for Japanese documents: the textwidth will be set to an integer multiple of the zenkaku width, andthe text height to an integer multiple of the baseline. See thehmargin documentation for more.
The default value is '\\fvsetfontsize=auto' which means that thefont size will adjust correctly if a code-block ends up in a footnote.You may need to modify this if you use custom fonts:'\\fvsetfontsize=\\small' if the monospace font is Courier-like.
LaTeX syntax for boolean keys requires lowercase true or falsee.g 'sphinxsetup': "verbatimwrapslines=false". If setting aboolean key to true, =true is optional.Spaces around the commas and equal signs are ignored, spaces inside LaTeXmacros may be significant.Do not use ticks/quotes to enclose string or numerical values.
This is the technique which has been used to style especially the present partof the documentation for the PDF output. The actually used options will befound at top of doc/latex.rst at the development repository.
Controls the depth of the collapsible bookmarks panel in the PDF.May be either a number (e.g. 3) or a LaTeX sectioning name (e.g.subsubsection, i.e. without backslash).For details, refer to the hyperref LaTeX docs.
Japanese documents currently accept only the one-dimension format forthese parameters. The geometry package is then passed suitable optionsto get the text width set to an exact multiple of the zenkaku width, andthe text height set to an integer multiple of the baselineskip, with theclosest fit for the margins.
If true, line breaks may happen at spaces (the last space before theline break will be rendered using a special symbol), and at ASCIIpunctuation characters (i.e. not at letters or digits). Whenever a longstring has no break points, it is moved to next line. If its length islonger than the line width it will overflow.
A number. If an unbreakable long string has length larger than the totallinewidth plus this number of characters, and if verbatimforcewrapsmode is on, the input line will be reset using the forceful algorithmwhich applies breakpoints at each character.
A number. If verbatimforcewraps mode applies, and if after applyingthe line wrapping at spaces and punctuation, the first part of the splitline is lacking at least that number of characters to fill the availablewidth, then the input line will be reset using the forceful algorithm.
As the default is set to a high value, the forceful algorithm is triggeredonly in overfull case, i.e. in presence of a string longer than fulllinewidth. Set this to 0 to force all input lines to be hard wrappedat the current available linewidth:
Boolean to specify if line breaks are allowed inside inline literals: butextra potential break-points (additionally to those allowed by LaTeX atspaces or for hyphenation) are currently inserted only after the characters. , ; ? ! / and \. Due to TeX internals, white space in the linewill be stretched (or shrunk) in order to accommodate the linebreak.
Changed in version 1.5: The breaking of long code lines was added at 1.4.2. The defaultdefinition of the continuation symbol was changed at 1.5 to accommodatevarious font sizes (e.g. code-blocks can be in footnotes).
As for the other 'sphinxsetup' keys, it can also be set or modifiedfrom a \sphinxsetup... LaTeX command inserted via the rawdirective, or also from a LaTeX environment associated to a containerclass and using such \sphinxsetup....
Sets the background color for odd rows in tables (the row count starts at1 at the first non-header row). Has an effect only if thelatex_table_style contains 'colorrows' or for specifictables assigned the colorrows class.
Added in version 6.2.0: To be considered experimental until 7.0.0. These options have aliasesdiv.note_TeXcolor (etc) described in Additional CSS-like 'sphinxsetup' keys. Usingthe latter will let Sphinx switch to a more complex LaTeX code,which supports the customizability described in Additional CSS-like 'sphinxsetup' keys.
Further, all admonition titles are by default styled using a colored rowand an icon, which are modeled on the current rendering of Sphinx owndocs at -doc.org. CSS-named alike keys are added toset the foreground and background colors for the title as well as theLaTeX code for the icon.
Perhaps in future these 5.1.0 (and 6.2.0) novel settings will be optionallyimported from some genuine CSS external file, but currently they have to be usedvia the 'sphinxsetup' interface (or the \sphinxsetup LaTeX commandinserted via the raw directive) and the CSS syntax is only imitated.
As a rule, avoid inserting unneeded spaces in the key values: especiallyfor the radii an input such 2 pt 3pt will break LaTeX. Beware alsothat \fboxsep \fboxsep will not be seen as space separated in LaTeX.You must use something such as \fboxsep \fboxsep. Or usedirectly 3pt 3pt which is a priori equivalent and simpler.
_box-decoration-break can be set to either clone orslice and configures the behavior at page breaks.It defaults to slice for code-block (i.e. for =pre)since 6.0.0. For other directives the default is clone.
Changed in version 7.4.0: All defaults were changed, except for code-block. Admonitionsare set-up so that left (or right) padding plus left (or right)border-width add up always to 7.5pt, so contents align wellvertically across admonition types on same page in PDF. This is only aproperty of defaults, not a constraint on possible user choices.
The x-offset and y-offset may be negative. The default is none,except for the topic or contents directives, for which it is4pt 4pt, i.e. the shadow has a width of 4pt and extends to the rightand below the frame. The lateral shadow then extends into the page rightmargin.
The only directives displaying a shadow per default are topic andcontents (handled identically at LaTeX level) and their shadow color isHTML6C6C6C. For all others the default shadow color is black.
_TeXextras: if set, its value must be some LaTeX command orcommands, for example \itshape. These commands will be inserted at thestart of the contents; for admonitions, this happens after the heading whichreproduces the admonition type.
The colored title-row is produced as a result of the Sphinx defaultdefinitions for the various \sphinxstyletitle commands, seeMacros. Custom redefinitions of these commands arepossible, but to re-use the colors and the icon, it is needed to check inSphinx LaTeX source code how the default definitions are done.
93ddb68554