# Latex in subplot title

**URL:** <https://forum.generic-mapping-tools.org/t/latex-in-subplot-title/4364>\
**Category:** Q&A\
**Created:** [October 20, 2023, 12:52pm UTC](https://forum.generic-mapping-tools.org/t/latex-in-subplot-title/4364 "2023-10-20T12:52:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pa345](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@pa345](https://forum.generic-mapping-tools.org/u/pa345)\
**Post date:** [October 20, 2023, 12:52pm UTC](https://forum.generic-mapping-tools.org/t/latex-in-subplot-title/4364/1 "2023-10-20T12:52:17Z")

</div>

I am unable to have LaTeX correctly render in a subplot title. Here is my example code:

```
SUBPLOT_WIDTH1="3i"
SUBPLOT_WIDTH2="1.5i"
SUBPLOT_HEIGHT="1.5i"

eq_proj="-JW180/3i -Rg"
np_proj="-JG0/90/1.5i -R-180/180/40/90"
sp_proj="-JG180/-90/1.5i -R/-180/180/-90/-40"

gmt begin Figure png
  gmt set FONT_TAG 16p,Times-Italic
  gmt set FONT_TITLE 16p,Helvetica

  gmt subplot begin 1x2 -Fs${SUBPLOT_WIDTH1},${SUBPLOT_WIDTH2},${SUBPLOT_WIDTH2}/${SUBPLOT_HEIGHT} -A+o-0.2c/0 -M0.4c/0.3c

    gmt subplot set 0,0 -A"@[\nabla^2@["
    gmt basemap ${eq_proj} -B0

    gmt subplot set 0,1 -A-
    gmt basemap ${np_proj}

  gmt subplot end

gmt end show

```

And here is the result:

 ![Figure](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/5/5beca503d1b384e7366da9a9fe724bcda02cea1d.png)

Can anyone spot the problem?

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [October 20, 2023, 2:41pm UTC](https://forum.generic-mapping-tools.org/t/latex-in-subplot-title/4364/2 "2023-10-20T14:41:08Z")

</div>

Using Latex in **subplot** panel tags was never implemented. I just tried to do it but it is tricky since the tags are plotted after everything in the panel is plotted so we must create a _PostScript_ function in the **subplot -A** call and then call that _PostScript_ function at the end of the panel. This yields a _PostScript_ error - trying to figure it [out](https://github.com/GenericMappingTools/gmt/pull/7958).

Meantime I suggest you place such text via **text**.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [October 8, 2026, 12:08am UTC](https://forum.generic-mapping-tools.org/t/latex-in-subplot-title/4364/3 "2026-10-08T00:08:21Z")

</div>

Just fixed in master.

> <https://github.com/GenericMappingTools/gmt/pull/9247>
>
> \*\*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\](https://forum.generic-mapping-tools.org/t/latex-in-subplot-title/4364). 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
> \`\`\`
> \<img width="70%" height="1341" alt="fig" src="https://github.com/user-attachments/assets/0aaf051c-442d-4de3-a47f-a3557ae8ddb9" /\>
