Skip to content

Support OPTIONAL ARGUMENT in user defined macro by \newcommand #2228

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

Open
zq1997 opened this issue Mar 29, 2020 · 5 comments
Open

Support OPTIONAL ARGUMENT in user defined macro by \newcommand #2228

zq1997 opened this issue Mar 29, 2020 · 5 comments

Comments

@zq1997
Copy link

zq1997 commented Mar 29, 2020

Is your feature request related to a problem? Please describe.
It seems that optional arguments are not supportes by user defined \newcommand.
Just see the following code.

\newcommand \foo [2] [bar] {{#1}^{#2}}
\foo {1}
\foo [baz]{2}

image

Describe the solution you'd like:
Would this optional argumant feature be implemented just like \sqrtmacro? this is a predefined macro in KaTeX with optional argument support.

Link to or name of a (La)TeX package that provides the same feature:
N/A

Describe alternatives you've considered:
N/A

Additional context:
N/A

@edemaine
Copy link
Member

edemaine commented Jul 9, 2020

Indeed, this shouldn't be too hard to implement, because KaTeX already internally supports optional arguments (without default values). A small extension to \newcommand ought to do it. A pull request would be welcome; otherwise, I can try to get to it eventually...

@zq1997
Copy link
Author

zq1997 commented Jul 9, 2020

I am not very familiar with this project, hope for the pull request in the future.

Lemmingh referenced this issue in keineahnung2345/mit-18.06-linalg-notes Jul 10, 2021

Verified

This commit was signed with the committer’s verified signature.
\newcommand is not supported by KaTeX/KaTeX#250
@klimanek
Copy link

klimanek commented May 4, 2023

Any update on this? Does KaTeX support optional argument now?

@edemaine
Copy link
Member

edemaine commented May 4, 2023

Alas, no. When there are updates, they will appear here.

@aleeper
Copy link

aleeper commented Jan 26, 2025

Upvote and bump, for what it's worth 😅

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

No branches or pull requests

5 participants