Skip to content

Commit e6bf914

Browse files
authored
Merge pull request sphinx-doc#8769 from jfbu/refactor_latex_into_multiple_files
Refactor latex into multiple files
2 parents c9480f9 + b259485 commit e6bf914

21 files changed

+2015
-1858
lines changed

CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Incompatible changes
3636
cross-references
3737
* #4550: The ``align`` attribute of ``figure`` and ``table`` nodes becomes
3838
``None`` by default instead of ``'default'``
39+
* #8769: LaTeX refactoring: split sphinx.sty into multiple files and rename
40+
some auxiliary files created in ``latex`` build output repertory
3941

4042
Deprecated
4143
----------

doc/latex.rst

+30-3
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,36 @@ macros may be significant.
830830
LaTeX macros and environments
831831
-----------------------------
832832

833-
Here are some macros from the package file :file:`sphinx.sty` and class files
834-
:file:`sphinxhowto.cls`, :file:`sphinxmanual.cls`, which have public names
835-
thus allowing redefinitions. Check the respective files for the defaults.
833+
The "LaTeX package" file :file:`sphinx.sty` loads various components
834+
providing support macros (aka commands), and environments, which are used in
835+
the mark-up produced on output from the ``latex`` builder, before conversion
836+
to ``pdf`` via the LaTeX toolchain. Also the "LaTeX class" files
837+
:file:`sphinxhowto.cls` and :file:`sphinxmanual.cls` define or customize some
838+
environments. All of these files can be found in the latex build repertory.
839+
840+
Some of these provide facilities not available from pre-existing LaTeX
841+
packages and work around LaTeX limitations with lists, table cells, verbatim
842+
rendering, footnotes, etc...
843+
844+
Others simply define macros with public names to make overwriting their
845+
defaults easy via user-added contents to the preamble. We will survey most of
846+
those public names here, but defaults have to be looked at in their respective
847+
definition files.
848+
849+
.. hint::
850+
851+
Sphinx LaTeX support code is split across multiple smaller-sized files.
852+
Rather than adding code to the preamble via
853+
`latex_elements <latex_elements_confval_>`_\ [``'preamble'``] it is
854+
also possible to replace entirely one of the component files of Sphinx
855+
LaTeX code with a custom version, simply by including a modified copy in
856+
the project source and adding the filename to the
857+
:confval:`latex_additional_files` list. Check the LaTeX build repertory
858+
for the filenames and contents.
859+
860+
.. versionchanged:: 4.0.0
861+
split of :file:`sphinx.sty` into multiple smaller units, to facilitate
862+
customization of many aspects simultaneously.
836863

837864
.. _latex-macros:
838865

sphinx/builders/latex/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,12 @@ def init_multilingual(self) -> None:
216216
if not self.babel.uses_cyrillic():
217217
if 'X2' in self.context['fontenc']:
218218
self.context['substitutefont'] = '\\usepackage{substitutefont}'
219-
self.context['textcyrillic'] = '\\usepackage[Xtwo]{sphinxcyrillic}'
219+
self.context['textcyrillic'] = ('\\usepackage[Xtwo]'
220+
'{sphinxpackagecyrillic}')
220221
elif 'T2A' in self.context['fontenc']:
221222
self.context['substitutefont'] = '\\usepackage{substitutefont}'
222-
self.context['textcyrillic'] = '\\usepackage[TtwoA]{sphinxcyrillic}'
223+
self.context['textcyrillic'] = ('\\usepackage[TtwoA]'
224+
'{sphinxpackagecyrillic}')
223225
if 'LGR' in self.context['fontenc']:
224226
self.context['substitutefont'] = '\\usepackage{substitutefont}'
225227
else:

0 commit comments

Comments
 (0)