I'm trying to used Sphinx to generate a manual in latex and HTML, but I'm having issues with the figure placement within latex. In Sphinx my figures are as follows:
.. figure:: _images/somepicture.png
:figwidth: 100 %
:width: 100 %
:align: center
some caption
So that when it writes to HTML, the figures span the whole width of the page. This works fine.
The trouble comes in latex, where a typical figure in latex writes as:
\begin{figure}[htbp]
\centering
\includegraphics[width=1.000\linewidth]{reset.png}
\end{figure}
The trouble is the [htbp] placement option. Since the images are \linewidth in length, they are very large and end up floating to the next page, and any often the order of text and figures in the document is not preserved in the the pdf output. I want to change [htbp] to [H].
I found an option to put into the conf.py file under latex elements section called 'figure_align', but when I use it, it doesn't work. The link is here http://sphinx.readthedocs.org/en/latest/config.html#options-for-latex-output
in my conf.py document, I have the following:
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble':'',
#Figure placement within LaTeX paper NOT WORKING
'figure_align': 'H'
}
My question is, why isn't this option working and what can I do to make it work?
When modifying conf.py you may have forgot the comma after the 'H'.
'figure_align': 'H',
Works for me on sphinx-doc version 1.4.6.
'figure_align'
Latex figure float alignment, default ‘htbp’ (here, top, bottom, page). Whenever an image doesn’t fit into the current page, it will be ‘floated’ into the next page but may be preceded by any other text. If you don’t like this behavior, use ‘H’ which will disable floating and position figures strictly in the order they appear in the source. Reference Sphinx-doc latex_element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With