mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 20:28:38 +00:00
Add bra-ket notation (#2162)
* Add bra-ket notation * Fix typo * Remove ketbra * Remove ketbra, add Bra and Ket * Add Bra/Ket and fix a typo in bra's source * Fix bra-ket typo in docs * Fix bra-ket escape typo in docs * Replace bra-ket pipe with \vert in docs
This commit is contained in:
committed by
Kevin Barabash
parent
800cdb2d23
commit
4b905064ab
@@ -183,6 +183,9 @@ table td {
|
|||||||
|\boxminus|$\boxminus$||
|
|\boxminus|$\boxminus$||
|
||||||
|\boxplus|$\boxplus$||
|
|\boxplus|$\boxplus$||
|
||||||
|\boxtimes|$\boxtimes$||
|
|\boxtimes|$\boxtimes$||
|
||||||
|
|\Bra|$\left\langle\psi\right\|$|`\Bra{\psi}`|
|
||||||
|
|\bra|$\mathinner{\langle{\psi}\|}$|`\bra{\psi}`|
|
||||||
|
|\braket|$\mathinner{\langle{\phi\|\psi}\rangle}$|`\braket{\phi|\psi}`|
|
||||||
|\brace|${n\brace k}$|`{n\brace k}`|
|
|\brace|${n\brace k}$|`{n\brace k}`|
|
||||||
|\bracevert|<span style="color:firebrick;">Not supported</span>||
|
|\bracevert|<span style="color:firebrick;">Not supported</span>||
|
||||||
|\brack|${n\brack k}$|`{n\brack k}`|
|
|\brack|${n\brack k}$|`{n\brack k}`|
|
||||||
@@ -511,6 +514,8 @@ use `\ce` instead|
|
|||||||
|\KaTeX|$\KaTeX$||
|
|\KaTeX|$\KaTeX$||
|
||||||
|\ker|$\ker$||
|
|\ker|$\ker$||
|
||||||
|\kern|$I\kern-2.5pt R$|`I\kern-2.5pt R`|
|
|\kern|$I\kern-2.5pt R$|`I\kern-2.5pt R`|
|
||||||
|
|\Ket|$\left\|\psi\right\rangle$|`\Ket{\psi}`|
|
||||||
|
|\ket|$\mathinner{\|{\psi}\rangle}$|`\ket{\psi}`|
|
||||||
|\Koppa|<span style="color:firebrick;">Not supported</span>||
|
|\Koppa|<span style="color:firebrick;">Not supported</span>||
|
||||||
|\koppa|<span style="color:firebrick;">Not supported</span>||
|
|\koppa|<span style="color:firebrick;">Not supported</span>||
|
||||||
|
|
||||||
|
@@ -510,6 +510,15 @@ Direct Input: $← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣
|
|||||||
|
|
||||||
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
Extensible arrows all can take an optional argument in the same manner<br>as `\xrightarrow[under]{over}`.
|
||||||
|
|
||||||
|
## Special Notation
|
||||||
|
|
||||||
|
**Bra-ket Notation**
|
||||||
|
|
||||||
|
||||
|
||||||
|
|:----------|:----------|:----------|
|
||||||
|
|$\bra{\phi}$ `\bra{\phi}` |$\ket{\psi}$ `\ket{\psi}` |$\braket{\phi\vert\psi}$ `\braket{\phi\vert\psi}` |
|
||||||
|
|$\Bra{\phi}$ `\Bra{\phi}` |$\Ket{\psi}$ `\Ket{\psi}` ||
|
||||||
|
|
||||||
## Style, Color, Size, and Font
|
## Style, Color, Size, and Font
|
||||||
|
|
||||||
**Class Assignment**
|
**Class Assignment**
|
||||||
|
@@ -930,6 +930,16 @@ defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}");
|
|||||||
defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
|
defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
|
||||||
defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits");
|
defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits");
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// braket.sty
|
||||||
|
// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
|
||||||
|
|
||||||
|
defineMacro("\\bra", "\\mathinner{\\langle{#1}|}");
|
||||||
|
defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
|
||||||
|
defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
|
||||||
|
defineMacro("\\Bra", "\\left\\langle#1\\right|");
|
||||||
|
defineMacro("\\Ket", "\\left|#1\\right\\rangle");
|
||||||
|
|
||||||
// Custom Khan Academy colors, should be moved to an optional package
|
// Custom Khan Academy colors, should be moved to an optional package
|
||||||
defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
|
defineMacro("\\blue", "\\textcolor{##6495ed}{#1}");
|
||||||
defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
|
defineMacro("\\orange", "\\textcolor{##ffa500}{#1}");
|
||||||
|
@@ -3312,6 +3312,26 @@ describe("A macro expander", function() {
|
|||||||
it("should expand \\argmax as expected", () => {
|
it("should expand \\argmax as expected", () => {
|
||||||
expect`\argmax`.toParseLike`\operatorname*{arg\,max}`;
|
expect`\argmax`.toParseLike`\operatorname*{arg\,max}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should expand \\bra as expected", () => {
|
||||||
|
expect`\bra{\phi}`.toParseLike`\mathinner{\langle{\phi}|}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should expand \\ket as expected", () => {
|
||||||
|
expect`\ket{\psi}`.toParseLike`\mathinner{|{\psi}\rangle}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should expand \\braket as expected", () => {
|
||||||
|
expect`\braket{\phi|\psi}`.toParseLike`\mathinner{\langle{\phi|\psi}\rangle}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should expand \\Bra as expected", () => {
|
||||||
|
expect`\Bra{\phi}`.toParseLike`\left\langle\phi\right|`;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should expand \\Ket as expected", () => {
|
||||||
|
expect`\Ket{\psi}`.toParseLike`\left|\psi\right\rangle`;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("\\tag support", function() {
|
describe("\\tag support", function() {
|
||||||
|
Reference in New Issue
Block a user