🏠 back to Observable

Writing LaTeX inside markdown

If I want to include LaTeX in a markdown literal string, I have to use ${...} to enter in javascript mode, then tex`` to generate the LaTeX formatted letter, eg:

md`The variable ${tex`t`} is the time and ${tex`x`} is the position.`

It’s a bit tedious if you have a lot of variables.

One solution is not to use LaTeX, and write them in normal font

md`The variable t is the time and x is the position.`

What would you do?

My preference is to use ${tex`t`} within Markdown or HTML literals. But if you find that tedious, you could use a wrapper like the following that uses $t$ for something like math mode.

Thanks, it’s exactly what I was looking for.

Thanks also for mentioning your preference. I imagine it’s due to the overhead of importing `texmd` and also adding a dependency that might break or diverge from `md` and `tex` implementations.

Personally I use $ as a shortcut for tex and $$ as a shortcut for tex.block.

So then TeX in markdown is ${$`f(x) = y`} or the like.