mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
parent
58be2f19b3
commit
3a388148d7
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user