How to pass a custom variable from sphinx conf file into a latex document
543 views
Skip to first unread message
Pieter Claeys
unread,
Jun 21, 2019, 5:06:30 AM6/21/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sphinx-users
I would need to extend / modify the default latex generated document with a few extra variable fields (reason: I need to easily generate a few variations of a document with different title pages).
I already figured out to use latex_maketitle where I can define some custom latex code.
However, if I would want a 'favoritecolor' variable somewhere in the conf.py file; and use that in the latex code to display 'favoritecolor' on the title screen: How should I do that? I am newbie in latex code.
As an extra bonus, I would even like to set 'favoritecolor' at command-line and pass that to sphinx . But I seems you can only override a specific number of sphinx parameters (like project, release) using the -D argument. Any other ways to achieve my usecase?
Komiya Takeshi
unread,
Jun 22, 2019, 7:33:22 AM6/22/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sphinx...@googlegroups.com
Hi,
AFAIK, there are no proper way to do that via configurations. I think
you need to create your own Sphinx extension and modify LaTeX macros
from it.
Both custom variable in conf.py and `-D` argument for sphinx-build
command are need to add new config value.
And then you'll modify latex_maketitle configuration on config-inited
event (it is happened after initialization of configurations).