mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix the caption of figure is always put on center even if `:align:
` was specified
This commit is contained in:
parent
4789ef899f
commit
885653a35d
1
CHANGES
1
CHANGES
@ -50,6 +50,7 @@ Bugs fixed
|
||||
* #2483: any figure number was not assigned if figure title contains only non text objects
|
||||
* #2501: Unicode subscript numbers are normalized in LaTeX
|
||||
* #2492: Figure directive with :figwidth: generates incorrect Latex-code
|
||||
* The caption of figure is always put on center even if ``:align:`` was specified
|
||||
|
||||
|
||||
Release 1.4.1 (released Apr 12, 2016)
|
||||
|
@ -1424,10 +1424,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
isinstance(node.children[0], nodes.image) and
|
||||
node.children[0]['ids']):
|
||||
ids += self.hypertarget(node.children[0]['ids'][0], anchor=False)
|
||||
if 'width' in node and node.get('align', '') in ('left', 'right'):
|
||||
if node.get('align', '') in ('left', 'right'):
|
||||
if 'width' in node:
|
||||
length = width_to_latex_length(node['width'])
|
||||
else:
|
||||
length = '0pt'
|
||||
self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' %
|
||||
(node['align'] == 'right' and 'r' or 'l',
|
||||
width_to_latex_length(node['width'])))
|
||||
(node['align'] == 'right' and 'r' or 'l', length))
|
||||
self.context.append(ids + '\\end{wrapfigure}\n')
|
||||
elif self.in_minipage:
|
||||
if ('align' not in node.attributes or
|
||||
|
@ -235,6 +235,11 @@ Figures
|
||||
|
||||
Description paragraph is wraped with legend node.
|
||||
|
||||
.. figure:: rimg.png
|
||||
:align: right
|
||||
|
||||
figure with align option
|
||||
|
||||
.. figure:: rimg.png
|
||||
:align: right
|
||||
:figwidth: 50%
|
||||
|
@ -31,14 +31,14 @@ http://www.python.org/logo.png
|
||||
reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
|
||||
:encoding: option\\n?
|
||||
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png
|
||||
(%(root)s/markup.txt:368: WARNING: invalid single index entry u'')?
|
||||
(%(root)s/markup.txt:373: WARNING: invalid single index entry u'')?
|
||||
(%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \
|
||||
with "\\?": b?'here: >>>(\\\\|/)xbb<<<'
|
||||
)?"""
|
||||
|
||||
HTML_WARNINGS = ENV_WARNINGS + """\
|
||||
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
|
||||
%(root)s/markup.txt:280: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
%(root)s/markup.txt:285: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
%(root)s/footnote.txt:60: WARNING: citation not found: missing
|
||||
%(root)s/markup.txt:164: WARNING: unknown option: &option
|
||||
"""
|
||||
|
@ -27,7 +27,7 @@ LATEX_WARNINGS = ENV_WARNINGS + """\
|
||||
%(root)s/markup.txt:164: WARNING: unknown option: &option
|
||||
%(root)s/footnote.txt:60: WARNING: citation not found: missing
|
||||
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
|
||||
%(root)s/markup.txt:280: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
%(root)s/markup.txt:285: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
"""
|
||||
|
||||
if PY3:
|
||||
@ -111,9 +111,13 @@ def test_writer(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
||||
|
||||
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
|
||||
'\\includegraphics{{rimg}.png}\n\\caption{figure with align option}'
|
||||
'\\label{markup:id7}\\end{wrapfigure}' in result)
|
||||
|
||||
assert ('\\begin{wrapfigure}{r}{0.500\\linewidth}\n\\centering\n'
|
||||
'\\includegraphics{{rimg}.png}\n\\caption{figure with align \\& figwidth option}'
|
||||
'\\label{markup:id7}\\end{wrapfigure}' in result)
|
||||
'\\label{markup:id8}\\end{wrapfigure}' in result)
|
||||
|
||||
|
||||
@with_app(buildername='latex', freshenv=True, # use freshenv to check warnings
|
||||
|
Loading…
Reference in New Issue
Block a user