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}$"
And here’s the equivalent with pdfLaTeX:
$\mathcal{J}$
Is there a way to get them to match, whether its converting the MathTeX font to pdfLaTeX or vice versa?
I think your best bet is to change the LaTeX version. Some thoughts that suggest this solution:
Using MathTeXEngine.jl:
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.
However, the pdfLaTeX example you show looks to be using the letter J from the ComputerModernSymbol font:
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.
2 Likes
Thanks for this. I assume you mean that I should change the font in my LaTeX to match the font that MathTeX uses?
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.
1 Like