# MathTeX font does not match pdfLaTeX font

**URL:** <https://discourse.julialang.org/t/mathtex-font-does-not-match-pdflatex-font/107670>\
**Category:** Visualization\
**Tags:** plotting, makie, glmakie, latexstrings\
**Created:** [December 15, 2023, 2:33pm UTC](https://discourse.julialang.org/t/mathtex-font-does-not-match-pdflatex-font/107670 "2023-12-15T14:33:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dchang10](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dchang10/32/44162_2.png) [@dchang10](https://discourse.julialang.org/u/dchang10)\
**Post date:** [December 15, 2023, 2:33pm UTC](https://discourse.julialang.org/t/mathtex-font-does-not-match-pdflatex-font/107670/1 "2023-12-15T14:33:17Z")

</div>

I’m using LaTeXstrings in GLMakie to render math. It seems like the mathcal font in LaTeXstrings is different from the typical font used for mathcal pdfLaTeX. Here’s an example of a render with LaTeXStrings:

`L"$\mathcal{J}$"`  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/e/2e39aca40b45c16981662a0f73b8d64202c826fb.png)

And here’s the equivalent with pdfLaTeX:  
`$\mathcal{J}$`  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/0/c00d5fb9b12bf79465d3730578c3ac46fd648951.png)

Is there a way to get them to match, whether its converting the MathTeX font to pdfLaTeX or vice versa?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [December 16, 2023, 10:54am UTC](https://discourse.julialang.org/t/mathtex-font-does-not-match-pdflatex-font/107670/2 "2023-12-16T10:54:53Z")

</div>

I think your best bet is to change the LaTeX version. Some thoughts that suggest this solution:

Using MathTeXEngine.jl:

```julia-term
julia-1.10> generate_tex_elements(L"\mathcal{J}")
1-element Vector{Any}:
 (TeXChar '𝓙' [index 2819 in NewComputerModern Math - Regular], 
   [0.0, 0.0], 1.0)

```

(Ignore the terminal font… :))

I understand that MathTeXEngine.jl always uses the NewComputerModern(Math) fonts, and here uses the Unicode glyph U+1d4a5, “MATHEMATICAL SCRIPT CAPITAL J”. The `index 2819` here is simply saying that the Unicode glyph U+1d4a5 occurs at index 2819 in the font file.

 ![Screenshot 2023-12-16 at 10.30.40](https://global.discourse-cdn.com/julialang/original/3X/c/e/ce09723454d8eeae8a1c4df1d623ef2c0ad492c5.png)

However, the pdfLaTeX example you show looks to be using the letter J from the ComputerModernSymbol font:

![Screenshot 2023-12-16 at 10.19.02](https://global.discourse-cdn.com/julialang/original/3X/d/5/d5452364d5035976cb95add85452cbe9b2ed3488.png)

and there doesn’t look like there’s any Unicode going on here.

The last time I used LaTeX I used LuaLaTeX, which someone said was the newer replacement for pdfLaTex…

Presumably LaTeX allows you more flexibility in selecting and using fonts… There’s a few fonts with Unicode Script Js - although to me they often look more like other letters rather than J. Your best choice looks like Cambria Math. 🤷🏻‍♂️

 ![Screenshot 2023-12-16 at 10.44.58](https://global.discourse-cdn.com/julialang/original/3X/5/0/5054e78f8165b10eb06edc824a3d3a8e145dfe1b.png)

---

<div class="post-metadata">

**Author:** ![dchang10](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dchang10/32/44162_2.png) [@dchang10](https://discourse.julialang.org/u/dchang10)\
**Post date:** [December 17, 2023, 2:58pm UTC](https://discourse.julialang.org/t/mathtex-font-does-not-match-pdflatex-font/107670/3 "2023-12-17T14:58:48Z")

</div>

Thanks for this. I assume you mean that I should change the font in my LaTeX to match the font that MathTeX uses?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [December 17, 2023, 3:13pm UTC](https://discourse.julialang.org/t/mathtex-font-does-not-match-pdflatex-font/107670/4 "2023-12-17T15:13:47Z")

</div>

I don’t think you can easily change the font used by MathTeXEngine.jl, but you can easily (I think) change the font used by your LaTeX system. So if you want the glyphs to look the same in both environments, I’m guessing you should change your LaTeX system.
