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 <erik.bernoth@gmail.com>
Acked-by: Matthias C. M. Troffaes <matthias.troffaes@gmail.com>
This commit is contained in:
Erik Bernoth 2013-09-24 16:01:12 +02:00
parent 58be2f19b3
commit 3a388148d7

View File

@ -379,7 +379,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
widest_label = bi[0] widest_label = bi[0]
self.body.append(u'\n\\begin{thebibliography}{%s}\n' % widest_label) self.body.append(u'\n\\begin{thebibliography}{%s}\n' % widest_label)
for bi in self.bibitems: for bi in self.bibitems:
target = self.hypertarget(bi[2] + ':' + bi[0].lower(), target = self.hypertarget(bi[2] + ':' + bi[3].lower(),
withdoc=False) withdoc=False)
self.body.append(u'\\bibitem[%s]{%s}{%s %s}\n' % self.body.append(u'\\bibitem[%s]{%s}{%s %s}\n' %
(bi[0], self.idescape(bi[0]), target, bi[1])) (bi[0], self.idescape(bi[0]), target, bi[1]))
@ -648,6 +648,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
if isinstance(node.parent, nodes.citation): if isinstance(node.parent, nodes.citation):
self.bibitems[-1][0] = node.astext() self.bibitems[-1][0] = node.astext()
self.bibitems[-1][2] = self.curfilestack[-1] self.bibitems[-1][2] = self.curfilestack[-1]
self.bibitems[-1][3] = node.parent['ids'][0]
raise nodes.SkipNode raise nodes.SkipNode
def visit_tabular_col_spec(self, node): def visit_tabular_col_spec(self, node):
@ -1271,7 +1272,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_citation(self, node): def visit_citation(self, node):
# TODO maybe use cite bibitems # TODO maybe use cite bibitems
self.bibitems.append(['', '', '']) # [citeid, citetext, docname] self.bibitems.append(['', '', '', '']) # [id, txt, name, ref]
self.context.append(len(self.body)) self.context.append(len(self.body))
def depart_citation(self, node): def depart_citation(self, node):
size = self.context.pop() size = self.context.pop()