bugGNU Octave - Bugs: bug #67320, latex_renderer: unable to compile...

 
 

bug #67320: latex_renderer: unable to compile "10^{1.5}" with colorbar

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Tue 15 Jul 2025 11:54:40 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Patch Submitted Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * stable Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Jump to the original submission

Fri 18 Jul 2025 12:46:15 PM UTC, comment #6: 

After looking a bit more into this, I see that in print.m we only change the axes "ticklabelinterpreter" to latex (so that log labels are handled automatically) not all strings. I now see two solutions :
1. we do it for both text and axes objects unconditionally (as I though we did),
2. we let users do it for any text that is not handled by Octave automatically (as proposed by Markus in comment #1) and we eventually warn users that they'd better change the interpreter to latex before printing if they want to make sure the output .tex file is valid and text positions are correct.

My favorite one is 1 because it is the most WYSIWYG and if the latex compilation fails in Octave the user knows that it won't work outside Octave either and he has something to fix before the .tex file is usable.

Pantxo Diribarne <pantxo>
Group Member
Wed 16 Jul 2025 07:06:02 PM UTC, comment #5: 

In section 15.2.9 I see


...
* Use one of the -d*latex* devices to produce a .tex file (plus supporting .eps or .pdf files) to be further processed by an external LaTeX engine. Note that the print function will first set the interpreter of all strings to "latex", which means all strings must be valid LaTeX strings.


That pretty much says it all IMHO. Maybe we could add


...which means all strings must be valid LaTeX strings otherwise the tex file won't be a valid latex file, and even if it is edited and fixed afterwards, there is no garanty that the position of text in the figure will be correct.


Pantxo Diribarne <pantxo>
Group Member
Wed 16 Jul 2025 12:58:12 PM UTC, comment #4: 

Is the attached patch ok for the stable branch?

I was trying to add something about a better WYSIWYG experience. But I was struggling to find good wording for that. So, I didn't add anything about that.


(file #57418)

Markus Mützel <mmuetzel>
Group administrator
Wed 16 Jul 2025 12:07:31 PM UTC, comment #3: 

That sounds reasonable.

If I understand correctly, a reasonable suggestion might be to set the "ticklabelinterpreter" axes property to "latex" in the first place if users plan to print with one of the "*latex*" drivers (and use manual tick labels).
Maybe, we could add a sentence about that to that section in the documentation of the `print` function.

Would that make sense?

Markus Mützel <mmuetzel>
Group administrator
Wed 16 Jul 2025 11:43:52 AM UTC, comment #2: 


>> Maybe, the "ticklabelinterpreter" should only be set if all "?ticklabelmode" properties are "auto"?


Switching to latex interpreter is useful to get the auto labels righ, but also to have them positionned correctly. So I don't think this is a good idea.

The warning says that the user should change the syntax of its labels otherwise the output tex file cannot be compiled. And even if it is modified outside Octave to fix the syntax (and add the missing $s), the position of the labels can be very wrong. E.g:


plot (1:10);
yl = yticks ();
nticks = numel (yl);
[yl, idx]  = sort ([yl, pi]);
idx = idx == (nticks + 1);
yticks (yl);
ytl = yticklabels ();
ytl{idx} = "\\underbrace{\\pi\\approx 3.14}_{Test}"
yticklabels (ytl);
print -dpdflatexstandalone toto.tex


So I would say we should change nothing.

Pantxo Diribarne <pantxo>
Group Member
Tue 15 Jul 2025 02:46:52 PM UTC, comment #1: 

This is probably because of the changes for bug #50130 here:
https://hg.savann ... /rev/ad9f8533e323

Maybe, the "ticklabelinterpreter" should only be set if all "?ticklabelmode" properties are "auto"?

That change was more than 6 years ago. But CC'ing Pantxo in the hope that he'll recall if that would break that use-case.

On the other hand, there is already a note about LaTeX formatting in the documentation for the "*latex*" drivers of the print function:
https://docs.octa ... .html#index-print

> The text that is written to the LaTeX file contains the strings exactly as they were specified in the plot. If any special characters of the TeX mode interpreter were used, the file must be edited before LaTeX processing. Specifically, the special characters must be enclosed with dollar signs ($ … $), and other characters that are recognized by LaTeX may also need editing (e.g., braces).


So, maybe that is already good enough to caution the user?

Markus Mützel <mmuetzel>
Group administrator
Tue 15 Jul 2025 11:54:40 AM UTC, original submission:  


octave:9> demo colorbar 19
colorbar example 19:
 clf;
 colormap ("default");
 imagesc (log10 (1 ./ hilb (99)));
 h = colorbar ();
 ytick = get (h, "ytick");
 set (h, "yticklabel", sprintf ("10^{%g}|", ytick));

octave:10> print -dpdflatexstandalone t1.pdf
warning: latex_renderer: unable to compile "10^{0}"
warning: called from
    print at line 764 column 14

warning: latex_renderer: unable to compile "10^{0.5}"
warning: called from
    print at line 764 column 14

warning: latex_renderer: unable to compile "10^{1}"
warning: called from
    print at line 764 column 14

warning: latex_renderer: unable to compile "10^{1.5}"
warning: called from
    print at line 764 column 14

warning: latex_renderer: unable to compile "10^{2}"
warning: called from
    print at line 764 column 14
...


(running "pdflatex t1.tex" would fail.)

Dmitri.
--
 

Dmitri A. Sergatskov <dasergatskov>

 

Attached Files

Attached Files

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by mmuetzel
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    Votes

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    History

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-07-16 mmuetzel Attached File- Added bug67318-print-latex-svgconvert.patch, #57418
        StatusNone Patch Submitted
    2025-07-15 mmuetzel CategoryPlotting Plotting with OpenGL
        Carbon-Copy- Added pantxo

    Back to the top

    Powered by Savane 3.16.
    Corresponding source code