Skip to content

Support LaTeX expressions in subplot panel tags - #9247

Merged
Esteban82 merged 3 commits into
masterfrom
latex-subplot-tags
Oct 7, 2026
Merged

Esteban82 merged 3 commits into
masterfrom
latex-subplot-tags

Conversation

@Esteban82

Copy link
Copy Markdown
Member

Description of proposed changes

LaTeX expressions in a subplot panel tag (subplot set -A"@[...@[") are not plotted. This is the request in #7958 and the forum post. This PR replaces the WIP in #7958.

The tag is plotted inside the PSL_plot_completion PostScript procedure, and the EPS made from the LaTeX expression is too large to fit in a procedure (Ghostscript limitcheck).

Changes:

  • postscriptlight.c/h: new PSL_deflatexeps stores the EPS outside the procedure; new PSL_plotlatexepsdef places it. PSL_plotlatexeps works as before.
  • gmt_plot.c: use them for LaTeX tags (replaces the /tmp workaround). The tag is on top of the panel, and +g, +p and +s work.
  • Docs: removed the note saying LaTeX is not allowed in tags.

Note: use subplot set -A; subplot begin -A cannot take LaTeX because there each letter/digit means auto-numbering.

Script to test

gmt begin fig png
  gmt subplot begin 2x2 -Fs5c -A+jBR+o0.2c+gwhite+p1p,blue+s
    gmt subplot set 0,0 -A"@[\nabla^2@["
    gmt basemap -R0/10/0/10 -JX5c -Bafg
    gmt subplot set 0,1 -AB
    gmt basemap -R0/10/0/10 -JX5c -Bafg
    gmt subplot set 1,0 -A"@[\sum_i x_i@["
    gmt basemap -R0/10/0/10 -JX5c -Bafg -B+glightblue
    gmt subplot set 1,1 -A4
    gmt basemap -R0/10/0/10 -JX5c -Bafg -B+glightblue
  gmt subplot end
gmt end
fig

Panel tags are plotted at the end of each panel via the PSL_plot_completion
procedure, but the EPS made from a LaTeX expression (with its embedded fonts)
is too large to be part of a PostScript procedure body (limitcheck).  The new
PSL_deflatexeps stores the EPS in a reusable file object (ReusableStreamDecode)
outside the procedure, and PSL_plotlatexepsdef executes it from inside the
procedure.  Hence LaTeX tags are drawn on top of the panel like regular tags,
and the tag box settings (+g, +p, +s) are honored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Esteban82
Esteban82 requested review from joa-quim and seisman October 7, 2026 15:33
@Esteban82 Esteban82 added enhancement Improving an existing feature add-changelog Add PR to the changelog labels Oct 7, 2026
@Esteban82

Copy link
Copy Markdown
Member Author

BTW, I think that the WIP Check is failing.

@Esteban82

Copy link
Copy Markdown
Member Author

BTW, I think that the WIP Check is failing.

Now it is working.

@joa-quim joa-quim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks a self contained change, and if it works.

@Esteban82
Esteban82 merged commit dd500f6 into master Oct 7, 2026
14 of 19 checks passed
@Esteban82
Esteban82 deleted the latex-subplot-tags branch October 7, 2026 23:29
@seisman seisman added this to the 6.8.0 milestone Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants