Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx to Latex Figure Placement

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?

like image 208
Alex Avatar asked Jun 18 '14 12:06

Alex


1 Answers

When modifying conf.py you may have forgot the comma after the 'H'.

Latex figure (float) alignment

'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.

like image 140
zerocog Avatar answered Oct 18 '22 20:10

zerocog