Reputation: 778
Does the Sphinx documentation tool offer different PDF themes like it offers different HTML themes?
I Googled the issue but can't find an answer, which leads me to believe the answer is 'no'. Still, i thought i'd ask here.
Thanks.
Upvotes: 31
Views: 18321
Reputation: 4295
Firstly, Sphinx doesn't generate PDF output by itself, though there are three general methods to get from Sphinx source files to PDF output:
That being said there is lots of potential for customizing the styling of your PDF output using either method.
Upvotes: 30
Reputation: 7667
There are no predefined themes for PDF output for Sphinx. But LaTex offers a rich set of options to style the document. My problem was to find the proper way to style the document with sphinx. Here the way, which worked for me:
First take a look into the conf.py
. There you'll find an option latex_elements
. With this option you can add your own LaTex commands to the output. For example:
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',
# The font size ('10pt', '11pt' or '12pt').
'pointsize': '12pt',
'fontpkg': r"""
\PassOptionsToPackage{bookmarksnumbered}{hyperref}
""",
# Additional stuff for the LaTeX preamble.
'preamble': r"""
\usepackage{setspace}
""",
'footer': r"""
""",
'maketitle': r'''
\pagenumbering{arabic}
''',
}
There are a few points important to know.
r"""
to avoid conflicts with pythonpreamble
would be the right point to add \usepackage
you can have conflicts with the Sphinx default settings. Look at fontpkg
in the example. It is the first include in the .tex
output document. If you have to set options for default packages, do it here.maketitle
let you define your own title page. See some latex documentation. I set \pagenumbering
there to have the table of contents with arabic numbers, so the real content begins on page "1".With the right knowledge of Latex commands you can get good theming with a few commands. A good source to find help is https://tex.stackexchange.com/ where most common problems have a solution. But finding the proper Latex commands is much more difficult than to choose a theme as done for HTML.
It might be helpful to take a look in the Tex-Output under ./_build
. There you can see, how the latex_elements
-options were included in the document.
Upvotes: 6