From 5caad013d1b9f229de23ba2714206bf9140e02d6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 20 Oct 2010 08:10:07 -0400 Subject: [PATCH 1/2] include a blank line before a new line-block so it stands as its own paragraph --- sphinx/writers/latex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index de57e35a8..f6d7eb7cb 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1238,7 +1238,7 @@ class LaTeXTranslator(nodes.NodeVisitor): * inline markup is supported. * serif typeface """ - self.body.append('{\\raggedright{}') + self.body.append('\n{\\raggedright{}') self.literal_whitespace += 1 def depart_line_block(self, node): self.literal_whitespace -= 1 From f0f9f7b1b2d54246b7ec77547f3cade6afa20967 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 28 Oct 2010 22:10:24 -0400 Subject: [PATCH 2/2] add caption option to graphviz nodes and render the caption in latex output --- sphinx/ext/graphviz.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index b4449e182..f44e51366 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -52,6 +52,7 @@ class Graphviz(Directive): option_spec = { 'alt': directives.unchanged, 'inline': directives.flag, + 'caption': directives.unchanged, } def run(self): @@ -85,6 +86,8 @@ class Graphviz(Directive): node['options'] = [] if 'alt' in self.options: node['alt'] = self.options['alt'] + if 'caption' in self.options: + node['caption'] = self.options['caption'] node['inline'] = 'inline' in self.options return [node] @@ -100,6 +103,7 @@ class GraphvizSimple(Directive): option_spec = { 'alt': directives.unchanged, 'inline': directives.flag, + 'caption': directives.unchanged, } def run(self): @@ -109,6 +113,8 @@ class GraphvizSimple(Directive): node['options'] = [] if 'alt' in self.options: node['alt'] = self.options['alt'] + if 'caption' in self.options: + node['caption'] = self.options['caption'] node['inline'] = 'inline' in self.options return [node] @@ -264,13 +270,24 @@ def render_dot_latex(self, node, code, options, prefix='graphviz'): self.builder.warn('dot code %r: ' % code + str(exc)) raise nodes.SkipNode - if node.get('inline', False): + inline = node.get('inline', False) + if inline: para_separator = '' else: para_separator = '\n' if fname is not None: - self.body.append('%s\\includegraphics{%s}%s' % (para_separator, fname, para_separator)) + caption = node.get('caption') + if caption: + self.body.append('\n\\begin{figure}[h!]') + self.body.append('\n\\begin{center}') + self.body.append('\n\\caption{%s}' % caption) + self.body.append('\n\\label{figure:%s}' % caption) + self.body.append('\n\\includegraphics{%s}' % fname) + self.body.append('\n\\end{center}') + self.body.append('\n\\end{figure}\n') + else: + self.body.append('%s\\includegraphics{%s}' % (para_separator, fname, para_separator)) raise nodes.SkipNode