Merged in erny1803/sphinx (pull request #227)

Latex: Allow alternative float options for figures
This commit is contained in:
Georg Brandl committed 2014-03-01 08:56:53 +01:00
commit 0312edd266
3 files changed
+12 -1

No files matched your search

+6
View File
@@ -1117,6 +1117,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.
+3
View File
@@ -246,6 +246,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
Executable → Regular
+3 -1
View File
@@ -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
@@ -1006,7 +1007,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')