#96: The LaTeX builder now supports figures wrapped by text, when using the `figwidth` option and right/left alignment.

This commit is contained in:
Georg Brandl 2009-02-21 20:28:20 +01:00
parent 18c3748c98
commit edaf639c2c
4 changed files with 36 additions and 10 deletions

View File

@ -120,6 +120,9 @@ New features added
- The new ``html_link_suffix`` config value can be used to select
the suffix of generated links between HTML files.
- #96: The LaTeX builder now supports figures wrapped by text, when
using the ``figwidth`` option and right/left alignment.
* New translations:
- Italian by Sandro Dentella.

View File

@ -9,6 +9,19 @@
:license: BSD, see LICENSE for details.
"""
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives import images
# import and register directives
from sphinx.directives.desc import *
from sphinx.directives.code import *
from sphinx.directives.other import *
# allow units for the figure's "figwidth"
try:
images.Figure.option_spec['figwidth'] = \
directives.length_or_percentage_or_unitless
except AttributeError:
images.figure.options['figwidth'] = \
directives.length_or_percentage_or_unitless

View File

@ -17,11 +17,15 @@
\RequirePackage{makeidx}
\RequirePackage{framed}
\RequirePackage{color}
% For highlighted code.
\RequirePackage{fancyvrb}
% For table captions.
\RequirePackage{threeparttable}
% Handle footnotes in tables.
\RequirePackage{footnote}
\makesavenoteenv{tabulary}
% For floating figures in the text.
\RequirePackage{wrapfig}
% Redefine these colors to your liking in the preamble.
\definecolor{TitleColor}{rgb}{0.126,0.263,0.361}

View File

@ -850,6 +850,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
pass
def visit_figure(self, node):
if node.has_key('width') and node.get('align', '') in ('left', 'right'):
self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' %
(node['align'] == 'right' and 'r' or 'l',
node['width']))
self.context.append('\\end{wrapfigure}\n')
else:
if (not node.attributes.has_key('align') or
node.attributes['align'] == 'center'):
# centering does not add vertical space like center.