# Makie: rich text, markdown?

**URL:** https://discourse.julialang.org/t/makie-rich-text-markdown/132650
**Category:** Visualization
**Tags:** question, makie, rich-text
**Created:** [September 25, 2025, 8:34am UTC](https://discourse.julialang.org/t/makie-rich-text-markdown/132650 "2025-09-25T08:34:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)
#### Post date: [September 25, 2025, 8:34am UTC](https://discourse.julialang.org/t/makie-rich-text-markdown/132650/1 "2025-09-25T08:34:48Z")

</div>

I’m looking for a way to produce rich text easily in `Makie` plots.

I know LaTeX strings work in Makie: [this thread.](https://discourse.julialang.org/t/nice-fonts-with-plots-gr-and-latexstrings/60037) But the LaTeX font (Computer Modern) is less legible than `Makie`’s default one. Its rich text produces more pleasant results, and it seems impossible to switch to a sans-serif font for `LaTeXStrings`. [See this thread.](https://discourse.julialang.org/t/can-i-change-the-latex-font-using-latexstring-package/97113)

Currently, I end up kind of building my ad-hoc tools:

```julia
using Makie

function Base.:*(x::Makie.RichText, y::Makie.RichText)
  rich(x, y)
end
function Base.:*(x::Makie.RichText, y::AbstractString)
  rich(x, y)
end
function Base.:*(x::AbstractString, y::Makie.RichText)
  rich(x, y)
end

itl(s) = rich(s, font=:italic)
paren(s) = "(" * s * ")"

ylabel = itl("c") * superscript(paren(itl("n"))) * " [m/s]"

```

In this example, I build the rich text « _c_(_n_) [m/s] », which in markdown is

```markdown
*c*<sup>(*n*)</sup> [m/s]

```

which is much nicer to write. So, I imagine one could write a converter from (a subset of ) markdown to rich text, which you could use as `ylabel = md2rich("*c*<sup>(*n*)</sup> [m/s]")`.

First of all, I don’t know whether this rich text capability is part of `Makie` or it is an independent library. If the latter is the case, is there a converter from, say, a subset of markdown to rich text?

Searching this forum, I’ve seen threads about converting markdown to HTML . . .

---

<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: [September 25, 2025, 9:32am UTC](https://discourse.julialang.org/t/makie-rich-text-markdown/132650/2 "2025-09-25T09:32:38Z")

</div>

This kind of works with the stdlib, but it doesn’t parse superscript or subscript syntax so you’d have to do something similar with CommonMark.jl or so

```julia
using Markdown

macro rich_str(str::String)
    quote
        md = Markdown.@md_str($str)
        markdown_to_rich(md)
    end
end

markdown_to_rich(x::Markdown.MD; italic = false, bold = false) = rich(markdown_to_rich.(x.content; italic, bold)...)
markdown_to_rich(x::Markdown.Paragraph; italic = false, bold = false) = rich(markdown_to_rich.(x.content; italic, bold)...)
markdown_to_rich(x::String; italic = false, bold = false) = rich(x; font = md_font(bold, italic))
markdown_to_rich(x::Markdown.Bold; italic = false, bold = false) = rich(markdown_to_rich.(x.text; italic, bold = !bold)...; font = md_font(!bold, italic))
markdown_to_rich(x::Markdown.Italic; italic = false, bold = false) = rich(markdown_to_rich.(x.text; italic = !italic, bold)...; font = md_font(bold, !italic))

function md_font(bold, italic)
    if bold
        if italic
            :bold_italic
        else
            :bold
        end
    else
        if italic
            :italic
        else
            :regular
        end
    end
end

f = Figure()
Axis(f[1, 1],
    xlabel = rich" **bold** and _italic_ and **_bold and italic_**",
)
f

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/7/272e8e803de8d707b2ab06aa90a2dd47e0aae003.png)
