Merge pull request #398 from gagern/aligned
Introduce an aligned environment
This commit is contained in:
commit
3a15a8402f
|
@ -176,3 +176,43 @@ defineEnvironment("cases", {
|
|||
}, context.mode);
|
||||
return res;
|
||||
});
|
||||
|
||||
// An aligned environment is like the align* environment
|
||||
// except it operates within math mode.
|
||||
// Note that we assume \nomallineskiplimit to be zero,
|
||||
// so that \strut@ is the same as \strut.
|
||||
defineEnvironment("aligned", {
|
||||
}, function(context) {
|
||||
var res = {
|
||||
type: "array",
|
||||
cols: []
|
||||
};
|
||||
res = parseArray(context.parser, res);
|
||||
var emptyGroup = new ParseNode("ordgroup", [], context.mode);
|
||||
var numCols = 0;
|
||||
res.value.body.forEach(function(row) {
|
||||
var i;
|
||||
for (i = 1; i < row.length; i += 2) {
|
||||
row[i].value.unshift(emptyGroup);
|
||||
}
|
||||
if (numCols < row.length) {
|
||||
numCols = row.length;
|
||||
}
|
||||
});
|
||||
for (var i = 0; i < numCols; ++i) {
|
||||
var align = "r";
|
||||
var pregap = 0;
|
||||
if (i % 2 === 1) {
|
||||
align = "l";
|
||||
} else if (i > 0) {
|
||||
pregap = 2; // one \qquad between columns
|
||||
}
|
||||
res.value.cols[i] = {
|
||||
type: "align",
|
||||
align: align,
|
||||
pregap: pregap,
|
||||
postgap: 0
|
||||
};
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
|
|
@ -1672,6 +1672,15 @@ describe("A cases environment", function() {
|
|||
|
||||
});
|
||||
|
||||
describe("An aligned environment", function() {
|
||||
|
||||
it("should parse its input", function() {
|
||||
expect("\\begin{aligned}a&=b&c&=d\\\\e&=f\\end{aligned}")
|
||||
.toParse();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var getMathML = function(expr, settings) {
|
||||
var usedSettings = settings ? settings : defaultSettings;
|
||||
|
||||
|
|
BIN
test/screenshotter/images/Aligned-chrome.png
Normal file
BIN
test/screenshotter/images/Aligned-chrome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
BIN
test/screenshotter/images/Aligned-firefox.png
Normal file
BIN
test/screenshotter/images/Aligned-firefox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
|
@ -12,6 +12,11 @@
|
|||
# on the next line. See http://www.yaml.org/ for syntax details.
|
||||
|
||||
Accents: \vec{A}\vec{x}\vec x^2\vec{x}_2^2\vec{A}^2\vec{xA}^2
|
||||
Aligned: |
|
||||
\begin{aligned}
|
||||
a &= 1 & b &= 2 \\
|
||||
3a &= 3 & 17b &= 34
|
||||
\end{aligned}
|
||||
Arrays: |
|
||||
\left(\begin{array}{|rl|c||}
|
||||
1&2&3\\
|
||||
|
|
Loading…
Reference in New Issue
Block a user