From 0725274b5e1bbe33c2e4273b249822e57c99f57d Mon Sep 17 00:00:00 2001 From: Ernesto Revilla Date: Thu, 20 Feb 2014 18:03:34 +0100 Subject: Allow alternative float options for figure. See #1. no-pep8 --- doc/config.rst | 6 ++++++ sphinx/quickstart.py | 3 +++ sphinx/writers/latex.py | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/config.rst b/doc/config.rst index 1b196abb..f6826995 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1099,6 +1099,12 @@ These options influence LaTeX output. "Rejne". You can also set this to ``''`` to disable fncychap. ``'preamble'`` Additional preamble content, default empty. + ``'figure_align'`` + Latex figure float alignment, default 'htbp' (here, top, bottom, page). + Whenever an image doesn't fit into the current page, it wil be + 'floated' into the next page but may be preceeded 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. ``'footer'`` Additional footer content (before the indices), default empty. diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index a57006fd..8a9fe479 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -236,6 +236,9 @@ latex_elements = { # Additional stuff for the LaTeX preamble. #'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 1c915431..a1c4afe1 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -164,6 +164,7 @@ class LaTeXTranslator(nodes.NodeVisitor): 'footer': '', 'printindex': '\\printindex', 'transition': '\n\n\\bigskip\\hrule{}\\bigskip\n\n', + 'figure_align': 'htbp', } # sphinx specific document classes @@ -1005,7 +1006,8 @@ class LaTeXTranslator(nodes.NodeVisitor): # TODO non vertical space for other alignments. align = '\\begin{flush%s}' % node.attributes['align'] align_end = '\\end{flush%s}' % node.attributes['align'] - self.body.append('\\begin{figure}[htbp]%s\n' % align) + self.body.append('\\begin{figure}[%s]%s\n' % ( + self.elements['figure_align'], align)) if any(isinstance(child, nodes.caption) for child in node): self.body.append('\\capstart\n') self.context.append(ids + align_end + '\\end{figure}\n') -- cgit v1.2.1