-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: Add commonly used physics macros #3700
base: main
Are you sure you want to change the base?
Conversation
Hi maintainers, GitHub said I "need a maintainer to approve running workflows". 🙂 |
Codecov Report
@@ Coverage Diff @@
## main #3700 +/- ##
==========================================
+ Coverage 92.97% 92.99% +0.01%
==========================================
Files 91 91
Lines 6765 6781 +16
Branches 1571 1571
==========================================
+ Hits 6290 6306 +16
Misses 437 437
Partials 38 38
Continue to review full report at Codecov.
|
Ping reviewers... 🙂 |
Ping reviewers..🙂 (x2) |
Ping reviewers...🙂 (x3) |
Ping reviewers...🙂 (x4) |
Ping reviewers...🙂(x5) |
Any plan to add a derivative shortcut like in the physics package: |
Nope.. If anyone volunteers, feel free to fork this PR. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to take forever to review this. I'm now trying to catch up on old PRs. This one looks like a good start, but there are a lot of small incompatibilities with physics.sty
, and we'd rather stick to exact LaTeX behavior. Hope you're still interested in seeing this through. You should probably look at the physics.sty
source code if you haven't already.
defineMacro("\\abs", "\\lvert{#1}\\rvert"); | ||
defineMacro("\\Abs", "\\Big\\lvert{#1}\\Big\\rvert"); | ||
defineMacro("\\norm", "\\lVert{#1}\\rVert"); | ||
defineMacro("\\Norm", "\\Big\\lVert{#1}\\Big\\rVert"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see \Abs
or \Norm
in physics.sty
. Also, it seems that \abs
and \norm
generally use \left
and \right
, with the ability to customize size via a second argument as in \abs\Big
. I could see skipping the latter feature in a first version, but I don't think the current definitions match any partial feature from physics.sty
.
defineMacro("\\gradient", "\\mathinner{\\nabla{#1}}"); | ||
defineMacro("\\laplacian", "\\mathinner{\\nabla^2{#1}}"); | ||
defineMacro("\\divergence", "\\mathinner{\\nabla\\dotproduct{#1}}"); | ||
defineMacro("\\curl", "\\mathinner{\\nabla\\crossproduct{#1}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment that this doesn't support the (...)
form of \curl
.
defineMacro("\\dotproduct", "\\cdot"); | ||
defineMacro("\\crossproduct", "\\times"); | ||
defineMacro("\\dd", "\\textnormal{d}"); | ||
defineMacro("\\gradient", "\\mathinner{\\nabla{#1}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the \grad
alias?
defineMacro("\\vectorarrow", "\\overrightarrow{\\vb{#1}}"); | ||
defineMacro("\\vectorunit", "\\widehat{\\vb{#1}}"); | ||
defineMacro("\\dotproduct", "\\cdot"); | ||
defineMacro("\\crossproduct", "\\times"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physics.sty
seems to use \boldsymbol\times
.
Also, should we add the \cp
and \cross
aliases?
defineMacro("\\vectorunit", "\\widehat{\\vb{#1}}"); | ||
defineMacro("\\dotproduct", "\\cdot"); | ||
defineMacro("\\crossproduct", "\\times"); | ||
defineMacro("\\dd", "\\textnormal{d}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment that this does not support the optional power argument.
defineMacro("\\Abs", "\\Big\\lvert{#1}\\Big\\rvert"); | ||
defineMacro("\\norm", "\\lVert{#1}\\rVert"); | ||
defineMacro("\\Norm", "\\Big\\lVert{#1}\\Big\\rVert"); | ||
defineMacro("\\eval", "\\Big\\vert_{#1}^{#2}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this matches physics.sty
's \eval
at all.
defineMacro("\\norm", "\\lVert{#1}\\rVert"); | ||
defineMacro("\\Norm", "\\Big\\lVert{#1}\\Big\\rVert"); | ||
defineMacro("\\eval", "\\Big\\vert_{#1}^{#2}"); | ||
defineMacro("\\vb", "\\bold{#1}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physics.sty
seems to use \boldsymbol
, so we should match that.
defineMacro("\\eval", "\\Big\\vert_{#1}^{#2}"); | ||
defineMacro("\\vb", "\\bold{#1}"); | ||
defineMacro("\\vectorbold", "\\vb{#1}"); | ||
defineMacro("\\vectorarrow", "\\overrightarrow{\\vb{#1}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physics.sty
seems to use \vec
instead of \overrightarrow
.
defineMacro("\\vb", "\\bold{#1}"); | ||
defineMacro("\\vectorbold", "\\vb{#1}"); | ||
defineMacro("\\vectorarrow", "\\overrightarrow{\\vb{#1}}"); | ||
defineMacro("\\vectorunit", "\\widehat{\\vb{#1}}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physics.sty
seems to use \hat
instead of \widehat
.
defineMacro("\\vectorbold", "\\vb{#1}"); | ||
defineMacro("\\vectorarrow", "\\overrightarrow{\\vb{#1}}"); | ||
defineMacro("\\vectorunit", "\\widehat{\\vb{#1}}"); | ||
defineMacro("\\dotproduct", "\\cdot"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physics.sty
seems to use \boldsymbol\cdot
.
Also, should we add the \vdot
alias?
Hi! Sorry I don't have enough bandwidth at the moment.. but feel free to copy this PR and modify it if anyone (or you) is interested! |
Support commonly used macros from the$\LaTeX$ physics package. Demo.
ops.js ('yarn start' URL):
\rank
\Res
\tr
,\Tr
,\trace
macros.js ('yarn start' URL):
\abs
,\Abs
\norm
,\Norm
\eval
\vb
,\vectorbold
\vectorarrow
\vectorunit
\dotproduct
,\crossproduct
\dd
\gradient
,\laplacian
\divergence
,\curl