LaTeX-syntax in docstrings with `DocStringExtensions.jl`

You could use a custom string macro instead of raw"...", similar to LaTeXStrings.jl which allows both unescaped \ and variable interpolation with %$:

julia> using LaTeXStrings

julia> foo = 7
7

julia> L"""
       foo = %$foo

       an equation $\sqrt{\frac{1}{1+x^2}}$.
       """
L"foo = 7

an equation $\sqrt{\frac{1}{1+x^2}}$.
"

e.g.

macro myL_str(s::String)
    i = firstindex(s)
    buf = IOBuffer(maxsize=ncodeunits(s))
    ex = Expr(:call, :string)
    while i <= ncodeunits(s)
        c = @inbounds s[i]
        i = nextind(s, i)
        if c === '$' && i <= ncodeunits(s)
            position(buf) > 0 && push!(ex.args, String(take!(buf)))
            atom, i = Meta.parseatom(s, i, filename=string(__source__.file))
            Meta.isexpr(atom, :incomplete) && error(atom.args[1])
            atom !== nothing && push!(ex.args, atom)
            continue
        else
            print(buf, c)
        end
    end
    position(buf) > 0 && push!(ex.args, String(take!(buf)))
    return esc(ex)
end

which should do what you want (supports interpolation with $ and supports unescaped backslashes), I think.