Interpolate values inside math expression

I am trying to interpolate the value of an object inside a math equation in Pluto.
A MWE could be:

begin
    avg = 15
    md"""
        The average would be given by:

        ``\overline{X} = \frac{\sum_{i=1}^N X_i}{N} = $(avg)``
    """
end

However, I am not successful. It works if I move the interpolation to the outside of the math expression. However, this causes the math to display inline and the value to be formatted as plain text.
Can anyone help me?

You need to use CommonMark.jl:

Notice that you need to escape the \.

1 Like

Can’t you just use the Markdown stdlib? That’s what the md"..." macro uses, after all. For example:

import Markdown

Markdown.parse("""
```math
\\overline{X} = $avg
```
""")
1 Like

Thank you a lot!