Opened 9 years ago

Closed 7 years ago

#12819 closed defect (wontfix)

Fix crossreferences in latex equations

Reported by: ppurka Owned by: jason
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: misc Keywords: latex cross-reference
Cc: kcrisman Merged in:
Authors: Punarbasu Purkayastha Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by ppurka)

This is a tiny patch to fix cross references in %latex blocks. Suggested by jason on that thread.


Apply trac_12819-latex_crossreference.patch

Attachments (1)

trac_12819-latex_crossreference.patch (1.8 KB) - added by ppurka 9 years ago.
apply to devel/sage

Download all attachments as: .zip

Change History (16)

Changed 9 years ago by ppurka

apply to devel/sage

comment:1 Changed 9 years ago by ppurka

  • Description modified (diff)
  • Status changed from new to needs_review

comment:2 Changed 9 years ago by novoselt

What about performance hit? All latex cells and latex output that was not handled by jsmath will get twice as slow, which kind of concerns me.

On the other hand, as far as I understand we only gain labels/references support within a single cell, not within a whole worksheet. It seems to me that it is not a very often needed functionality, i.e. you need it only for relatively large block of latex without computational cells in it. Can it be made optional? I.e. if someone needs it, then latex is called twice but only after calling some function, say latex_calls(2).

comment:3 Changed 9 years ago by ppurka

Will the performance hit be significant? I wonder if anyone will be writing big blocks of latex text in a cell. Even for a single journal-like page (or maybe two such pages), the latex compilation process is plenty fast.

You are right about the fact that the labels will be effective only within the cell. Is it better to be correct than (just a bit more) efficient in this case? After all, if I am writing small pieces of latex on the notebook, I would want it to "just work."

comment:4 Changed 9 years ago by novoselt

The performance hit is one system call (which seems to be about 0.1sec using cache depending on the system) plus the actual running time of LaTeX. This may seem small, but I think it can be an issue in two situations: a heavily used server for many users and a worksheet with a lot of latex pieces, e.g. all outputs of cells can be run through the actual LaTeX if they are using something not supported by jsmath.

I don't have any numbers to support my concerns and I am not quite sure how to get them, but it seems to me that latex should not be run the second time unless necessary, because usually it is not necessary. And sometimes two times are not sufficient.

A better solution would be to keep the crossreference data from the previous run, so that second evaluation of the cell would make the references work. Perhaps we can even show the warning from LaTeX about possibly wrong references (and any other warnings for that matter). This will make it work closer to the actual LaTeX and I expect those who use label to know that the second run is necessary and not be surprised by question marks.

Even better would be to support sectioning and labels and hyperlinks across the whole worksheet, which I think would be much more useful then references within a single sell, but I have no idea how difficult it is to make it work this way. I imagine - not easy.

I am not volunteering to implement either of these approach and perhaps the posted patch is just fine, I just want the reviewer who sets it to positive review think about this issues.

comment:5 Changed 9 years ago by ppurka

Maybe it is best to maintain the status quo, and not make any changes after all.

If we try to parse the latex log file and try to find out if a second or third run is needed then this parsing itself will take some time (disc access, search within file almost till the end for phrase like "rerun to get crossreferenc.", etc). This will defeat the purpose of saving server load by reducing unnecessary latex runs.

comment:6 Changed 9 years ago by novoselt

Well, if evaluating the same %latex cell the second time would actually run LaTeX the second time, it should not cost any time in execution and would allow using references.

comment:7 Changed 9 years ago by kcrisman

  • Cc kcrisman added

comment:8 Changed 9 years ago by jdemeyer

Please fill in your real name as Author.

comment:9 Changed 9 years ago by ppurka

  • Authors set to Punarbasu Purkayastha

comment:10 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:11 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:12 Changed 7 years ago by rws

Agree with @novoselt: in the case this is needed the user should give the second command herself. So wontfix?

comment:13 Changed 7 years ago by ppurka

I don't care.

It is choice between compiling more than once (easy fix) and changing the latex build system (big change).

Feel free to close the ticket.

comment:14 Changed 7 years ago by rws

  • Milestone changed from sage-6.2 to sage-duplicate/invalid/wontfix
  • Status changed from needs_review to positive_review

comment:15 Changed 7 years ago by vbraun

  • Resolution set to wontfix
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.