mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 11:48:41 +00:00
Support {rcases} and {drcases} (#2149)
* Support {rcases} and {drcases} * Fix lint error * Update screenshots
This commit is contained in:
@@ -338,6 +338,7 @@ use `\ce` instead|
|
|||||||
|\downdownarrows|$\downdownarrows$||
|
|\downdownarrows|$\downdownarrows$||
|
||||||
|\downharpoonleft|$\downharpoonleft$||
|
|\downharpoonleft|$\downharpoonleft$||
|
||||||
|\downharpoonright|$\downharpoonright$||
|
|\downharpoonright|$\downharpoonright$||
|
||||||
|
|{drcases}|$\begin{drcases}a&\text{if }b\\c&\text{if }d\end{drcases}$|`\begin{drcases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{drcases}`|
|
||||||
|
|
||||||
## E
|
## E
|
||||||
|
|
||||||
@@ -847,6 +848,7 @@ use `\ce` instead|
|
|||||||
|\rBrace|$\rBrace$||
|
|\rBrace|$\rBrace$||
|
||||||
|\rbrace|$\rbrace$||
|
|\rbrace|$\rbrace$||
|
||||||
|\rbrack|$\rbrack$||
|
|\rbrack|$\rbrack$||
|
||||||
|
|{rcases}|$\begin{rcases}a&\text{if }b\\c&\text{if }d\end{rcases}$|`\begin{rcases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{rcases}`|
|
||||||
|\rceil|$\rceil$||
|
|\rceil|$\rceil$||
|
||||||
|\Re|$\Re$||
|
|\Re|$\Re$||
|
||||||
|\real|$\real$||
|
|\real|$\real$||
|
||||||
|
@@ -85,11 +85,11 @@ $( \big( \Big( \bigg( \Bigg($ `( \big( \Big( \bigg( \Bigg(`
|
|||||||
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
|$\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}$ |`\begin{Bmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{Bmatrix}`|$\def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}$|`\def\arraystretch{1.5}`<br> `\begin{array}{c:c:c}`<br> `a & b & c \\ \hline`<br> `d & e & f \\`<br> `\hdashline`<br> `g & h & i`<br>`\end{array}`
|
||||||
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
|$\begin{aligned} a&=b+c \\ d+e&=f \end{aligned}$ |`\begin{aligned}`<br> `a&=b+c \\`<br> `d+e&=f`<br>`\end{aligned}`|$\begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat}$ |`\begin{alignedat}{2}`<br> `10&x+ &3&y = 2 \\`<br> ` 3&x+&13&y = 4`<br>`\end{alignedat}`
|
||||||
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
|$\begin{gathered} a=b \\ e=b+c \end{gathered}$ |`\begin{gathered}`<br> `a=b \\ `<br> `e=b+c`<br>`\end{gathered}`|$x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}$ |`x = \begin{cases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{cases}`
|
||||||
|$\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}$ | `\begin{smallmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{smallmatrix}` | | |
|
|$\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}$ | `\begin{smallmatrix}`<br> `a & b \\`<br> `c & d`<br>`\end{smallmatrix}` |$\begin{rcases} a &\text{if } b \\ c &\text{if } d \end{rcases}⇒…$ |`\begin{rcases}`<br> `a &\text{if } b \\`<br> `c &\text{if } d`<br>`\end{rcases}⇒…`|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
KaTeX also supports `darray` and `dcases`.
|
KaTeX also supports `darray`, `dcases`, and `drcases`.
|
||||||
|
|
||||||
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
Acceptable line separators include: `\\`, `\cr`, `\\[distance]`, and `\cr[distance]`. *Distance* can be written with any of the [KaTeX units](#units).
|
||||||
|
|
||||||
|
@@ -752,11 +752,14 @@ defineEnvironment({
|
|||||||
// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
|
// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right.
|
||||||
// {dcases} is a {cases} environment where cells are set in \displaystyle,
|
// {dcases} is a {cases} environment where cells are set in \displaystyle,
|
||||||
// as defined in mathtools.sty.
|
// as defined in mathtools.sty.
|
||||||
|
// {rcases} is another mathtools environment. It's brace is on the right side.
|
||||||
defineEnvironment({
|
defineEnvironment({
|
||||||
type: "array",
|
type: "array",
|
||||||
names: [
|
names: [
|
||||||
"cases",
|
"cases",
|
||||||
"dcases",
|
"dcases",
|
||||||
|
"rcases",
|
||||||
|
"drcases",
|
||||||
],
|
],
|
||||||
props: {
|
props: {
|
||||||
numArgs: 0,
|
numArgs: 0,
|
||||||
@@ -786,8 +789,8 @@ defineEnvironment({
|
|||||||
type: "leftright",
|
type: "leftright",
|
||||||
mode: context.mode,
|
mode: context.mode,
|
||||||
body: [res],
|
body: [res],
|
||||||
left: "\\{",
|
left: context.envName.indexOf("r") > -1 ? "." : "\\{",
|
||||||
right: ".",
|
right: context.envName.indexOf("r") > -1 ? "\\}" : ".",
|
||||||
rightColor: undefined,
|
rightColor: undefined,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@@ -2646,6 +2646,15 @@ describe("A cases environment", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("An rcases environment", function() {
|
||||||
|
|
||||||
|
it("should build", function() {
|
||||||
|
expect`\begin{rcases} a &\text{if } b \\ c &\text{if } d \end{rcases}⇒…`
|
||||||
|
.toBuild();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe("An aligned environment", function() {
|
describe("An aligned environment", function() {
|
||||||
|
|
||||||
it("should parse its input", function() {
|
it("should parse its input", function() {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 25 KiB |
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 24 KiB |
@@ -74,7 +74,11 @@ Cases: |
|
|||||||
a+1&\text{if }b\text{ is odd} \\
|
a+1&\text{if }b\text{ is odd} \\
|
||||||
a&\text{if }b=0 \\
|
a&\text{if }b=0 \\
|
||||||
a-1&\text{otherwise}
|
a-1&\text{otherwise}
|
||||||
\end{cases}
|
\end{cases} \\
|
||||||
|
\begin{rcases}
|
||||||
|
a &\text{if } b \\
|
||||||
|
c &\text{if } d
|
||||||
|
\end{rcases}⇒…
|
||||||
Colors:
|
Colors:
|
||||||
tex: \blue{a}\textcolor{#0f0}{b}\textcolor{red}{c}
|
tex: \blue{a}\textcolor{#0f0}{b}\textcolor{red}{c}
|
||||||
nolatex: different syntax and different scope
|
nolatex: different syntax and different scope
|
||||||
|
Reference in New Issue
Block a user