mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#96: The LaTeX builder now supports figures wrapped by text, when using the `figwidth
` option and right/left alignment.
This commit is contained in:
parent
18c3748c98
commit
edaf639c2c
3
CHANGES
3
CHANGES
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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}
|
||||
|
@ -850,17 +850,23 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
pass
|
||||
|
||||
def visit_figure(self, node):
|
||||
if (not node.attributes.has_key('align') or
|
||||
node.attributes['align'] == 'center'):
|
||||
# centering does not add vertical space like center.
|
||||
align = '\n\\centering'
|
||||
align_end = ''
|
||||
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:
|
||||
# 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.context.append('%s\\end{figure}\n' % align_end)
|
||||
if (not node.attributes.has_key('align') or
|
||||
node.attributes['align'] == 'center'):
|
||||
# centering does not add vertical space like center.
|
||||
align = '\n\\centering'
|
||||
align_end = ''
|
||||
else:
|
||||
# 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.context.append('%s\\end{figure}\n' % align_end)
|
||||
def depart_figure(self, node):
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user