Pluto Markdown Not Working

Hello,

I am trying to emulate the markdown in the Pluto NB shown here.

Here’s what it looks like in my notebook.

begin
	Cmin=10.0; Cmax=200.;
	Cslider = @bind SlideValC Slider(Cmin:0.1:Cmax, default=51);
	md" $(Cmin) J/m^2/K $(Cslider) $(Cmax)$"
end

But this results in the following, which does not look right and furthermore has no slider for me to manipulate.
image

How can I get it render to correctly? What am I doing wrong? I tried with triple quotes and it makes no difference.

I’m using the following packages
Plots, PlutoUI, OffsetArrays, LaTeXStrings, Markdown
Also, if it matters, I am using Firefox

This isn’t actually a Pluto issue, it’s just a clash between Julia’s string interpolation using a single $ and inserting LaTeX into markdown with paired $$. Usually, a bunch of characters without spaces between $$ will be interpreted as LaTeX, e.g. the $C(max)$ at the end of your string (although the actual rules for what gets interpreted as what are not super straightforward).

Actually, the syntax highlighting here is also giving you a hint that the last $ at the end is not needed. If you remove it, it renders correctly:

begin
	Cmin=10.0; Cmax=200.;
	Cslider = @bind SlideValC Slider(Cmin:0.1:Cmax, default=51);
	md" $(Cmin) J/m^2/K $(Cslider) $(Cmax)"
end

image

Thanks!

How would I get the units to display as LaTeX? Manually insert a superscript 2 somehow on the meters?

I’m not sure if it will work with LaTeX, but if it’s just the superscript 2, you could always just insert the superscript manually, via \^2<tab> shortcut.

Hm - am I taking the wrong approach here? Should I even be trying to typeset the superscript with LaTeX? It was natural for me to try to express the units using LaTeX within a piece of markdown, since the expression superscripts. But should I be trying to use the build-in short cuts you mention? (didn’t even realize you use them for stuff besides inserting greek characters).

No, LaTeX should be the preferred way, but it can be hard to get it working with the standard $ delimiters.

Actually, it turns out that Julia’s flavor of Markdown supports using double backticks to surround LaTeX, so your line from above is better written as

md" $Cmin ``J/m^2/K`` $(Cslider) $(Cmax)"

which renders as
image

2 Likes

Thanks - that link is very helpful.

I think units are generally typeset upstraight (unlike the slanted mathmode), as in the SI Unit package for LaTeX. So you might prefer to use plain markdown for them, like J m⁻² K⁻¹ maybe?

1 Like