Opened 13 years ago

Last modified 8 years ago

#7664 new defect

Make sure latex doesn't do weird things with R output

Reported by: kcrisman Owned by: tbd
Priority: major Milestone: sage-6.4
Component: packages: standard Keywords: latex, R, jsmath, r-project
Cc: jason, iandrus Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


jsmath doesn't understand output from R, so you have to turn off typesetting for it to work. E.g., it doesn't know what to do with this table which results from R output - I guess it's really a latex() problem.

[1] "sage0"
sage: a._latex_()

% latex.default(sage3, file = "") 



Change History (9)

comment:1 Changed 13 years ago by jason

  • Cc jason added

comment:2 follow-up: Changed 13 years ago by jason

Can R latex its own expressions?

If not, we might explore the rpy2 interface a bit more to get the data into python formats.

Also, when evaluating in the R system, we ought to enclose things in a div that tells jsmath "Hands off!"

comment:3 in reply to: ↑ 2 Changed 13 years ago by kcrisman

Replying to jason:

Can R latex its own expressions?

Apparently using the Hmisc package. From our own doctests in

    def _latex_(self):
        Return LaTeX representation of this R object.

        This calls the \code{latex} command in R.

           a latex expression (basically a string)
            sage: latex(r(2))  #optional requires the Hmisc R package
        P = self.parent()
        # latex is in Hmisc, this is currently not part of Sage's R!!!
        except ImportError:
            raise RuntimeError, "The R package 'Hmisc' is required for R to LaTeX conversion, but it is not available."
        return LatexExpr(P.eval('latex(%s, file="");'

Note that this requires the package 'survival', which is also recommended but not currently in Sage.

Anyway, I checked some more and apparently the problem is that jsmath doesn't understand the latex output created by Hmisc - namely, it doesn't know what a table is, nor center, nor tabular.

So maybe if EMBEDDED_MODE=True, we should have a thing that strips out all that other stuff and just puts in the stuff in the middle. Incidentally, the output in the optional doctest above is incorrect, we get

% latex.default(sage0, file = "") 



so maybe this was with a previous version of Hmisc.

Or we could even strip out those things and replace them with equivalent HTML stuff when EMBEDDED_MODE is true.

comment:4 Changed 11 years ago by kcrisman

  • Keywords r-project added

comment:5 Changed 9 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:6 Changed 9 years ago by iandrus

  • Cc iandrus added

FWIW, this affects sage-mode in Emacs when typesetting output as well.

comment:7 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:8 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:9 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.