Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numfig bug: :page: references wrong label from one chapter to another #28

Open
erikbgithub opened this issue Feb 9, 2014 · 0 comments

Comments

@erikbgithub
Copy link
Contributor

Hi Jeff,

found a bug in numfig.py which can be seen, when :page: reference is one in chapter A but the figure referenced is in chapter B. The current numfig will generate the incorrect latex. Example:

figure \ref{ch-impl/index:fig-desk} on page \pageref{ch-eval/index:fig-desk}

(the \ref block is correct, but the \pageref is wrong, because that label doesn't exist)

I fixed it by copying a lot of code from latex_visit_num_ref to latex_visit_page_ref locally and the page ref method looks like this now:

def latex_visit_page_ref(self, node):
    fields = node['reftarget'].split('#')

    if len(fields) > 1:
        label, target = fields
    else:
        label = None
        target = fields[0]

    if target not in self.builder.env.docnames_by_figname:
        raise nodes.SkipNode
    targetdoc = self.builder.env.docnames_by_figname[target]

    ref_link = '%s:%s' % (targetdoc, target)
    self.body.append("\\pageref{%s}" % ref_link)
    raise nodes.SkipNode

The code is neither optimal nor did I bother to make a commit out of it for now. I mostly want to keep the note here to make this a pull request after I am done with my thesis. Maybe this can be changed already when we replace some of the copy&paste files with a requirements.txt file and get the public numfig project. What do you think? (take your time responding, I know you are busy)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant