mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
latex `\noindent
` for non-inline images, not only if top level
This commit is contained in:
@@ -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'])
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user