# Makie.jl - LaTeX ticks (and other elements)by default

**URL:** https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529
**Category:** Visualization
**Created:** [August 6, 2023, 6:15am UTC](https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529 "2023-08-06T06:15:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![danieleavitabile](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danieleavitabile/32/31966_2.png) [@danieleavitabile](https://discourse.julialang.org/u/danieleavitabile)
#### Post date: [August 6, 2023, 6:15am UTC](https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529/1 "2023-08-06T06:15:16Z")

</div>

Hi All,

I have read several posts in which LaTex ticks can be added to Makie manually, by specifying the ticks with a command, for instance [here](https://discourse.julialang.org/t/latex-strings-in-makie-axis-ticks/80729).

Close to publication, I would like that by default every text in my figure be a LaTeX string. This should include numerical values of the ticks, and all other strings. Is this possible with a single command?

Thanks

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [August 6, 2023, 7:17am UTC](https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529/2 "2023-08-06T07:17:21Z")

</div>

I think we have to clarify what is meant by “LaTeX String” here. There are a few different interpretations.

The first and simplest one refers to the fonts used. If you render a LaTeXString type in Makie, it will layout the glyphs using MathTeXEngine.jl which will use Computer Modern fonts for that. So your question could relate to how you can adjust the fonts of all other non-LaTeXString text items to match. The easiest would be to pass different default fonts. That can be done using the `fonts` attribute like `fonts = (; regular = x, bold = y)` as described here [Fonts · Makie](https://docs.makie.org/stable/documentation/fonts/index.html#symbol)

Another interpretation would be that you want all text to go through MathTeXEngine layouting. This doesn’t really make sense for non latex expressions but at least for ticks you could get there by replacing `xtickformat` and `ytickformat` in the theme with functions returning `LaTeXString`s.

The third interpretation is that you want real latex, but currently MakieTeX.jl is not functional so this isn’t possible right now.

---

<div class="post-metadata">

### Author: ![danieleavitabile](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danieleavitabile/32/31966_2.png) [@danieleavitabile](https://discourse.julialang.org/u/danieleavitabile)
#### Post date: [August 6, 2023, 8:07am UTC](https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529/3 "2023-08-06T08:07:59Z")

</div>

Thank you @jules for your response. I agree the question was not clear. I would like having plots in which any text displayed in the figure (including axis title, axis labels, legends, numbers annotations that I may write, and numbers displayed in the ticks) be displayed using in Computer Modern Roman.

Ideally, I would like to be able to change fonts if I want, but let’s say that for the time being I stick with Computer Modern Roman which is by far my go-to font for publications.

The examples presented in the [documentation](https://docs.makie.org/stable/documentation/latex/) get me only so far, because the numbers in the ticks are not in the correct font.

The example you indicate makes me override the current figure defaults. I would like to call some command at the beginning of the following minimal example so that all non-LaTeX strings are Computer Modern Roman. Is there such a command?

```julia
module TestLaTeXFigure

using CairoMakie

x = LinRange(-pi,pi,100)
f, ax = lines(x,cos.(x),label=L"The function $y(x)=\sin(x)$")
axislegend()
ax.xlabel = L"x"
ax.ylabel = L"y"
ax.title = "This is a test title"
display(f)

end

```

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [August 6, 2023, 5:57pm UTC](https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529/4 "2023-08-06T17:57:47Z")

</div>

For example using `set_theme!`, you can also pass the `fonts` setting via `with_theme` or to the `Figure` constructor.

```julia
MT = Makie.MathTeXEngine
mt_fonts_dir = joinpath(dirname(pathof(MT)), "..", "assets", "fonts", "NewComputerModern")

set_theme!(fonts = (
    regular = joinpath(mt_fonts_dir, "NewCM10-Regular.otf"),
    bold = joinpath(mt_fonts_dir, "NewCM10-Bold.otf")
))

x = LinRange(-pi,pi,100)
f, ax = lines(x,cos.(x),label=L"The function $y(x)=\sin(x)$")
axislegend()
ax.xlabel = L"x"
ax.ylabel = L"y"
ax.title = "This is a test title"
f

```

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/3/f/3f22a7fc18b8782df02ed6347dbd8c9f95807fbf.png)

---

<div class="post-metadata">

### Author: ![danieleavitabile](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danieleavitabile/32/31966_2.png) [@danieleavitabile](https://discourse.julialang.org/u/danieleavitabile)
#### Post date: [August 6, 2023, 6:57pm UTC](https://discourse.julialang.org/t/makie-jl-latex-ticks-and-other-elements-by-default/102529/5 "2023-08-06T18:57:33Z")

</div>

Thank you, this is excellent.
