latex `\noindent` for non-inline images, not only if top level

This commit is contained in:
jfbu
2016-06-19 11:02:39 +02:00
parent 664e24cf86
commit beeeb56c27
2 changed files with 15 additions and 16 deletions

View File

@@ -1408,12 +1408,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
except KeyError:
pass
if not is_inline:
if isinstance(node.parent, nodes.section):
pre.append('\n\\noindent')
post.append('\n')
else:
pre.append('\n')
post.append('\n')
pre.append('\n\\noindent')
post.append('\n')
pre.reverse()
if node['uri'] in self.builder.images:
uri = self.builder.images[node['uri']]
@@ -1456,7 +1452,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('\\begin{sphinxfigure-in-table}\n\\centering\n')
if any(isinstance(child, nodes.caption) for child in node):
self.body.append('\\capstart')
self.context.append(ids + '\\end{sphinxfigure-in-table}\n')
self.context.append(ids + '\\end{sphinxfigure-in-table}\\relax\n')
elif node.get('align', '') in ('left', 'right'):
if 'width' in node:
length = width_to_latex_length(node['width'])

View File

@@ -113,21 +113,24 @@ def test_writer(app, status, warning):
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
assert ('\\begin{sphinxfigure-in-table}\n\\centering\n\\capstart\n'
'\\sphinxincludegraphics{{img}.png}\n\\sphinxfigcaption'
'{figure in table}\\label{markup:id7}\\end{sphinxfigure-in-table}' in result)
'\\noindent\\sphinxincludegraphics{{img}.png}\n'
'\\sphinxfigcaption{figure in table}\\label{markup:id7}'
'\\end{sphinxfigure-in-table}\\relax' in result)
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
'\\sphinxincludegraphics{{rimg}.png}\n\\caption{figure with align option}'
'\\label{markup:id8}\\end{wrapfigure}' in result)
'\\noindent\\sphinxincludegraphics{{rimg}.png}\n'
'\\caption{figure with align option}\\label{markup:id8}'
'\\end{wrapfigure}' in result)
assert ('\\begin{wrapfigure}{r}{0.500\\linewidth}\n\\centering\n'
'\\sphinxincludegraphics{{rimg}.png}\n\\caption{figure with align \\& figwidth option}'
'\\label{markup:id9}\\end{wrapfigure}' in result)
'\\noindent\\sphinxincludegraphics{{rimg}.png}\n'
'\\caption{figure with align \\& figwidth option}\\label{markup:id9}'
'\\end{wrapfigure}' in result)
assert ('\\begin{wrapfigure}{r}{3cm}\n\\centering\n'
'\\sphinxincludegraphics[width=3cm]{{rimg}.png}\n'
'\\caption{figure with align \\& width option}'
'\\label{markup:id10}\\end{wrapfigure}' in result)
'\\noindent\\sphinxincludegraphics[width=3cm]{{rimg}.png}\n'
'\\caption{figure with align \\& width option}\\label{markup:id10}'
'\\end{wrapfigure}' in result)
@with_app(buildername='latex', freshenv=True, # use freshenv to check warnings