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

cannot use macro \newcommand #103

Open
hleiaa opened this issue Nov 22, 2023 · 1 comment
Open

cannot use macro \newcommand #103

hleiaa opened this issue Nov 22, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@hleiaa
Copy link

hleiaa commented Nov 22, 2023

I understand that we can specify latex macros in a "macros.txt" file. Also, it seems that LaTeX macro commands do not work at this time.

A minimal example:

$$
\newcommand{\RR}{\mathbb{R}}
$$

Real numbers: $\RR$ and $\mathbb{R}$.

The above example does not work. As katex has support for \newcommand, is it possible to use that feature?

Rationale: I mostly write in vscode and wish to publish using mdbook. The above example works fine with vscode markdown preview, which is also powered by katex.

@SichangHe
Copy link
Collaborator

Hi @hleiaa,

I remember this problem. TLDR; Please put all the macros in a file and configure mdBook-KaTeX to use it.

My attempt to add an option to process each chapter in serial to fix this: https://github.com/lzanini/mdbook-katex/tree/parallel-chapter-option.
It does not work in my testing.

In theory, if the same JS engine processes two blocks, it should remember what happened in the first block when running the second one. I thought that was the case because we use katex-rs, which has one JS engine per thread, but there seems to be something else wrong.

Maybe you could look a bit into this if you want, or consult the katex-rs people. I probably won't have time for major investigation until the end of next month.

Steven Hé (Sīchàng)

@SichangHe SichangHe added enhancement New feature or request help wanted Extra attention is needed labels Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants