To change Latex Output options in sphinx, set the relevant latex_elements
key in the build configuration file, documentation on this is located here.
To change the font size for all fonts use pointsize
.
E.g.
latex_elements = {
'pointsize':'10pt'
}
To change other Latex settings that are listed in the documetntation use preamble
or use a custom document class in latex_documents
.
E.g.
mypreamble='''customlatexstuffgoeshere
'''
latex_elements = {
'papersize':'letterpaper',
'pointsize':'11pt',
'preamble':mypreamble
}
Reading the Sphinx sourcecode by default the code in LatexWriter sets code snippets to the \code
latex primitive.
So what you want to do is replace the \code
with a suitable replacement.
This is done by including a Latex command like \newcommand{\code}[1]{\texttt{\tiny{#1}}}
either as part of the preamble or as part of a custom document class for sphinx that gets set in latex_documents
as the documentclass key. An example sphinx document class is avaliable here.
Other than just making it smaller with \tiny
you can modify the latex_documents
document class or the latex_elements
preamble to use the Latex package listings for more fancy code formatting like in the StackOverflow question here.
The package stuff from the linked post would go as a custom document class and the redefinition similar to \newcommand{\code}[1]{\begin{lstlisting} #1 \end{lstlisting}}
would be part of the preamble.
Alternatively you could write a sphinx extension that extends the default latex writer with a custom latex writer of your choosing though that is significantly more effort.
Other relevant StackOverflow questions include