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:
3
CHANGES
3
CHANGES
@@ -120,6 +120,9 @@ New features added
|
|||||||
- The new ``html_link_suffix`` config value can be used to select
|
- The new ``html_link_suffix`` config value can be used to select
|
||||||
the suffix of generated links between HTML files.
|
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:
|
* New translations:
|
||||||
|
|
||||||
- Italian by Sandro Dentella.
|
- Italian by Sandro Dentella.
|
||||||
|
|||||||
@@ -9,6 +9,19 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
: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.desc import *
|
||||||
from sphinx.directives.code import *
|
from sphinx.directives.code import *
|
||||||
from sphinx.directives.other 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{makeidx}
|
||||||
\RequirePackage{framed}
|
\RequirePackage{framed}
|
||||||
\RequirePackage{color}
|
\RequirePackage{color}
|
||||||
|
% For highlighted code.
|
||||||
\RequirePackage{fancyvrb}
|
\RequirePackage{fancyvrb}
|
||||||
|
% For table captions.
|
||||||
\RequirePackage{threeparttable}
|
\RequirePackage{threeparttable}
|
||||||
% Handle footnotes in tables.
|
% Handle footnotes in tables.
|
||||||
\RequirePackage{footnote}
|
\RequirePackage{footnote}
|
||||||
\makesavenoteenv{tabulary}
|
\makesavenoteenv{tabulary}
|
||||||
|
% For floating figures in the text.
|
||||||
|
\RequirePackage{wrapfig}
|
||||||
|
|
||||||
% Redefine these colors to your liking in the preamble.
|
% Redefine these colors to your liking in the preamble.
|
||||||
\definecolor{TitleColor}{rgb}{0.126,0.263,0.361}
|
\definecolor{TitleColor}{rgb}{0.126,0.263,0.361}
|
||||||
|
|||||||
@@ -850,6 +850,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_figure(self, node):
|
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
|
if (not node.attributes.has_key('align') or
|
||||||
node.attributes['align'] == 'center'):
|
node.attributes['align'] == 'center'):
|
||||||
# centering does not add vertical space like center.
|
# centering does not add vertical space like center.
|
||||||
|
|||||||
Reference in New Issue
Block a user