mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
LaTeX: no spaces between operands and operators
This commit is contained in:
parent
46bb79b5b9
commit
f2bcfed89f
@ -323,7 +323,7 @@ OperatorNode.prototype._toTex = function(callbacks) {
|
||||
//op contains '\\frac' at this point
|
||||
return op + '{' + lhsTex + '}' + '{' + rhsTex + '}';
|
||||
}
|
||||
return lhsTex + ' ' + op + ' ' + rhsTex;
|
||||
return lhsTex + op + rhsTex;
|
||||
|
||||
default:
|
||||
//fall back to formatting as a function call
|
||||
|
||||
@ -265,7 +265,7 @@ describe('FunctionAssignmentNode', function() {
|
||||
var p = new OperatorNode('^', 'pow', [o, a]);
|
||||
var n = new FunctionAssignmentNode('f', ['x'], p);
|
||||
|
||||
assert.equal(n.toTex(), '\\mathrm{f}\\left(\\mathrm{x}\\right):={{\\frac{{\\mathrm{x}}}{{2}}} ^ {2}}');
|
||||
assert.equal(n.toTex(), '\\mathrm{f}\\left(\\mathrm{x}\\right):={{\\frac{{\\mathrm{x}}}{{2}}}^{2}}');
|
||||
});
|
||||
|
||||
it ('should LaTeX a FunctionAssignmentNode containing an AssignmentNode', function () {
|
||||
|
||||
@ -278,7 +278,7 @@ describe('FunctionNode', function() {
|
||||
|
||||
var o = new OperatorNode('+', 'add', [c1, c2]);
|
||||
var n3 = new FunctionNode('permutations', [o]);
|
||||
assert.equal(n3.toTex(), '\\mathrm{permutations}\\left({{4} + {5}}\\right)');
|
||||
assert.equal(n3.toTex(), '\\mathrm{permutations}\\left({{4}+{5}}\\right)');
|
||||
});
|
||||
|
||||
it ('should have an identifier', function () {
|
||||
|
||||
@ -276,7 +276,7 @@ describe('OperatorNode', function() {
|
||||
var c = new ConstantNode(4);
|
||||
|
||||
var n = new OperatorNode('+', 'add', [a, b]);
|
||||
assert.equal(n.toTex(), '{2} + {3}');
|
||||
assert.equal(n.toTex(), '{2}+{3}');
|
||||
});
|
||||
|
||||
it ('should LaTeX an OperatorNode with factorial', function () {
|
||||
@ -298,9 +298,9 @@ describe('OperatorNode', function() {
|
||||
var n2= new OperatorNode('!', 'factorial', [add] );
|
||||
var n3= new OperatorNode('!', 'factorial', [mult] );
|
||||
var n4= new OperatorNode('!', 'factorial', [div] );
|
||||
assert.equal(n1.toTex(), '\\left({{2} - {3}}\\right)!');
|
||||
assert.equal(n2.toTex(), '\\left({{2} + {3}}\\right)!');
|
||||
assert.equal(n3.toTex(), '\\left({{2} \\cdot {3}}\\right)!');
|
||||
assert.equal(n1.toTex(), '\\left({{2}-{3}}\\right)!');
|
||||
assert.equal(n2.toTex(), '\\left({{2}+{3}}\\right)!');
|
||||
assert.equal(n3.toTex(), '\\left({{2}\\cdot{3}}\\right)!');
|
||||
assert.equal(n4.toTex(), '{\\frac{{2}}{{3}}}!');
|
||||
});
|
||||
|
||||
@ -316,8 +316,8 @@ describe('OperatorNode', function() {
|
||||
var n3 = new OperatorNode('-', 'unaryMinus', [add]);
|
||||
|
||||
assert.equal(n1.toTex(), '-{2}');
|
||||
assert.equal(n2.toTex(), '-\\left({{2} - {3}}\\right)');
|
||||
assert.equal(n3.toTex(), '-\\left({{2} + {3}}\\right)');
|
||||
assert.equal(n2.toTex(), '-\\left({{2}-{3}}\\right)');
|
||||
assert.equal(n3.toTex(), '-\\left({{2}+{3}}\\right)');
|
||||
});
|
||||
|
||||
it ('should LaTeX an OperatorNode that subtracts an OperatorNode', function() {
|
||||
@ -331,8 +331,8 @@ describe('OperatorNode', function() {
|
||||
var n1 = new OperatorNode('-', 'subtract', [a, sub]);
|
||||
var n2 = new OperatorNode('-', 'subtract', [a, add]);
|
||||
|
||||
assert.equal(n1.toTex(), '{1} - \\left({{2} - {3}}\\right)');
|
||||
assert.equal(n2.toTex(), '{1} - \\left({{2} + {3}}\\right)');
|
||||
assert.equal(n1.toTex(), '{1}-\\left({{2}-{3}}\\right)');
|
||||
assert.equal(n2.toTex(), '{1}-\\left({{2}+{3}}\\right)');
|
||||
});
|
||||
|
||||
it ('should LaTeX an OperatorNode with zero arguments', function () {
|
||||
@ -363,10 +363,10 @@ describe('OperatorNode', function() {
|
||||
var m2 = new OperatorNode('*', 'multiply', [n1, c]);
|
||||
var m3 = new OperatorNode('-', 'subtract', [m2, d]);
|
||||
|
||||
assert.equal(n1.toTex(), '{2} + {3}');
|
||||
assert.equal(n2.toTex(), '{4} - {5}');
|
||||
assert.equal(n3.toTex(), '\\left({{2} + {3}}\\right) \\cdot \\left({{4} - {5}}\\right)');
|
||||
assert.equal(m3.toTex(), '{\\left({{2} + {3}}\\right) \\cdot {4}} - {5}');
|
||||
assert.equal(n1.toTex(), '{2}+{3}');
|
||||
assert.equal(n2.toTex(), '{4}-{5}');
|
||||
assert.equal(n3.toTex(), '\\left({{2}+{3}}\\right)\\cdot\\left({{4}-{5}}\\right)');
|
||||
assert.equal(m3.toTex(), '{\\left({{2}+{3}}\\right)\\cdot{4}}-{5}');
|
||||
});
|
||||
|
||||
it('should LaTeX fractions with operators that are enclosed in parenthesis', function () {
|
||||
@ -375,7 +375,7 @@ describe('OperatorNode', function() {
|
||||
|
||||
var add = new OperatorNode('+', 'add', [a,a]);
|
||||
var frac = new OperatorNode('/', 'divide', [add,b]);
|
||||
assert.equal(frac.toTex(), '\\frac{{{1} + {1}}}{{2}}');
|
||||
assert.equal(frac.toTex(), '\\frac{{{1}+{1}}}{{2}}');
|
||||
});
|
||||
|
||||
it ('should have an identifier', function () {
|
||||
|
||||
@ -71,7 +71,7 @@ describe('arg', function() {
|
||||
|
||||
it('should LaTeX arg', function () {
|
||||
var expression = math.parse('arg(1+i)');
|
||||
assert.equal(expression.toTex(), '\\arg\\left({{1} + {{i}}}\\right)');
|
||||
assert.equal(expression.toTex(), '\\arg\\left({{1}+{{i}}}\\right)');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -54,7 +54,7 @@ describe('conj', function() {
|
||||
|
||||
it('should LaTeX conj', function () {
|
||||
var expression = math.parse('conj(1+i)');
|
||||
assert.equal(expression.toTex(), '\\left({{1} + {{i}}}\\right)^{*}');
|
||||
assert.equal(expression.toTex(), '\\left({{1}+{{i}}}\\right)^{*}');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -48,7 +48,7 @@ describe('im', function() {
|
||||
|
||||
it('should LaTeX im', function () {
|
||||
var expression = math.parse('im(1+i)');
|
||||
assert.equal(expression.toTex(), '\\Im\\left\\lbrace{{1} + {{i}}}\\right\\rbrace');
|
||||
assert.equal(expression.toTex(), '\\Im\\left\\lbrace{{1}+{{i}}}\\right\\rbrace');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ describe('re', function() {
|
||||
|
||||
it('should LaTeX re', function () {
|
||||
var expression = math.parse('re(1+i)');
|
||||
assert.equal(expression.toTex(), '\\Re\\left\\lbrace{{1} + {{i}}}\\right\\rbrace');
|
||||
assert.equal(expression.toTex(), '\\Re\\left\\lbrace{{1}+{{i}}}\\right\\rbrace');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -77,7 +77,7 @@ describe('to', function() {
|
||||
|
||||
it('should LaTeX to', function () {
|
||||
var expression = math.parse('to(2cm,m)');
|
||||
assert.equal(expression.toTex(), '\\left({{2} \\cdot {\\mathrm{cm}}}\\rightarrow{\\mathrm{m}}\\right)');
|
||||
assert.equal(expression.toTex(), '\\left({{2}\\cdot{\\mathrm{cm}}}\\rightarrow{\\mathrm{m}}\\right)');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user