Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros do not work #114

Closed
rjmigliori opened this issue Jun 15, 2021 · 13 comments
Closed

Macros do not work #114

rjmigliori opened this issue Jun 15, 2021 · 13 comments

Comments

@rjmigliori
Copy link

rjmigliori commented Jun 15, 2021

Summary

The macro example from the Readme is not working. Identical to issue 63.

Expected behavior

Preview without errors.

Actual behavior

Red symbols \RR and \vek. Also \R renders mathbb{R} correctly, while \RR does not.

Steps to reproduce

  1. Add example config to settings.json
  2. Restart VS Code just in case
  3. Open existing workspace.
  4. Open existing .md file.
  5. Write some example latex code.
  6. Open markdown preview.

Code example

  1. settings.json section
    "mdmath.macros":{
        "\\RR":"\\mathbb{R}",
        "\\vek": "{\\begin{pmatrix}#1\\\\#2\\end{pmatrix}}",
        "\\test":"2+2"
    },
  1. .md file test section
\texttt{\textbackslash R \textbackslash RR \textbackslash test \textbackslash vek} \Rightarrow \R \RR \test \vek

Related links

Environment

     Operating system:  Windows 10 Enterprise x64
       VSCode version: 

    Version: 1.57.0 (user setup)
    Commit: b4c1bd0a9b03c749ea011b06c6d2676c8091a70c
    Date: 2021-06-09T17:18:42.354Z
    Electron: 12.0.9
    Chrome: 89.0.4389.128
    Node.js: 14.16.0
    V8: 8.9.255.25-electron.0
    OS: Windows_NT x64 10.0.18363

Markdown+Math version: 2.7.4
@goessner
Copy link
Owner

goessner commented Jun 17, 2021

Be sure to have ...

  • version 2.7.4 installed
  • closed and opened VSCode again after having changed settings.

For me

Vectors in $\RR^2$ have a shape of

$$\vek{x}{y}$$

gives
grafik

btw: KaTeX now supports \R natively, so macro \RR makes sense only for demonstration reasons.

@rjmigliori
Copy link
Author

Simply does not work for me, on two different computers too. Maybe it's an interaction with one of my installed extensions?

```math
\RR
```

$\RR$

$$
\RR
$$

Produces

image

settings.json section:

    "mdmath.delimiters": "gitlab",
    "mdmath.macros":{
        "\\RR":"\\mathbb{R}",
        "\\vek": "{\\begin{pmatrix}#1\\\\#2\\end{pmatrix}}",
        "\\test":"2+2"
    },

Extensions
image

@goessner
Copy link
Owner

goessner commented Jun 17, 2021

hmm ... please deactivate all markdown related extensions ... temporarily ...

@rjmigliori
Copy link
Author

Interesting, it's one of the extensions. Working on figuring out which one right now.

```math
\RR
```

$\RR$

$$
\RR
$$

Produces
image

Not sure why $\RR$ isn't working, but, progress?

@rjmigliori
Copy link
Author

rjmigliori commented Jun 17, 2021

It's the Markdown All In One extension.

Ugh I bet it's this, right in the Readme:

Please use Markdown+Math for dedicated math support. Be sure to disable math.enabled option of this extension.

@rjmigliori
Copy link
Author

Fixed.
Code:

```math
\RR \\
\vek{x}{y} \\
\test \\
```

Produces:
image

Settings:

  "markdown.extension.math.enabled": false, //<- This fixes the macro issue
  "mdmath.delimiters": "gitlab",
  "mdmath.macros":{
      "\\RR":"\\mathbb{R}",
      "\\vek": "{\\begin{pmatrix}#1\\\\#2\\end{pmatrix}}",
      "\\test":"2+2"
  },

Sorry for the trouble! Can close this, I think.

@goessner
Copy link
Owner

Thanks for successfully investigating this. Can you please do me a favor and raise an analog issue regarding macro collision there, while referencing your reproducable steps here ... thanks.

@rjmigliori
Copy link
Author

I'd be happy to do that, but I'm not exactly clear on what you mean? Could you clarify more precisely what you'd like me to do?

@goessner
Copy link
Owner

don't worry ... I did it by myself ... thanks again.

@rjmigliori
Copy link
Author

don't worry ... I did it by myself ... thanks again.

I have another problem, but I wanted to ask you about it before opening a whole issue. Is there any way to get latex macros to render with the markdown file uploaded to gitlab/github? I'm getting the error "There was an error rendering this math block," I assume because gitlab doesn't know how to interpret the macros without them being defined anywhere. Not sure how to resolve this, or if it's even possible?

@goessner
Copy link
Owner

goessner commented Jun 24, 2021

hmm ... macros are resolved in VSCode Markdown via mdmath via markdown-it-texmath via KaTeX. GitLab should have a completely different math engine. If that doesn't support macros, you are lost. GitHub doesn't have a math engine at all.

The only way I know is working, is to export HTML from mdmath to GitHub pages or something similar with GitLab.

@rjmigliori
Copy link
Author

hmm ... macros are resolved in VSCode Markdown via mdmath via markdown-it-texmath via KaTeX. GitLab should have a completely different math engine. If that doesn't support macros, you are lost. GitHub doesn't have a math engine at all.

The only way I know is working, is to export HTML from mdmath to GitHub pages or something similar with GitLab.

That's what I figured. How do you get github to render html (I looked into it a bit online but I'm wondering what your approach is)?

@afinedog
Copy link

I have an another trouble: MPE(markdown preview enhanced) doesn't support the macros. And it works when I disable it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants