Feature request: more ergonomic LaTeX input

At the moment, I’m writing math prose like so:

md`The map sends ${tex`x \in X`} to ${tex`f(x) \in Y`}.`

It would be supes cool if we could enter math like in the kramdown or Pandoc markdown dialects. That would make the previous snippet look like:

md`The map sends $x \in X$ to $f(x) \in Y$.`


You can do this by writing your own tagged template literal function, or import the one shown here:

(Though a downside of the texmd approach is you can’t take advantage of single backslashes for LaTeX, since they are embedded within the Markdown template literal.)


That’s exactly what I was looking for, thanks!

Mike, can you add the suggestion to use markup like:

md`Some text description with an embedded formula, ${tex`x^2 + y^2`}, etc.`

To the introduction to html notebook?

There’s already this example:

md`I like Markdown for prose, but ${tex`\KaTeX`} for math.`

Do you think it needs further explanation?

Oh, somehow I missed that one entirely (and it looks like @kelleyvanevert might have missed it as well before making her notebook with a workaround?). Maybe add another example down where discussing equations as well?

I recommend also adding the keyword “LaTeX” somewhere in there for people searching in the page, as most people have no idea what KaTeX is.

For what it’s worth, for me personally, that method is plenty ergonomic, and I don’t imagine typically needing anything more streamlined.

When we first launched, the md, html and svg literals didn’t allow embedding of arbitrary DOM in expressions. This feature was added later, as described here:

One more note. Not sure where to put this, but it doesn’t seem worth making a new issue.

I started adding <style> .katex { font-size: 1.08em; } </style> to my title cells. This makes the size of inline LaTeX match the surrounding content much more closely. The current default size is like 1.25em or something very dramatically large.

1 Like

See my fork for a version that fixes one major problem that I ran into, namely that you couldn’t use a ${} substitution inside texmd`` if that substitution returned a DOM node instead of plain text