Hi

Le 09/05/2018 à 11:13, Julian Meier a écrit :
Dear Sphinx Team,

Thank you for providing sphinx.

I am tring to get our latex class and sphinx conf work with sphinx 1.7
instead of sphinx 1.5.

I am almost there, but the latex_elements = {... 'preamble' gets larger and
larger because I am not succeeding in defining the titleformats (color and
font) in our custum latex class - it seems to get overruled by sphinx.

An example of a defined title is (extract from latex preamble in sphinx
conf):
'\\titleformat{{\\subsection}}{{\\fontsize{{14}}{{20}}\\fontspec{{MyriadPro-Bold}}\\addfontfeature{{Color=Pantone123C}}}}{{\\thesubsection}}{{0.5em}}{{}}\n'
'\\titlespacing{{\\subsection}}{{-32mm}}{{*4}}{{-0.3mm}}\n'

Now, to my question.

Which is the recommended way to define custom titles, headers and footers?

- Definition in custom class file using correct statements (there I got
some problems)
- Definition in the sphinx conf.py latex_elements preamble as 'pure' latex
- Definition in the sphinx conf.py using 'sphinxsetup'

I hope i provided all the necessary details for you to make a
recommandation.

Many thanks,

Julian



1. Things done from sphinx style file
will override things done in a custom class
file. The class file is loaded first by LaTeX and
`\usepackage{sphinx}` gets executed later.

2. The 'sphinxsetup' is only interface to some customization handled
by the options of sphinx.sty, e.g. to modify the page margins
or the  colours for various elements (everything was hardcoded
in earlier Sphinx releases). You can only customize pre-defined
(and documented) options

http://www.sphinx-doc.org/en/1.7/latex.html#the-latex-style-file-options

3. To do things like custom `titleformat`'s or anything beyond
a few lines, the recommended way (for easier maintenance and to avoid
bloating conf.py)
is to set-up a custom LaTeX package mypackage.sty and then
use latex_elements
'preamble' key to contain `r'\usepackage{mypackage}'`. You will also need
to add 'mypackage.sty' to the latex_additional_files config value, if
file mypackage.sty is not installed globally in your TeX installation,
but only present at top of source repertory of your Sphinx project.
It will then be copied over to build repertory.

cf http://www.sphinx-doc.org/en/1.7/latex.html#basic-customization

A file mypackage.sty  is simply a collection of tex macros with
an extra `\ProvidesPackage{mypackage}[2018/05/09 v1 my own macros]` line
at top. The @ letter can be used in it. To load more packages from therein
use `\RequirePackage{foo}`, not `\usepackage{foo}`.

Alternative is to put all macros in a file mymacros.tex.txt,
update latex_additional_files accordingly and add
`r'''
\makeatletter
\input{mymacros.tex.txt}
\makeatother'''`
to 'preamble' key of latex_elements. The `.txt` extension is to
avoid confusing the LaTeX Makefile, it does not cause problem
to `\input`. The `\makeatletter/\makeatother` is in case "@" letter
is used in the macros included mymacros.tex.txt

In both cases: don't double escape
the backslashes inside the files as they get parsed by LaTeX directly
with no Python in-between.

Jean-François

--
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to