From 3a388148d703de69a7bc9ce8a9b72c7103e0a2d0 Mon Sep 17 00:00:00 2001 From: Erik Bernoth Date: Tue, 24 Sep 2013 16:01:12 +0200 Subject: [PATCH] writers/latex: debug bibtex hypertarget labels The LaTeX reference target used to be the bibitem id. But the bibitem id was already rewritten to contain a number instead of the lowercased id name, that is given by the bibtex file. This change adds a new element to the bibitem instantiation which contains the id from the bibtex file. The hypertarget uses this bibitem element now. The alternative fix would be to hyperref the numbered id and leave the target with the id number as it is. We decided against it, because in the html builder both the ref and the target use the bibtex id name and not the number. Signed-off-by: Erik Bernoth Acked-by: Matthias C. M. Troffaes --- sphinx/writers/latex.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index ce92edfc3..d7a522289 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -379,7 +379,7 @@ class LaTeXTranslator(nodes.NodeVisitor): widest_label = bi[0] self.body.append(u'\n\\begin{thebibliography}{%s}\n' % widest_label) for bi in self.bibitems: - target = self.hypertarget(bi[2] + ':' + bi[0].lower(), + target = self.hypertarget(bi[2] + ':' + bi[3].lower(), withdoc=False) self.body.append(u'\\bibitem[%s]{%s}{%s %s}\n' % (bi[0], self.idescape(bi[0]), target, bi[1])) @@ -648,6 +648,7 @@ class LaTeXTranslator(nodes.NodeVisitor): if isinstance(node.parent, nodes.citation): self.bibitems[-1][0] = node.astext() self.bibitems[-1][2] = self.curfilestack[-1] + self.bibitems[-1][3] = node.parent['ids'][0] raise nodes.SkipNode def visit_tabular_col_spec(self, node): @@ -1271,7 +1272,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_citation(self, node): # TODO maybe use cite bibitems - self.bibitems.append(['', '', '']) # [citeid, citetext, docname] + self.bibitems.append(['', '', '', '']) # [id, txt, name, ref] self.context.append(len(self.body)) def depart_citation(self, node): size = self.context.pop()