Closed skydog23 closed 10 months ago
Currently JekTex is build using KaTeX so it has same limitations. I will look into KaTeX documentation if macro arguments are supported. If macro arguments are supported it will be easy fix otherwise it will be a lot of work.
This feature looks interesting and useful. I promise to try my best. Unfortunately I can not promise deadline because next week exam season starts at my university. I hope you understand.
Thank you for great feature idea.
I did some digging and found out that KaTeX supports marcos with arguments and current JekTeX implementation is compatible with them!
You can define your macro in _config.yml
:
jektex:
macros:
- ["\\vec", "\\mathbf{#1}"]
- ["\\addBar", "\\bar{#1}"]
it renders this: $$ \vec{a} + \bar{b} $$
like this:
Does this meet your expectations ?
Source: KaTeX/discussions/2589
It works for me too, thanks very much for the quick answer.
On Sun, Jan 7, 2024 at 12:50 AM Jan Černý @.***> wrote:
I did some digging and found out that KaTeX supports marcos with arguments and current JekTeX implementation is compatible with them!
You can define your macro in _config.yml:
jektex: macros:
- ["\vec", "\mathbf{#1}"]
- ["\addBar", "\bar{#1}"]
it renders this: $$ \vec{a} + \bar{b} $$ like this: image.png (view on web) https://github.com/yagarea/jektex/assets/14349169/8acdde1b-fbea-49a6-bb13-4965efee8073
Does this meet your expectations ?
Source: KaTeX/discussions/2589 https://github.com/KaTeX/KaTeX/discussions/2589
— Reply to this email directly, view it on GitHub https://github.com/yagarea/jektex/issues/4#issuecomment-1879880908, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7F3IZS7GRN2UFFYILB3TDYNHPLRAVCNFSM6AAAAABBPW4SPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZZHA4DAOJQHA . You are receiving this because you authored the thread.Message ID: @.***>
Awesome! I added example of macros with parameters to README and now I am closing this issue.
Thank you for this issue.
PS: If you like this project consider giving its repository a star and sharing it.
It appears that the macro facility in jektex is similar to the \def command of LaTeX. It's certainly useful. However, it doesn't allow for arguments.
That would be useful, for example, to set up a single definition for how to format vectors, for example, and to change it simply by changing the macro in the _config.yml file
This for example is given by the \newcommand command in LaTeX, e.g., \newcommand{\vec}[1]{\mathbf{#1}} has the effect that \vec{X} will convert to \mathbf{X} no matter what X is.
Could the macro facility in jektex be expanded to include such a syntax?