michael-brade / LaTeX.js

JavaScript LaTeX to HTML5 translator
https://latex.js.org
MIT License
783 stars 59 forks source link

CustomMacros and math display mode? #156

Open gosanon opened 1 month ago

gosanon commented 1 month ago

I created a macro which should transform one string to another. If I try to render such string: "\mymacro$\mymacro$", it works in first part but second part renders as a red "\mymacro" text instead of what it should have been transformed to. I read generator/htmlgenerator source code and came to a conclusion that it won't render because math pieces of the document are rendered via katex and my macros are not sent there. Is it true? If so, what would you recommend to create math mode macros? If not, why won't the macro render in math mode? Also, I believe #126 was a question about that.

gosanon commented 1 month ago

I just noticed \newcommand works in math mode as expected. I'll write a wrapper to create "math" macros using it. But I still don't quite understand if CustomMacros should work in math display mode by design