Skip to content

Commit

Permalink
Remove some redundant code in LaTeX writer visit_figure
Browse files Browse the repository at this point in the history
	modified:   sphinx/writers/latex.py
  • Loading branch information
jfbu committed May 3, 2017
1 parent 4ffe79c commit f545805
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions sphinx/writers/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,28 +1554,14 @@ def visit_figure(self, node):
(node['align'] == 'right' and 'r' or 'l', length or '0pt'))
self.context.append(ids + '\\end{wrapfigure}\n')
elif self.in_minipage:
if ('align' not in node.attributes or
node.attributes['align'] == 'center'):
self.body.append('\n\\begin{center}')
self.context.append('\\end{center}\n')
else:
self.body.append('\n\\begin{flush%s}' % node.attributes['align'])
self.context.append('\\end{flush%s}\n' % node.attributes['align'])

This comment has been minimized.

Copy link
@jfbu

jfbu May 3, 2017

Author Owner

this code is never executed if I understand correctly f545805#diff-81c44cde8d80608ae558b93878f9be8aL1547 above

self.body.append('\n\\begin{center}')
self.context.append('\\end{center}\n')
else:
if ('align' not in node.attributes 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']

This comment has been minimized.

Copy link
@jfbu

jfbu May 3, 2017

Author Owner

same here: we never reach here if :align: left or :align: right was encountered.

self.body.append('\\begin{figure}[%s]%s\n' % (
self.elements['figure_align'], align))
self.body.append('\\begin{figure}[%s]\n\\centering\n' %
self.elements['figure_align'])
if any(isinstance(child, nodes.caption) for child in node):
self.body.append('\\capstart\n')
self.context.append(ids + align_end + '\\end{figure}\n')
self.context.append(ids + '\\end{figure}\n')

def depart_figure(self, node):
self.body.append(self.context.pop())
Expand Down

0 comments on commit f545805

Please sign in to comment.