mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
update latex.rst (`LaTeX customization
` chapter in the docs)
This commit is contained in:
parent
cb74df621c
commit
613b80d3ed
@ -11,45 +11,71 @@ LaTeX customization
|
|||||||
The *latex* target does not (yet) benefit from pre-prepared themes like the
|
The *latex* target does not (yet) benefit from pre-prepared themes like the
|
||||||
*html* target does (see :doc:`theming`).
|
*html* target does (see :doc:`theming`).
|
||||||
|
|
||||||
There are two principal means of setting up customization:
|
Basic customization is available from ``conf.py`` via usage of the
|
||||||
|
:ref:`latex-options` as described in :doc:`config`. For example::
|
||||||
|
|
||||||
#. usage of the :ref:`latex-options` as described in :doc:`config`, particularly the
|
# inside conf.py
|
||||||
various keys of :confval:`latex_elements`, to modify the loaded packages,
|
latex_engine = 'xelatex'
|
||||||
for example::
|
latex_elements = {
|
||||||
|
'fontenc': '\\usepackage{fontspec}',
|
||||||
|
'fontpkg': '''\
|
||||||
|
\\setmainfont{DejaVu Serif}
|
||||||
|
\\setsansfont{DejaVu Sans}
|
||||||
|
\\setmonofont{DejaVu Sans Mono}''',
|
||||||
|
'geometry': '\\usepackage[vmargin=2.5cm, hmargin=3cm]{geometry}',
|
||||||
|
'preamble': '''\
|
||||||
|
\\usepackage[titles]{tocloft}
|
||||||
|
\\cftsetpnumwidth {1.25cm}\\cftsetrmarg{1.5cm}
|
||||||
|
\\setlength{\cftchapnumwidth}{0.75cm}
|
||||||
|
\\setlength{\cftsecindent}{\\cftchapnumwidth}
|
||||||
|
\\setlength{\cftsecnumwidth}{1.25cm}''',
|
||||||
|
'fncychap': '\\usepackage[Bjornstrup]{fncychap}',
|
||||||
|
'printindex': '\\footnotesize\\raggedright\\printindex',
|
||||||
|
}
|
||||||
|
latex_show_urls = 'footnote'
|
||||||
|
|
||||||
'fontpkg': '\\usepackage{times}', # can load other font
|
.. the above was tested on Sphinx's own 1.5a2 documentation with good effect !
|
||||||
'fncychap': '\\usepackage[Bjarne]{fncychap}', # can use other option
|
|
||||||
|
|
||||||
.. tip::
|
More advanced customization will be obtained via insertion into the LaTeX
|
||||||
|
preamble of relevant ``\renewcommand``, ``\renewenvironment``, ``\setlength``,
|
||||||
|
or ``\definecolor`` commands. The ``'preamble'`` key of
|
||||||
|
:confval:`latex_elements` will serve for inserting these commands. If they are
|
||||||
|
numerous, it may prove more convenient to assemble them into a specialized
|
||||||
|
file :file:`mycustomizedmacros.tex` and then use::
|
||||||
|
|
||||||
It is not mandatory to load *fncychap*. Naturally, without it and in
|
'preamble': '\\makeatletter\\input{mycustomizedmacros.tex}\\makeatother',
|
||||||
absence of further customizations, the chapter headings will revert to
|
|
||||||
LaTeX's default for the *report* class.
|
|
||||||
|
|
||||||
#. usage of LaTeX ``\renewcommand``, ``\renewenvironment``, ``\setlength``,
|
More advanced LaTeX users will set up a style file
|
||||||
``\definecolor`` to modify the defaults from package file :file:`sphinx.sty`
|
:file:`mycustomizedmacros.sty`, which can then be loaded via::
|
||||||
and class files :file:`sphinxhowto.cls` and :file:`sphinxmanual.cls`. If such
|
|
||||||
definitions are few, they can be located inside the ``'preamble'`` key of
|
|
||||||
:confval:`latex_elements`. In case of many it may prove more convenient to
|
|
||||||
assemble them into a specialized file :file:`customizedmacros.tex` and use::
|
|
||||||
|
|
||||||
'preamble': '\\makeatletter\\input{customizedmacros.tex}\\makeatother',
|
'preamble': '\\usepackage{mycustomizedmacros}',
|
||||||
|
|
||||||
More advanced LaTeX users will set up a style file
|
The :ref:`build configuration file <build-config>` file for the project needs
|
||||||
:file:`customizedmacros.sty`, which can then be loaded via::
|
to have its variable :confval:`latex_additional_files` appropriately
|
||||||
|
configured, for example::
|
||||||
|
|
||||||
'preamble': '\\usepackage{customizedmacros}',
|
latex_additional_files = ["customizedmacros.sty"]
|
||||||
|
|
||||||
The :ref:`build configuration file <build-config>` file will then have its variable
|
Such *LaTeX Sphinx theme* files could possibly be contributed in the
|
||||||
:confval:`latex_additional_files` appropriately configured, for example::
|
future by advanced users for wider use.
|
||||||
|
|
||||||
latex_additional_files = ["customizedmacros.sty"]
|
Let us list here some examples of macros, lengths, colors, which are inherited
|
||||||
|
from package file :file:`sphinx.sty` and class file :file:`sphinxhowto.cls` or
|
||||||
|
:file:`sphinxmanual.cls`, and can be customized.
|
||||||
|
|
||||||
Such *LaTeX Sphinx theme* files could possibly be contributed in the
|
- the table of contents is typeset via ``\sphinxtableofcontents`` which is a
|
||||||
future by advanced users for wider use.
|
wrapper (whose definition can be found in :file:`sphinxhowto.cls` or in
|
||||||
|
:file:`sphinxmanual.cls`) of standard ``\tableofcontents``.
|
||||||
|
|
||||||
Let us illustrate here what can be modified by the second method.
|
.. versionchanged:: 1.5
|
||||||
|
formerly, the meaning of ``\tableofcontents`` was modified by Sphinx.
|
||||||
|
- the bibliography and Python Module index are typeset respectively within
|
||||||
|
environments ``sphinxthebibliography`` and ``sphinxtheindex``, which are
|
||||||
|
simple wrappers of the non-modified ``thebibliography`` and ``theindex``
|
||||||
|
environments.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.5
|
||||||
|
formerly, the original environments were modified by Sphinx.
|
||||||
- text styling commands (they have one argument): ``\sphinx<foo>`` with
|
- text styling commands (they have one argument): ``\sphinx<foo>`` with
|
||||||
``<foo>`` being one of ``strong``, ``bfcode``, ``email``, ``tablecontinued``,
|
``<foo>`` being one of ``strong``, ``bfcode``, ``email``, ``tablecontinued``,
|
||||||
``titleref``, ``menuselection``, ``accelerator``, ``crossref``, ``termref``,
|
``titleref``, ``menuselection``, ``accelerator``, ``crossref``, ``termref``,
|
||||||
@ -128,8 +154,10 @@ Let us illustrate here what can be modified by the second method.
|
|||||||
|
|
||||||
.. versionadded:: 1.5
|
.. versionadded:: 1.5
|
||||||
formerly, the use of ``\small`` for code listings was not customizable.
|
formerly, the use of ``\small`` for code listings was not customizable.
|
||||||
- miscellaneous colours: *TitleColor*, *InnerLinkColor*, *OuterLinkColor*,
|
- miscellaneous colours: *InnerLinkColor*, *OuterLinkColor* (used in
|
||||||
*VerbatimColor* (this is a background colour), *VerbatimBorderColor*.
|
``hyperref`` options), *TitleColor* (used for titles via ``titlesec``),
|
||||||
|
*VerbatimColor* (background colour) and *VerbatimBorderColor* (used for
|
||||||
|
code-blocks).
|
||||||
- the ``\sphinxAtStartFootnote`` is inserted between footnote numbers and their
|
- the ``\sphinxAtStartFootnote`` is inserted between footnote numbers and their
|
||||||
texts, by default it does ``\mbox{ }``.
|
texts, by default it does ``\mbox{ }``.
|
||||||
- use ``\sphinxSetHeaderFamily`` to set the font used by headings
|
- use ``\sphinxSetHeaderFamily`` to set the font used by headings
|
||||||
@ -140,8 +168,8 @@ Let us illustrate here what can be modified by the second method.
|
|||||||
``\titleformat`` command.
|
``\titleformat`` command.
|
||||||
- for the ``'manual'`` class, the chapter headings can be customized using
|
- for the ``'manual'`` class, the chapter headings can be customized using
|
||||||
*fncychap*'s commands ``\ChNameVar``, ``\ChNumVar``, ``\ChTitleVar``. Or, if
|
*fncychap*'s commands ``\ChNameVar``, ``\ChNumVar``, ``\ChTitleVar``. Or, if
|
||||||
the loading of this package has been removed from ``'fncychap'`` key, one can
|
the loading of this package has been removed via emptying the ``'fncychap'``
|
||||||
use the *titlesec* ``\titleformat`` command.
|
key, one can use the *titlesec* ``\titleformat`` command.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user