From 71cf3e7a4f061f9d597978c049026ac57234db48 Mon Sep 17 00:00:00 2001 From: tk0miya Date: Mon, 6 Oct 2014 20:24:57 +0900 Subject: [PATCH] Fix position of \label tag for table was invalid in LaTeX --- sphinx/writers/latex.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 2687fc7cc..5a4c8a61b 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -682,6 +682,9 @@ class LaTeXTranslator(nodes.NodeVisitor): if not self.table.longtable and self.table.caption is not None: self.body.append(u'\n\n\\begin{threeparttable}\n' u'\\capstart\\caption{%s}\n' % self.table.caption) + for id in self.next_table_ids: + self.body.append(self.hypertarget(id, anchor=False)) + self.next_table_ids.clear() if self.table.longtable: self.body.append('\n\\begin{longtable}') endmacro = '\\end{longtable}\n\n' @@ -709,11 +712,11 @@ class LaTeXTranslator(nodes.NodeVisitor): else: self.body.append('{|' + ('L|' * self.table.colcount) + '}\n') if self.table.longtable and self.table.caption is not None: - self.body.append(u'\\caption{%s} \\\\\n' % self.table.caption) - if self.table.caption is not None: + self.body.append(u'\\caption{%s}' % self.table.caption) for id in self.next_table_ids: self.body.append(self.hypertarget(id, anchor=False)) self.next_table_ids.clear() + self.body.append(u'\\\\\n') if self.table.longtable: self.body.append('\\hline\n') self.body.extend(self.tableheaders) @@ -1114,7 +1117,7 @@ class LaTeXTranslator(nodes.NodeVisitor): return elif isinstance(next, nodes.table): # same for tables, but only if they have a caption - for n in node: + for n in next: if isinstance(n, nodes.title): if node.get('refid'): self.next_table_ids.add(node['refid'])