Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Conversation

qnxor
Copy link
Contributor

@qnxor qnxor commented May 18, 2022

See https://katex.org/docs/api.html#persistent-macros

Katex allows using \gdef, \def, \newcommand and the likes. However, if some \gdef\root{\sqrt} is defined in some math expression then it won't be recognized in subsequent math expressions unless katex.render() is called as in this PR (in my view this should be default behavior in Katex, as it's expected standard Latex behavior, but alas).

Basically, this PR allows one to define macros at the top of a post, then reuse them as many times as they wish afterwards (should work for subsequent posts too, though I haven't tested that) e.g.:

$\gdef\mylim{\lim\limits_{n\to\infty}}$

Text...

$$
\mylim \ln(1+x^n)=0
$$

More text reusing the macro inline $\mylim c_n = 1$.

And so on...

@CvX CvX requested a review from pmusaraj June 7, 2022 10:11
Copy link
Contributor

@pmusaraj pmusaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @qnxor!

@pmusaraj pmusaraj merged commit 4b4ad9d into discourse:main Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants