# How do you control the font size of a figure that is used in an academic publication?

**URL:** <https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713>\
**Category:** Visualization\
**Tags:** question, latex, makie\
**Created:** [August 1, 2024, 3:33am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713 "2024-08-01T03:33:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [August 1, 2024, 3:33am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/1 "2024-08-01T03:33:09Z")

</div>

Hi, everyone! I wonder how do you control the font size of a figure that is used in an academic publication, for example, if we plot the figure with `Makie` and write a paper with `LaTex`?

Usually, we can tune in Julia both the size of a figure and the font size in it, and in LaTex we can also tune the size of the inserted figure using e.g., `\includegraphics[width=0.6\textwidth]{figure.pdf}`. So there seems to be so much freedom here that it’s hard to control the exact size of the final font, so I have to draw and render repeatedly to achieve an imprecise subjective trade-off, rather than having a uniform font size for all figures in one paper. I guess that’s hardly the right way to do this. So I would like to consult the experienced seniors here, is there a better standardized practice?

Thanks!

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [August 1, 2024, 5:43am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/2 "2024-08-01T05:43:28Z")

</div>

With Makie this is rather easy. There was just a thread the other day:

> [@Figure and font size when using \`Plots\`](https://discourse.julialang.org/t/figure-and-font-size-when-using-plots/117611/8):
>
> Ah, my mistake was using pt\_per\_unit in the wrong place… it should be used when saving the PDF. So it was using the default value (0.75). I can also use one of the default themes instead of specifying the font myself. Here is the solution that works. using CairoMakie x = 0:0.01:2π y = cos.(x); pt\_per\_unit = 1 figsizeinches(width, height) = (width, height) .\* (72/pt\_per\_unit) height = 2.5 # inches width = 4.5 # inches fontsize = 10 set\_theme!(theme\_latexfonts(); fontsize) f = Figure(; size…

It is also explained in the documentation:

> **[Figures | Makie](https://docs.makie.org/stable/explanations/figure#Matching-figure-and-font-sizes-to-documents)**
>
> Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and...

The only thing missing is that you need to set pt\_per\_unit when _saving_ and not upon creation of the `Figure`.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [August 1, 2024, 8:19am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/3 "2024-08-01T08:19:36Z")

</div>

Thank you! I’ll have a look. 🤝

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 1, 2024, 8:36am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/4 "2024-08-01T08:36:52Z")

</div>

This might not suit everyone, but for optimal control and perfect integration of figures in LaTeX documents, you cannot beat pgfplotsx.jl. It actually generates LaTeX code, so that the figure is compiled and generated by TeX/LaTeX itself.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [August 1, 2024, 8:49am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/5 "2024-08-01T08:49:02Z")

</div>

Interesting. Thanks!

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 1, 2024, 8:59am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/6 "2024-08-01T08:59:05Z")

</div>

Just as an example. Makie.jl only supports Computer Modern, the default LaTeX font (as far as I can tell), while with PgfPlotsX.jl the figure font will match the font of your document, or in fact use any other typeface/size/weight that LaTeX itself supports. If you use Computer Modern in your document, it might not be a big deal, but if you don’t it’s a big advantage.

Another cool thing, is that if you resize your figure (e.g. by changing the value in `\includegraphics[width=0.6\textwidth]`), the fonts are not affected.

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [August 1, 2024, 10:03am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/7 "2024-08-01T10:03:25Z")

</div>

> [@DNF](#):
>
> Just as an example. [Makie.jl](https://juliahub.com/ui/Packages/General/Makie) only supports Computer Modern

You can load/use other fonts with Makie:

> **[Fonts | Makie](https://docs.makie.org/v0.21/explanations/fonts)**
>
> Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and...

Sure this is not as automatic as with pgfplots

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 1, 2024, 11:22am UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/8 "2024-08-01T11:22:00Z")

</div>

Thanks for the correction. I tried to verify my claim, and found several places saying only Computer Modern was supported, but those must be out of date.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [August 1, 2024, 12:20pm UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/9 "2024-08-01T12:20:04Z")

</div>

Only Computer Modern is supported for Latex rendering, since MathTexEngine needs some adjustments per font: [[FEATURE]? Is there a way to use different fonts in LaTeXStrings? · Issue #53 · Kolaru/MathTeXEngine.jl · GitHub](https://github.com/Kolaru/MathTeXEngine.jl/issues/53)  
It should be relatively easy to add more fonts, but nobody has stepped up yet to do that.  
Makie itselfs supports any font you throw at it!

---

<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:** [August 1, 2024, 1:28pm UTC](https://discourse.julialang.org/t/how-do-you-control-the-font-size-of-a-figure-that-is-used-in-an-academic-publication/117713/10 "2024-08-01T13:28:37Z")

</div>

I think `@kolaru` switched to

```julia
Currently available are
- NewComputerModern
- TeXGyreHeros

```

[ref](https://github.com/Kolaru/MathTeXEngine.jl/blob/6847fe7fc1b8a2974fef84dc5b59368bb030f5b0/src/engine/fonts.jl#L100)

for LaTeX. NewComputerModern has 3000+ glyphs, whereas ComputerModern (ComputerModern/cmmib10.ttf) has 134.

I don’t know what work is involved to support new fonts - if there were instructions … 🤔 🙂
