Search code examples
latextexmaxima

Writing Latex math expression in Maxima


How I can write Latex/TEX expressions in legend and labels of plot2d?

Thanks.


Solution

  • Maxima relies on Gnuplot for displaying plots, so to extent Maxima can handle TeX/LaTeX in labels and legends depends on what Gnuplot can handle.

    Gnuplot has a LaTeX output format, but that is a file output format, not for display on the screen, so I won't consider it further here. But maybe there is some way to output a LaTeX file and then launch a viewer for it? I haven't investigated that possibility.

    From looking at some discussions in the Gnuplot project, it appears that Gnuplot cannot handle TeX/LaTeX in output formats which are displayed directly to the screen. However, Gnuplot recognizes some escape sequences, and also allows Unicode characters in strings when the terminal option enhanced is specified. This allows some subset of LaTeX-like functionality.

    About escape sequences, see "Enhanced text mode", pp 32--33 in the current version of the manual: http://gnuplot.info/docs_5.4/Gnuplot_5_4.pdf

    About Unicode characters, see "Escape sequences", p 34. See also the examples: http://www.gnuplot.info/demo/enhanced_utf8.html and http://www.gnuplot.info/demo_5.4/unicode.html .

    On looking at how Maxima interacts with Gnuplot, it appears that Maxima disabled the enhanced flag, so stuff like underscore and caret have no effect, and escape sequences are not recognized. EDIT: You can enable Gnuplot enhanced strings in Maxima via: set_plot_option([gnuplot_strings, true]);

    When Unicode characters are in a string supplied by Maxima to Gnuplot, they are displayed correctly.

    Most Lisp implementations handle Unicode characters; GCL is the exception.

    I know this is not straightforward; this is a summary of what I could figure out, and I hope it helps.