From b1c6717743ca70322c3f1fc9ca954b6720f9cf05 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 26 Jun 2016 23:19:57 +0900 Subject: [PATCH] Check latex_image_length() returns none value --- sphinx/writers/latex.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index ca3df78de..db8fae0dc 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1463,21 +1463,22 @@ class LaTeXTranslator(nodes.NodeVisitor): # TODO: support align option if 'width' in node: length = self.latex_image_length(node['width']) - self.body.append('\\begin{sphinxfigure-in-table}[%s]\n\\centering\n' % length) + if length: + self.body.append('\\begin{sphinxfigure-in-table}[%s]\n' + '\\centering\n' % length) else: 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}\\relax\n') elif node.get('align', '') in ('left', 'right'): + length = None if 'width' in node: length = self.latex_image_length(node['width']) elif 'width' in node[0]: length = self.latex_image_length(node[0]['width']) - else: - length = '0pt' self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' % - (node['align'] == 'right' and 'r' or 'l', length)) + (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