bugGNU Octave - Bugs: bug #50130, 'print -dpdflatex' forgets putting...


bug #50130: 'print -dpdflatex' forgets putting superscripts inside math-environment.

Submitted by:  None
Submitted on:  Mon 23 Jan 2017 11:54:19 PM UTC  
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.2.0
Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sun 11 Nov 2018 02:04:28 AM UTC, comment #8: 

@Pantxo: I pushed your patch for the "latex" printing here https://hg.savannah.gnu.org/hgweb/octave/rev/8b9e6a39e0a2.  Changing Status of bug to Fixed.

Rik <rik5>
Project Administrator
Thu 08 Nov 2018 08:09:25 AM UTC, comment #7: 

I attached a clean patch (without debug printf). Note that with this approach I think nothing will have to be changed when/if we implement a true latex renderer: Octave handles its own latex strings, the user takes care of his ones.

(file #45383)

Pantxo Diribarne <pantxo>
Project Member
Wed 07 Nov 2018 10:16:59 PM UTC, comment #6: 

@Rik: I attached a patch that fixes the issue of producing log plots that don't compile in latex.

(file #45381)

Pantxo Diribarne <pantxo>
Project Member
Sat 12 Aug 2017 09:42:23 PM UTC, comment #5: 

I am pretty sure that your updates will help. It should
have been clear that user editing of the Octave output
strings was required for full use of TeX (LaTeX) for plots.

I am really swamped right now, but will check on the current
state as soon as I can. In any case, it would be nice to
x and y (and z) labels could be post-edited for publication as
was once true.

Michael Godfrey <godfrey>
Project Member
Sat 12 Aug 2017 09:33:01 PM UTC, comment #4: 

I'm marking this as Won't Fix.  Octave does not implement an on-screen "latex" interpreter.  The text strings are only useful for a true LaTeX interpreter.  It is up to the programmer to make sure that those strings are correct.  This will mean extra work to change the ticklabels to manually set text.  However, making figures for publication is always a bit of a chore.

Rik <rik5>
Project Administrator
Thu 06 Jul 2017 02:23:04 PM UTC, comment #3: 

Labels are correct when the graphic toolkit is gnuplot

graphics_toolkit ('gnuplot')
x = logspace (1, 6);
semilogx (x, log10 (x));
print -dpdflatexstandalone log.tex
system ('pdflatex log.tex')

Is it gnuplot which produces the right labels?

Marco Caliari <caliari>
Project Member
Tue 24 Jan 2017 09:54:14 AM UTC, comment #2: 


Thanks for your report. I think you are right that labels that are generated by Octave itself could be handled by Octave. Changing text provided by the user is another story:

  • Octave has a "tex" interpreter, which means it can handle a subset of latex formatting, in line (without the need for $). So far so good.
  • Octave doesn't have a "latex" interpreter (in the background, it is the same as "tex"). But if it had, "function of e^x." would not be a valid expression for the "latex" interpreter. The user would have to enclose the inline math expression between $ himself.

So I think someone who wants to print using latex output formats should take care of having valid text strings himself (as will be necessary when a proper latex interpreter is implemented), except for those generated by Octave itself.
For those, a workaround is to use something like :

function fixlabels (hax)
  for s = ['x' 'y' 'z']
    if (strcmp (get (hax, [s "scale"]), "log") &&
        strcmp (get (hax, [s "ticklabelmode"]), "auto"))
      labs = get (hax, [s "ticklabel"]);
      labs = cellfun (@(ss) ["$" ss "$"], labs, "uniformoutput", 0);
      set (hax, [s "ticklabel"], labs)

Pantxo Diribarne <pantxo>
Project Member
Tue 24 Jan 2017 12:10:28 AM UTC, comment #1: 

(I'm op and I messed up the formatting. There should be a preview button.)

The same happens with text in the labels like

> xlabel("This is log(x), the inverse function of e^x.")

This is a bit harder to fix, since we don't want to put the whole text in a math environment. But octave seems to already have something like a LaTeX interpreter. That could tell us, where to put the dollar-signs.

Martin Castillo <castilma>
Mon 23 Jan 2017 11:54:19 PM UTC, original submission:  

The for big numbers, the axis is labeled with superscripted exponents. When printing it with -dpdflatex{,standalone}, the superscript is not put inside a math environment.

Try this

> x=logspace(1,6);
> semilogx(x,log10(x));
> print -dpdflatexstandalone log.tex

$ pdflatex log.tex

If you look into log.tex, you should see e.g.


even though it should say




(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #45383:  texloglog2.patch added by pantxo (3KiB - text/x-patch)
file #45381:  texloglog.patch added by pantxo (3KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by caliari (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by castilma (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-11 rik5 StatusWont Fix => Fixed
    2018-11-08 pantxo Attached File- => Added texloglog2.patch, #45383
    2018-11-07 pantxo Attached File- => Added texloglog.patch, #45381
    2017-08-12 rik5 StatusConfirmed => Wont Fix
        Open/ClosedOpen => Closed
    2017-01-24 pantxo StatusNone => Confirmed
        Operating SystemGNU/Linux => Any

    Back to the top

    Powered by Savane 3.5