goessner / mdmath

LaTeX Math for Markdown inside of Visual Studio Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to auto-number and quote math formula?

dualer opened this issue · comments

Summary

I have a very basic question: how can we auto-number and quote math formulas through this extension? I find katex is supported to auto-number math formulas, but mdmath seems to don't support it. As for quoting math formulas, I cannot find how to do this, the following code don't work:

$$
\pi \tag{1}\label{1}
$$

eq.$\eqref{1}$

...

Expected behavior

...

Actual behavior

...

Steps to reproduce

  1. First step
  2. Second step
  3. Third step

Code example

Some markdown code ...

... with issues.

Related links

Environment

     Operating system: ___
       VSCode version: ___
Markdown+Math version: ___
commented

I use align environments to get eq numbering.

$$
\begin{align}
f'(x) &= \lim_{h \to 0} \frac{f(x+h)-f(x)}{h}
\end{align}
$$

Edit: I just tried using a label, but it renders with an error. It could be I haven't got amsmath to use it.

I use align environments to get eq numbering.

$$
\begin{align}
f'(x) &= \lim_{h \to 0} \frac{f(x+h)-f(x)}{h}
\end{align}
$$

Are you sure? It doesn't work for me.

commented

image

Here's (some of) the extensions and versions I have installed

  • VSCode version v1.58.2
  • mdmath version v2.7.4
  • markdownlint v0.42.1

@carneeki When I disable the related function of markdown math, it works. Thanks for your detailed explanation.

So, how to quote math formula?

@winterant

Reference: KaTeX/KaTeX#2003 (comment)

I added the following settings into my VSCode settings.json, and it seems rendering fine in the preview.

"mdmath.katexoptions": {
    "trust": "(context) => ['\\htmlId', '\\href'].includes(context.command)"
},
"mdmath.macros": {
    "\\eqref": "\\href{###1}{(\\text{#1})}",
    "\\ref": "\\href{###1}{\\text{#1}}",
    "\\label": "\\htmlId{#1}{}"
},