feat: Support \Braket, \set, and \Set (#3214)

* feat: Support \Braket, \set, and \Set

* Update screenshots.

* Rewrite to redefine | via macros

* Update screenshot after merge

* Rename \bra@ket@one -> \bra@set

* Fix spacing in \set and \Set to match braket.sty

* Add || and \| support

* Update tests

* Update screenshots

Co-authored-by: Ron Kok <ronkok@comcast.net>
This commit is contained in:
Erik Demaine
2022-05-20 13:26:04 -04:00
committed by GitHub
parent 8319467151
commit 9e3ae4d5a8
10 changed files with 89 additions and 4 deletions

View File

@@ -3610,6 +3610,26 @@ describe("A macro expander", function() {
it("should expand \\Ket as expected", () => {
expect`\Ket{\psi}`.toParseLike`\left|\psi\right\rangle`;
});
it("should expand \\Braket as expected", () => {
expect`\Braket{ ϕ | \frac{∂^2}{∂ t^2} | ψ }`.toParseLike`\left\langle ϕ\,\middle\vert\,\frac{∂^2}{∂ t^2}\,\middle\vert\, ψ\right\rangle`;
});
it("should expand \\set as expected", () => {
expect`\set{x|x<5|S|}`.toParseLike`\{\,x\mid x<5|S|\,\}`;
// \set doesn't support special || or \| handling
expect`\set{x||x<5|S|}`.toParseLike`\{\,x\mid |x<5|S|\,\}`;
expect`\set{x\|x<5|S|}`.toParseLike`\{\,x\|x<5\mid S|\,\}`;
});
it("should expand \\Set as expected", () => {
expect`\Set{ x | x<\frac 1 2 |S| }`
.toParseLike`\left\{\: x\;\middle\vert\; x<\frac 1 2 |S| \:\right\}`;
expect`\Set{ x || x<\frac 1 2 |S| }`
.toParseLike`\left\{\: x\;\middle\Vert\; x<\frac 1 2 |S| \:\right\}`;
expect`\Set{ x \| x<\frac 1 2 |S| }`
.toParseLike`\left\{\: x\;\middle\Vert\; x<\frac 1 2 |S| \:\right\}`;
});
});
describe("\\tag support", function() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -119,12 +119,12 @@ DeepFontSizing:
nolatex: \Huge inside \dfrac doesn't work, needs an extra {…}
DelimiterSizing: |
\bigl\uparrow\Bigl\downarrow\biggl\updownarrow
\Biggl\Uparrow\Biggr\Downarrow\biggr\langle\Bigr\}\bigr\rfloor \\
\Biggl\Uparrow\Biggr\Downarrow\biggr\langle\Bigr\}\bigr\rfloor\; \Set{ x | x<\frac 1 2 } \\
\begin{pmatrix}
a & b & c\\
a & b & c\\
a & b & c\\
\end{pmatrix}
\end{pmatrix}\; \Braket{ ϕ | \frac{∂^2}{∂ t^2} | ψ } \\
DisplayMode:
tex: \sum_{i=0}^\infty \frac{1}{i}
pre: pre