Menu

#2861 epslatex terminal: tick labels contain LaTeX math but not enclosed in dollar signs

None
closed-not-a-bug
nobody
epslatex (6)
2026-03-12
2026-03-12
No

I'm working w/ Gnuplot 5.0 on Linux, although I am informed this bug also exists with Gnuplot 6.0.2 on Linux.

In summary it appears that tick labels are generated which contain LaTeX math expressions but they are not enclosed in dollar signs.

In detail, I have an example Gnuplot input file latex-bug.gnuplot which I've attached. Executing

$ gnuplot latex-bug.gnuplot

apparently succeeds and creates its specified output mumble.tex, but then

$ latex mumble.tex
! Missing $ inserted.
<inserted text> 
                $
l.167     \gplbacktext

The error is actually at lines 142--147, which say

      \put(1474,1548){\makebox(0,0)[r]{\strut{}1.02\times10^{6}}}%
      \put(1474,2498){\makebox(0,0)[r]{\strut{}1.04\times10^{6}}}%
      \put(1474,3448){\makebox(0,0)[r]{\strut{}1.06\times10^{6}}}%
      \put(1474,4399){\makebox(0,0)[r]{\strut{}1.08\times10^{6}}}%
      \put(1474,5349){\makebox(0,0)[r]{\strut{}1.1\times10^{6}}}%
      \put(1474,6299){\makebox(0,0)[r]{\strut{}1.12\times10^{6}}}%

which are labels for the y-axis. The \times stuff should be enclosed in dollar signs, and in fact if I do that, then I get what appears to be a valid output from latex.

3 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2026-03-12

    The problem arises because your test script explicitly sets the tic format to '%h', but this is not correct for latex terminals. Here is the guidance from help set format:

    The length of the format string is restricted to 100 characters.
    The default format is "% h", except that LaTeX terminals use "$%h$".
    You can modify this to provide units or a different numeric format,
    for example 'set xtics format "%.2f MHz"'.
    "set format" with no following string will restore the default.

    I grant you that this bit of documentation may not be easy to find. A further subtlety is that the default format has a space in it. This is silently replaced internally with the latex default if output is to a latex terminal. Your script omits the space (%h rather than % h) so the program does not recognize this as the default and thus does not make the replacement.

    Any of the following commands would work to restore the correct latex output:

    set format
    set format "% h"       # note extra space
    set format "$%h$"
    set ytics format
    set ytics format "% h"
    set ytics format "$%h$"
    

    If you want a non-default format for latex output you would have to include appropriate latex math markup.

     
  • Robert Dodier

    Robert Dodier - 2026-03-12
    • status: open --> closed-not-a-bug
    • Group: -->
    • Priority: -->
     
  • Robert Dodier

    Robert Dodier - 2026-03-12

    Thanks for the info, I'll go back and fix up the code which generated that Gnuplot script. I've marked this ticket as "not a bug" accordingly.

     

Log in to post a comment.