mdmath icon indicating copy to clipboard operation
mdmath copied to clipboard

how to auto-number and quote math formula?

Open dualer opened this issue 3 years ago • 6 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: ___

dualer avatar Jul 15 '21 02:07 dualer

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.

carneeki avatar Jul 25 '21 23:07 carneeki

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.

dualer avatar Jul 26 '21 07:07 dualer

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 avatar Jul 26 '21 07:07 carneeki

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

dualer avatar Jul 27 '21 13:07 dualer

So, how to quote math formula?

winterant avatar Dec 13 '21 08:12 winterant

@winterant

Reference: https://github.com/KaTeX/KaTeX/issues/2003#issuecomment-843991794

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}{}"
},

JoeyTeng avatar Oct 30 '22 10:10 JoeyTeng