diff --git a/src/commands/math/commands.js b/src/commands/math/commands.js
index b8b78deba..91175c502 100644
--- a/src/commands/math/commands.js
+++ b/src/commands/math/commands.js
@@ -945,9 +945,6 @@ Environments.matrix = P(Environment, function(_, super_) {
trs += '
$tds
';
cells[row] = [];
}
- if (this.parent.htmlColumnSeparator && !isFirstColumn) {
- cells[row].push(this.parent.htmlColumnSeparator);
- }
cells[row].push('&'+(i++)+' | ');
});
@@ -1204,9 +1201,6 @@ Environments.matrix = P(Environment, function(_, super_) {
block = MatrixCell(row+1);
block.parent = this;
newCells.push(block);
- if (this.htmlColumnSeparator && !isFirstColumn) {
- newRow.append($(this.htmlColumnSeparator));
- }
isFirstColumn = false;
// Create cell s and add to new row
block.jQ = $(' | ')
@@ -1323,50 +1317,13 @@ Environments.Vmatrix = P(Matrix, function(_, super_) {
// differently in latex. Nevertheless, we want it to render as a table so it's convenient to extend Matrix.
Environments['align*'] = P(Matrix, function (_, super_) {
_.environment = 'align*';
- _.extraTableClasses = 'mq-rcl';
+ _.extraTableClasses = 'mq-align';
_.createBlocks = function() {
this.blocks = [
MatrixCell(0, this),
MatrixCell(0, this),
];
}
- _.htmlColumnSeparator = ' | = | ';
- _.delimiters = {
- column: '&=',
- row: '\\\\',
- };
-
- // Don't delete empty columns, the align environment is for equations and should always have two columns.
- _.removeEmptyColumns = false;
-
- // For the same reason, don't allow adding columns.
- _.addColumn = function() {};
-
- // jQadd hack to keep the cursor in the correct row on seek
- _.jQadd = function(jQ) {
- var cmd = this, eachChild = this.eachChild;
- jQ = super_.jQadd.call(this, jQ);
-
- // Listen for mousedown on td.mq-align-equal descendants
- // Handler will run just before `this.seek` is triggered by a similar
- // listener in the controller.
- jQ.delegate('td.mq-align-equal', 'mousedown.mathquill.alignenv', function (e) {
- var tds = $(e.currentTarget).siblings('td');
- var row = Fragment(
- Node.byId[tds[0].getAttribute(mqBlockId)],
- Node.byId[tds[1].getAttribute(mqBlockId)]
- );
-
- // Temporarily monkey-patch eachChild so that seek is limited
- // to this row only.
- // TODO - fix this properly
- cmd.eachChild = function() {
- row.each.apply(row, arguments);
- cmd.eachChild = eachChild;
- };
- });
- return jQ;
- };
});
// Replacement for mathblocks inside matrix cells
diff --git a/src/css/math.less b/src/css/math.less
index d64828ae9..cb879d16d 100644
--- a/src/css/math.less
+++ b/src/css/math.less
@@ -389,14 +389,11 @@
margin-bottom: 1px;
}
- &.mq-rcl {
- td:nth-child(1) {
+ &.mq-align {
+ td:nth-child(odd) {
text-align: right;
}
- td:nth-child(2) {
- text-align: center;
- }
- td:nth-child(3) {
+ td:nth-child(even) {
text-align: left;
}
}
diff --git a/test/visual.html b/test/visual.html
index 8b03663f2..53fd70c03 100644
--- a/test/visual.html
+++ b/test/visual.html
@@ -290,21 +290,35 @@ Text mode
Mutiple consecutive spaces in the middle of a text mode block should not collapse into one space: \text{three spaces}
Matrix align* environments
-align* environments should render with each row's = sign aligned, the LHS aligned right, and the RHS aligned left
+
align* environments should render in a similar manner to matrix environments, except their cell alignment occurs in the order {rlrlrlrl...}
+
+ \begin{align*}
+\frac{3x + y}{7} &&= 9 && \text{given} \\
+3x + y &&= 63 && \text{multiply by 7} \\
+3x &&= 63 - y && \text{subtract y} \\
+x &&= 21 - \frac{y}{3} && \text{divide by 3} \\
+\end{align*}
+
+They can align on any symbol prefixed by an &
+
+ \begin{align*}
+ f(x) &= x^4 + 7x^3 + 2x^2 \\
+ &+ 10x + 12
+\end{align*}
+
+They may also have multiple equations per line
\begin{align*}
- y &= mx+c \\
- y-c &= mx \\
- \frac{y-c}{m} &= x
- \end{align*}
+ f(x) &= a x^2+b x +c & g(x) &= d x^3 \\
+ f'(x) &= 2 a x +b & g'(x) &= 3 d x^2
+\end{align*}
align* environments can be edited. New row: shift+enter.
- \begin{align*}
- y &= mx+c \\
- y-c &= mx \\
- \frac{y-c}{m} &= x
- \end{align*}
+ \begin{align*}
+ f(x) &= (x+a)(x+b) \\
+ &= x^2 + (a+b)x + ab
+ \end{align*}