Repository: josdejong/mathjs
Pull request #326 (2015-04-19 09:18:27)

Bugfixes, simplifications and other improvements in the LaTeX output
See commit messages!


Patch:
diff --git a/lib/expression/node/AssignmentNode.js b/lib/expression/node/AssignmentNode.js
index d99c07126..e939c143d 100644
--- a/lib/expression/node/AssignmentNode.js
+++ b/lib/expression/node/AssignmentNode.js
@@ -96,7 +96,7 @@ AssignmentNode.prototype._toTex = function(callbacks) {
   var precedence = operators.getPrecedence(this);
   var exprPrecedence = operators.getPrecedence(this.expr);
 
-  var expr = '{' + this.expr.toTex(callbacks) + '}';
+  var expr = this.expr.toTex(callbacks);
   if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) {
     expr = '\\left(' + expr + '\\right)';
   }
diff --git a/lib/expression/node/ConstantNode.js b/lib/expression/node/ConstantNode.js
index 10e8448cf..1220b0571 100644
--- a/lib/expression/node/ConstantNode.js
+++ b/lib/expression/node/ConstantNode.js
@@ -169,7 +169,7 @@ ConstantNode.prototype._toTex = function(callbacks) {
     case 'number':
       index = value.toLowerCase().indexOf('e');
       if (index !== -1) {
-        return value.substring(0, index) + ' \\cdot 10^{' +
+        return value.substring(0, index) + '\\cdot10^{' +
             value.substring(index + 1) + '}';
       }
       return value;
diff --git a/lib/expression/node/FunctionAssignmentNode.js b/lib/expression/node/FunctionAssignmentNode.js
index abde1a6ea..e3e94ba57 100644
--- a/lib/expression/node/FunctionAssignmentNode.js
+++ b/lib/expression/node/FunctionAssignmentNode.js
@@ -118,7 +118,7 @@ FunctionAssignmentNode.prototype._toTex = function(callbacks) {
   var precedence = operators.getPrecedence(this);
   var exprPrecedence = operators.getPrecedence(this.expr);
 
-  var expr = '{' + this.expr.toTex(callbacks) + '}';
+  var expr = this.expr.toTex(callbacks);
   if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) {
     expr = '\\left(' + expr + '\\right)';
   }
diff --git a/lib/expression/node/IndexNode.js b/lib/expression/node/IndexNode.js
index 3149b17a3..4ef0703bb 100644
--- a/lib/expression/node/IndexNode.js
+++ b/lib/expression/node/IndexNode.js
@@ -215,7 +215,10 @@ IndexNode.prototype.toString = function() {
  * @return {String} str
  */
 IndexNode.prototype._toTex = function(callbacks) {
-  return this.object.toTex(callbacks) + '[' + this.ranges.join(', ') + ']';
+  var ranges = this.ranges.map(function (range) {
+    return range.toTex(callbacks);
+  });
+  return this.object.toTex(callbacks) + '_{\\left[' + ranges.join(',') + '\\right]}';
 };
 
 module.exports = IndexNode;
diff --git a/lib/expression/node/OperatorNode.js b/lib/expression/node/OperatorNode.js
index 1d24e5cf0..f17ed7d63 100644
--- a/lib/expression/node/OperatorNode.js
+++ b/lib/expression/node/OperatorNode.js
@@ -291,7 +291,7 @@ OperatorNode.prototype._toTex = function(callbacks) {
    case 1: //unary operators
      var assoc = operators.getAssociativity(this);
 
-     var operand = '{' + args[0].toTex(callbacks) + '}';
+     var operand = args[0].toTex(callbacks);
      if (parens[0]) {
        operand = '\\left(' + operand + '\\right)';
      }
@@ -308,22 +308,32 @@ OperatorNode.prototype._toTex = function(callbacks) {
 
    case 2: //binary operators
      var lhs = args[0]; //left hand side
-     var lhsTex =  '{' + lhs.toTex(callbacks) + '}';
+     var lhsTex =  lhs.toTex(callbacks);
      if (parens[0]) {
        lhsTex = '\\left(' + lhsTex + '\\right)';
      }
+
      var rhs = args[1]; //right hand side
-     var rhsTex = '{' + rhs.toTex(callbacks) + '}';
+     var rhsTex = rhs.toTex(callbacks);
      if (parens[1]) {
        rhsTex = '\\left(' + rhsTex + '\\right)';
      }
 
+     //handle some exceptions (due to the way LaTeX works)
      switch (this.getIdentifier()) {
        case 'OperatorNode:divide':
          //op contains '\\frac' at this point
          return op + '{' + lhsTex + '}' + '{' + rhsTex + '}';
+       case 'OperatorNode:pow':
+         lhsTex = '{' + lhsTex + '}';
+         rhsTex = '{' + rhsTex + '}';
+         switch (lhs.getIdentifier()) {
+           case 'ConditionalNode': //
+           case 'OperatorNode:divide':
+             lhsTex = '\\left(' + lhsTex + '\\right)';
+         }
      }
-     return lhsTex + ' ' + op + ' ' + rhsTex;
+     return lhsTex + op + rhsTex;
 
    default:
      //fall back to formatting as a function call
@@ -331,7 +341,7 @@ OperatorNode.prototype._toTex = function(callbacks) {
      //fancy function names
      return '\\mathrm{' + this.fn + '}\\left('
              + args.map(function (arg) {
-               return '{' + arg.toTex(callbacks) + '}';
+               return arg.toTex(callbacks);
              }).join(',') + '\\right)';
  }
 };
diff --git a/lib/expression/node/SymbolNode.js b/lib/expression/node/SymbolNode.js
index ca148b7cf..a713b2531 100644
--- a/lib/expression/node/SymbolNode.js
+++ b/lib/expression/node/SymbolNode.js
@@ -109,7 +109,13 @@ SymbolNode.prototype.toString = function() {
  * @override
  */
 SymbolNode.prototype._toTex = function(callbacks) {
-  return latex.toSymbol(this.name);
+  var symbol = latex.toSymbol(this.name);
+  if (symbol[0] === '\\') {
+    //no space needed if the symbol starts with '\'
+    return symbol;
+  }
+  //the space prevents symbols from breaking stuff like '\cdot' if it's written right before the symbol
+  return ' ' + symbol;
 };
 
 module.exports = SymbolNode;
diff --git a/lib/expression/node/UpdateNode.js b/lib/expression/node/UpdateNode.js
index 58c3b120c..eef548863 100644
--- a/lib/expression/node/UpdateNode.js
+++ b/lib/expression/node/UpdateNode.js
@@ -93,7 +93,7 @@ UpdateNode.prototype.toString = function() {
  * @return {String}
  */
 UpdateNode.prototype._toTex = function(callbacks) {
-  return this.index.toTex(callbacks) + ' = ' + this.expr.toTex(callbacks);
+  return this.index.toTex(callbacks) + ':=' + this.expr.toTex(callbacks);
 };
 
 module.exports = UpdateNode;
diff --git a/lib/util/latex.js b/lib/util/latex.js
index ee5ab09b9..fe17d785a 100644
--- a/lib/util/latex.js
+++ b/lib/util/latex.js
@@ -41,10 +41,10 @@ exports.symbols = {
 };
 
 exports.operators = {
-  'transpose': '^{\\top}',
+  'transpose': '^\\top',
   'factorial': '!',
   'pow': '^',
-  'dotPow': '.^{\\wedge}', //TODO find ideal solution
+  'dotPow': '.^\\wedge', //TODO find ideal solution
   'unaryPlus': '+',
   'unaryMinus': '-',
   'bitNot': '~', //TODO find ideal solution
@@ -78,7 +78,7 @@ exports.operators = {
 //create a comma separated list of function arguments
 function functionArgs(args, callbacks) {
   return args.map( function (arg) {
-    return '{' + arg.toTex(callbacks) + '}';
+    return arg.toTex(callbacks);
   }).join(',');
 }
 
@@ -97,12 +97,12 @@ function expandTemplate(template, name, args) {
 
   //replace %0%, %1% .... with the arguments in args
   args.forEach(function (arg, index) {
-    template = template.replace(RegExp('%' + index + '%', 'g'), '{' + arg + '}');
+    template = template.replace(RegExp('%' + index + '%', 'g'), arg);
   });
 
   //replace %*% with a comma separated list of all arguments
   template = template.replace('%*%', args.map(function (arg) {
-      return '{' + arg + '}';
+      return arg;
     }).join(','));
 
   //replace %% with %, this comes in handy when you need a % in your LaTeX string
@@ -117,8 +117,8 @@ var functions = {
   'abs': '\\left|%0%\\right|',
   'add': '\\left(%0%+%1%\\right)',
   'ceil': '\\left\\lceil%0%\\right\\rceil',
-  'cube': '\\left(%0%\\right)^{3}',
-  'divide': '\\frac%0%%1%',
+  'cube': '\\left(%0%\\right)^3',
+  'divide': '\\frac{%0%}{%1%}',
   'dotDivide': '\\left(%0%' + exports.operators['dotDivide'] + '%1%\\right)',
   'dotMultiply': '\\left(%0%' + exports.operators['dotMultiply'] + '%1%\\right)',
   'dotPow': '\\left(%0%' + exports.operators['dotPow'] + '%1%\\right)',
@@ -130,7 +130,7 @@ var functions = {
   'log10': '\\log_{10}\\left(%0%\\right)',
   'log': {
     1: '\\ln\\left(%0%\\right)',
-    2: '\\log_%1%\\left(%0%\\right)'
+    2: '\\log_{%1%}\\left(%0%\\right)'
   },
   'mod': '\\left(%0%' + exports.operators['mod'] + '%1%\\right)',
   'multiply': '\\left(%0%' + exports.operators['multiply'] + '%1%\\right)',
@@ -138,15 +138,15 @@ var functions = {
     1: '\\left\\|%0%\\right\\|',
     2: defaultTemplate
   },
-  'nthRoot': '\\sqrt[%1%]%0%',
-  'pow': '\\left(%0%' + exports.operators['pow'] + '%1%\\right)',
+  'nthRoot': '\\sqrt[%1%]{%0%}',
+  'pow': '\\left(%0%\\right)' + exports.operators['pow'] + '{%1%}',
   'round': {
     1: '\\left\\lfloor%0%\\right\\rceil',
     2: defaultTemplate
   },
   'sign': defaultTemplate,
-  'sqrt': '\\sqrt%0%',
-  'square': '\\left(%0%\\right)^{2}',
+  'sqrt': '\\sqrt{%0%}',
+  'square': '\\left(%0%\\right)^2',
   'subtract': '\\left(%0%' + exports.operators['subtract'] + '%1%\\right)',
   'unaryMinus': exports.operators['unaryMinus'] + '\\left(%0%\\right)',
   'unaryPlus': exports.operators['unaryPlus'] + '\\left(%0%\\right)',
@@ -163,7 +163,7 @@ var functions = {
 
   //complex
   'arg': '\\arg\\left(%0%\\right)',
-  'conj': '\\left(%0%\\right)^{*}',
+  'conj': '\\left(%0%\\right)^*',
   'im': '\\Im\\left\\lbrace%0%\\right\\rbrace',
   're': '\\Re\\left\\lbrace%0%\\right\\rbrace',
 
@@ -177,8 +177,8 @@ var functions = {
   'complex': {
     0: '0',
     1: '\\left(%0%\\right)',
-    2: '\\left({\\left(%0%\\right)+'
-      + exports.symbols['i'] + '\\cdot\\left(%1%\\right)}\\right)',
+    2: '\\left(\\left(%0%\\right)+'
+      + exports.symbols['i'] + '\\cdot\\left(%1%\\right)\\right)',
   },
   'index': defaultTemplate,
   'matrix': {
@@ -200,7 +200,7 @@ var functions = {
   },
   'unit': {
     1: '\\left(%0%\\right)',
-    2: '\\left({\\left(%0%\\right)%1%}\\right)'
+    2: '\\left(\\left(%0%\\right)%1%\\right)'
   },
 
   //expression TODO does the default even work in this case? (.toTex on the args)
@@ -217,13 +217,13 @@ var functions = {
 
   //matrix
   'concat': defaultTemplate,
-  'cross': '%0%\\times%1%',
+  'cross': '\\left(%0%\\right)\\times\\left(%1%\\right)',
   'det': '\\det\\left(%0%\\right)',
   'diag': defaultTemplate,
   'dot': '\\left(%0%\\cdot%1%\\right)',
   'eye': defaultTemplate,
   'flatten': defaultTemplate,
-  'inv': '%0%^{-1}',
+  'inv': '\\left(%0%\\right)^{-1}',
   'ones': defaultTemplate,
   'range': defaultTemplate,
   'resize': defaultTemplate,
@@ -231,13 +231,13 @@ var functions = {
   'squeeze': defaultTemplate,
   'subset': defaultTemplate,
   'trace': '\\mathrm{tr}\\left(%0%\\right)',
-  'transpose': '%0%^{\\top}',
+  'transpose': '\\left(%0%\\right)' + exports.operators['transpose'],
   'zeros': defaultTemplate,
 
   //probability
-  'combinations': '\\binom%0%%1%',
+  'combinations': '\\binom{%0%}{%1%}',
   'distribution': defaultTemplate,
-  'factorial': '\\left(%0%\\right)!',
+  'factorial': '\\left(%0%\\right)' + exports.operators['factorial'],
   'gamma': '\\Gamma\\left(%0%\\right)',
   'permutations': defaultTemplate,
   'pickRandom': defaultTemplate,
@@ -307,20 +307,24 @@ var functions = {
 };
 
 var units = {
-  deg: '^{\\circ}'
+  deg: '^\\circ'
 };
 
 //FIXME find a good solution so that single characters still
 //get rendered in regular italic whereas single character units
 //are rendered with \mathrm
 exports.toSymbol = function (name) {
-  if (typeof exports.symbols[name] !== 'undefined') {
-    return '{' + exports.symbols[name] + '}';
+  if (units.hasOwnProperty(name)) {
+    return units[name];
+  }
+
+  if (exports.symbols.hasOwnProperty(name)) {
+    return exports.symbols[name];
   }
   else if (name.indexOf('_') !== -1) {
     //symbol with index (eg. alpha_1)
     var index = name.indexOf('_');
-    return '{' + exports.toSymbol(name.substring(0, index)) + '}_{'
+    return exports.toSymbol(name.substring(0, index)) + '_{'
       + exports.toSymbol(name.substring(index + 1)) + '}';
   }
   return '\\mathrm{' + name + '}';


Test patch:
diff --git a/test/expression/node/AssignmentNode.test.js b/test/expression/node/AssignmentNode.test.js
index c1418eef1..a4e96728e 100644
--- a/test/expression/node/AssignmentNode.test.js
+++ b/test/expression/node/AssignmentNode.test.js
@@ -213,7 +213,7 @@ describe('AssignmentNode', function() {
     var b = new ConstantNode(3);
     var n = new AssignmentNode('b', b);
 
-    assert.equal(n.toTex(), '\\mathrm{b}:={3}');
+    assert.equal(n.toTex(), '\\mathrm{b}:=3');
   });
 
   it ('should LaTeX an AssignmentNode containing an AssignmentNode', function () {
@@ -222,7 +222,7 @@ describe('AssignmentNode', function() {
 
     var n = new AssignmentNode('b', b);
 
-    assert.equal(n.toTex(), '\\mathrm{b}:=\\left({\\mathrm{a}:={2}}\\right)');
+    assert.equal(n.toTex(), '\\mathrm{b}:=\\left(\\mathrm{a}:=2\\right)');
   });
 
   it ('should LaTeX an AssignmentNode with custom toTex', function () {
diff --git a/test/expression/node/BlockNode.test.js b/test/expression/node/BlockNode.test.js
index dbe512000..80335fa7f 100644
--- a/test/expression/node/BlockNode.test.js
+++ b/test/expression/node/BlockNode.test.js
@@ -253,7 +253,7 @@ describe('BlockNode', function() {
       {node: new SymbolNode('foo'), visible:true}
     ]);
 
-    assert.equal(n.toTex(), '5\n\\mathrm{foo}:={3};\n\\mathrm{foo}');
+    assert.equal(n.toTex(), '5\n\\mathrm{foo}:=3;\n\\mathrm{foo}');
   });
 
   it ('should LaTeX a BlockNode with custom toTex', function () {
diff --git a/test/expression/node/ConditionalNode.test.js b/test/expression/node/ConditionalNode.test.js
index 587df6207..5175b763e 100644
--- a/test/expression/node/ConditionalNode.test.js
+++ b/test/expression/node/ConditionalNode.test.js
@@ -257,7 +257,7 @@ describe('ConditionalNode', function() {
   it ('should LaTeX a ConditionalNode', function () {
     var n = new ConditionalNode(condition, a, b);
 
-    assert.equal(n.toTex(), '\\left\\{\\begin{array}{l l}{\\mathrm{a}:={2}}, &\\quad{\\text{if}\\;true}\\\\{\\mathrm{b}:={3}}, &\\quad{\\text{otherwise}}\\end{array}\\right.');
+    assert.equal(n.toTex(), '\\left\\{\\begin{array}{l l}{\\mathrm{a}:=2}, &\\quad{\\text{if}\\;true}\\\\{\\mathrm{b}:=3}, &\\quad{\\text{otherwise}}\\end{array}\\right.');
   });
 
   it ('should LaTeX a ConditionalNode with custom toTex', function () {
diff --git a/test/expression/node/ConstantNode.test.js b/test/expression/node/ConstantNode.test.js
index c572377d6..18847e3c6 100644
--- a/test/expression/node/ConstantNode.test.js
+++ b/test/expression/node/ConstantNode.test.js
@@ -139,6 +139,11 @@ describe('ConstantNode', function() {
     assert.equal(new ConstantNode('null', 'null').toTex(), 'null');
   });
 
+  it ('should LaTeX a ConstantNode in exponential notation', function () {
+    var n = new ConstantNode('1e10', 'number');
+    assert.equal(n.toTex(), '1\\cdot10^{10}');
+  });
+
   it ('should LaTeX a ConstantNode with custom toTex', function () {
     //Also checks if the custom functions get passed on to the children
     var customFunction = function (node, callback) {
diff --git a/test/expression/node/FunctionAssignmentNode.test.js b/test/expression/node/FunctionAssignmentNode.test.js
index f56b3f2ef..01e988092 100644
--- a/test/expression/node/FunctionAssignmentNode.test.js
+++ b/test/expression/node/FunctionAssignmentNode.test.js
@@ -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):=\\left({\\frac{\\mathrm{x}}{2}}\\right)^{2}');
   });
 
   it ('should LaTeX a FunctionAssignmentNode containing an AssignmentNode', function () {
@@ -274,7 +274,7 @@ describe('FunctionAssignmentNode', function() {
     var n1 = new AssignmentNode('a', a);
     var n = new FunctionAssignmentNode('f', ['x'], n1);
 
-    assert.equal(n.toTex(), '\\mathrm{f}\\left(\\mathrm{x}\\right):=\\left({\\mathrm{a}:={2}}\\right)');
+    assert.equal(n.toTex(), '\\mathrm{f}\\left(\\mathrm{x}\\right):=\\left(\\mathrm{a}:=2\\right)');
   });
 
   it ('should LaTeX a FunctionAssignmentNode with custom toTex', function () {
diff --git a/test/expression/node/FunctionNode.test.js b/test/expression/node/FunctionNode.test.js
index ccfc0cb48..97549b2d5 100644
--- a/test/expression/node/FunctionNode.test.js
+++ b/test/expression/node/FunctionNode.test.js
@@ -274,11 +274,11 @@ describe('FunctionNode', function() {
 
     // test permutations
     var n2 = new FunctionNode('permutations', [c1]);
-    assert.equal(n2.toTex(), '\\mathrm{permutations}\\left({4}\\right)');
+    assert.equal(n2.toTex(), '\\mathrm{permutations}\\left(4\\right)');
 
     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 () {
diff --git a/test/expression/node/IndexNode.test.js b/test/expression/node/IndexNode.test.js
index 83a74036a..2235c2e89 100644
--- a/test/expression/node/IndexNode.test.js
+++ b/test/expression/node/IndexNode.test.js
@@ -279,10 +279,10 @@ describe('IndexNode', function() {
     ];
 
     var n = new IndexNode(a, ranges);
-    assert.equal(n.toTex(), '\\mathrm{a}[2, 1]');
+    assert.equal(n.toTex(), '\\mathrm{a}_{\\left[2,1\\right]}');
 
     var n2 = new IndexNode(a, []);
-    assert.equal(n2.toTex(), '\\mathrm{a}[]')
+    assert.equal(n2.toTex(), '\\mathrm{a}_{\\left[\\right]}')
   });
 
   it ('should LaTeX an IndexNode with custom toTex', function () {
diff --git a/test/expression/node/OperatorNode.test.js b/test/expression/node/OperatorNode.test.js
index 53b995fc8..4410d05a1 100644
--- a/test/expression/node/OperatorNode.test.js
+++ b/test/expression/node/OperatorNode.test.js
@@ -4,6 +4,7 @@ var assert = require('assert'),
     math = require('../../../index'),
     Node = require('../../../lib/expression/node/Node'),
     ConstantNode = require('../../../lib/expression/node/ConstantNode'),
+    ConditionalNode = require('../../../lib/expression/node/ConditionalNode'),
     SymbolNode = require('../../../lib/expression/node/SymbolNode'),
     OperatorNode = require('../../../lib/expression/node/OperatorNode');
 
@@ -276,13 +277,13 @@ 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 () {
     var a = new ConstantNode(2);
     var n = new OperatorNode('!', 'factorial', [a]);
-    assert.equal(n.toTex(), '{2}!');
+    assert.equal(n.toTex(), '2!');
   });
 
   it ('should LaTeX an OperatorNode with factorial of an OperatorNode', function () {
@@ -298,10 +299,10 @@ 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(n4.toTex(), '{\\frac{{2}}{{3}}}!');
+    assert.equal(n1.toTex(), '\\left(2-3\\right)!');
+    assert.equal(n2.toTex(), '\\left(2+3\\right)!');
+    assert.equal(n3.toTex(), '\\left(2\\cdot3\\right)!');
+    assert.equal(n4.toTex(), '\\frac{2}{3}!');
   });
 
   it ('should LaTeX an OperatorNode with unary minus', function () {
@@ -315,9 +316,9 @@ describe('OperatorNode', function() {
     var n2 = new OperatorNode('-', 'unaryMinus', [sub]);
     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(n1.toTex(), '-2');
+    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 +332,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 () {
@@ -346,7 +347,7 @@ describe('OperatorNode', function() {
     var c = new ConstantNode(4);
 
     var n = new OperatorNode('foo', 'foo', [a, b, c]);
-    assert.equal(n.toTex(), '\\mathrm{foo}\\left({2},{3},{4}\\right)');
+    assert.equal(n.toTex(), '\\mathrm{foo}\\left(2,3,4\\right)');
 
   });
 
@@ -363,10 +364,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)\\cdot4-5');
   });
 
   it('should LaTeX fractions with operators that are enclosed in parenthesis', function () {
@@ -375,7 +376,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 () {
@@ -431,4 +432,20 @@ describe('OperatorNode', function() {
     assert.equal(n.toTex(customFunction), 'const\\left(1, number\\right)+add+const\\left(2, number\\right)');
   });
 
+  it ('should LaTeX powers of fractions with parentheses', function () {
+    var a = new ConstantNode(1);
+    var frac = new OperatorNode('/', 'divide', [a,a]);
+    var pow = new OperatorNode('^', 'pow', [frac, a]);
+
+    assert.equal(pow.toTex(), '\\left({\\frac{1}{1}}\\right)^{1}');
+  });
+
+  it ('should LaTeX powers of conditions with parentheses', function () {
+    var a = new ConstantNode(1);
+    var cond = new ConditionalNode(a, a, a);
+    var pow = new OperatorNode('^', 'pow', [cond, a]);
+
+    assert.equal(pow.toTex(), '\\left({\\left\\{\\begin{array}{l l}{1}, &\\quad{\\text{if}\\;1}\\\\{1}, &\\quad{\\text{otherwise}}\\end{array}\\right.}\\right)^{1}');
+  });
+
 });
diff --git a/test/expression/node/SymbolNode.test.js b/test/expression/node/SymbolNode.test.js
index 5147219ee..8d341a0ae 100644
--- a/test/expression/node/SymbolNode.test.js
+++ b/test/expression/node/SymbolNode.test.js
@@ -4,6 +4,7 @@ var assert = require('assert'),
     math = require('../../../index'),
     Node = require('../../../lib/expression/node/Node'),
     ConstantNode = require('../../../lib/expression/node/ConstantNode'),
+    OperatorNode = require('../../../lib/expression/node/OperatorNode'),
     SymbolNode = require('../../../lib/expression/node/SymbolNode');
 
 describe('SymbolNode', function() {
@@ -120,4 +121,13 @@ describe('SymbolNode', function() {
     assert.equal(n.toTex(customFunction), 'symbol(a)');
   });
 
+  it ('should LaTeX a SymbolNode without breaking \\cdot', function () {
+    var a = new ConstantNode(1);
+    var b = new SymbolNode('Epsilon');
+
+    var mult = new OperatorNode('*', 'multiply', [a,b]);
+
+    assert.equal(mult.toTex(), '1\\cdot E');
+  });
+
 });
diff --git a/test/expression/node/UpdateNode.test.js b/test/expression/node/UpdateNode.test.js
index 5019b1d77..83a0c3ec4 100644
--- a/test/expression/node/UpdateNode.test.js
+++ b/test/expression/node/UpdateNode.test.js
@@ -319,7 +319,7 @@ describe('UpdateNode', function() {
     var v = new ConstantNode(5);
 
     var n = new UpdateNode(new IndexNode(a, ranges), v);
-    assert.equal(n.toString(), 'a[2, 1] = 5');
+    assert.equal(n.toTex(), '\\mathrm{a}_{\\left[2,1\\right]}:=5');
   });
 
   it ('should LaTeX an UpdateNode with custom toTex', function () {
diff --git a/test/function/arithmetic/abs.test.js b/test/function/arithmetic/abs.test.js
index 154d92341..6a2ed8060 100644
--- a/test/function/arithmetic/abs.test.js
+++ b/test/function/arithmetic/abs.test.js
@@ -62,7 +62,7 @@ describe('abs', function () {
 
   it('should LaTeX abs', function () {
 	  var expression = math.parse('abs(-1)');
-	  assert.equal(expression.toTex(),'\\left|{-{1}}\\right|');
+	  assert.equal(expression.toTex(),'\\left|-1\\right|');
   });
 
 });
diff --git a/test/function/arithmetic/add.test.js b/test/function/arithmetic/add.test.js
index ec7625d6e..0254738ab 100644
--- a/test/function/arithmetic/add.test.js
+++ b/test/function/arithmetic/add.test.js
@@ -145,7 +145,7 @@ describe('add', function() {
 
   it('should LaTeX add', function () {
     var expression = math.parse('add(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}+{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1+2\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/ceil.test.js b/test/function/arithmetic/ceil.test.js
index bb562e228..b06102372 100644
--- a/test/function/arithmetic/ceil.test.js
+++ b/test/function/arithmetic/ceil.test.js
@@ -76,7 +76,7 @@ describe('ceil', function() {
 
   it('should LaTeX ceil', function () {
     var expression = math.parse('ceil(0.5)');
-    assert.equal(expression.toTex(), '\\left\\lceil{0.5}\\right\\rceil');
+    assert.equal(expression.toTex(), '\\left\\lceil0.5\\right\\rceil');
   });
 
 });
diff --git a/test/function/arithmetic/cube.test.js b/test/function/arithmetic/cube.test.js
index a65f000ac..1e5601edb 100644
--- a/test/function/arithmetic/cube.test.js
+++ b/test/function/arithmetic/cube.test.js
@@ -59,7 +59,7 @@ describe('cube', function() {
 
   it('should LaTeX cube', function () {
     var expression = math.parse('cube(2)');
-    assert.equal(expression.toTex(), '\\left({2}\\right)^{3}');
+    assert.equal(expression.toTex(), '\\left(2\\right)^3');
   });
 
 });
diff --git a/test/function/arithmetic/dotDivide.test.js b/test/function/arithmetic/dotDivide.test.js
index 49f107483..da0c18b8e 100644
--- a/test/function/arithmetic/dotDivide.test.js
+++ b/test/function/arithmetic/dotDivide.test.js
@@ -89,7 +89,7 @@ describe('dotDivide', function() {
 
   it('should LaTeX dotDivide', function () {
     var expression = math.parse('dotDivide([1,2],[3,4])');
-    assert.equal(expression.toTex(), '\\left({\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}}.:{\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}.:\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/dotMultiply.test.js b/test/function/arithmetic/dotMultiply.test.js
index 45f227c64..437dc95ad 100644
--- a/test/function/arithmetic/dotMultiply.test.js
+++ b/test/function/arithmetic/dotMultiply.test.js
@@ -97,6 +97,6 @@ describe('dotMultiply', function() {
   
   it('should LaTeX dotMultiply', function () {
     var expression = math.parse('dotMultiply([1,2],[3,4])');
-    assert.equal(expression.toTex(), '\\left({\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}}.\\cdot{\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}.\\cdot\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}\\right)');
   });
 });
diff --git a/test/function/arithmetic/dotPow.test.js b/test/function/arithmetic/dotPow.test.js
index 8f5df2982..5c7f5d680 100644
--- a/test/function/arithmetic/dotPow.test.js
+++ b/test/function/arithmetic/dotPow.test.js
@@ -105,7 +105,7 @@ describe('dotPow', function() {
 
   it('should LaTeX dotPow', function () {
     var expression = math.parse('dotPow([1,2],[3,4])');
-    assert.equal(expression.toTex(), '\\left({\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}}.^{\\wedge}{\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}.^\\wedge\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/exp.test.js b/test/function/arithmetic/exp.test.js
index fd70389ad..cd290b118 100644
--- a/test/function/arithmetic/exp.test.js
+++ b/test/function/arithmetic/exp.test.js
@@ -81,7 +81,7 @@ describe('exp', function() {
 
   it('should LaTeX exp', function () {
     var expression = math.parse('exp(0)');
-    assert.equal(expression.toTex(), '\\exp\\left({0}\\right)');
+    assert.equal(expression.toTex(), '\\exp\\left(0\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/fix.test.js b/test/function/arithmetic/fix.test.js
index 551727b8e..1413d0975 100644
--- a/test/function/arithmetic/fix.test.js
+++ b/test/function/arithmetic/fix.test.js
@@ -78,7 +78,7 @@ describe('fix', function() {
 
   it('should LaTeX fix', function () {
     var expression = math.parse('fix(0.6)');
-    assert.equal(expression.toTex(), '\\mathrm{fix}\\left({0.6}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{fix}\\left(0.6\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/floor.test.js b/test/function/arithmetic/floor.test.js
index 6df77adb9..b39146799 100644
--- a/test/function/arithmetic/floor.test.js
+++ b/test/function/arithmetic/floor.test.js
@@ -74,7 +74,7 @@ describe('floor', function() {
 
   it('should LaTeX floor', function () {
     var expression = math.parse('floor(0.6)');
-    assert.equal(expression.toTex(), '\\left\\lfloor{0.6}\\right\\rfloor');
+    assert.equal(expression.toTex(), '\\left\\lfloor0.6\\right\\rfloor');
   });
 
 });
diff --git a/test/function/arithmetic/gcd.test.js b/test/function/arithmetic/gcd.test.js
index 0979afeab..3da3d3caa 100644
--- a/test/function/arithmetic/gcd.test.js
+++ b/test/function/arithmetic/gcd.test.js
@@ -96,7 +96,7 @@ describe('gcd', function() {
 
   it('should LaTeX gcd', function () {
     var expression = math.parse('gcd(2,3)');
-    assert.equal(expression.toTex(), '\\gcd\\left({2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\gcd\\left(2,3\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/lcm.test.js b/test/function/arithmetic/lcm.test.js
index dfd0c8930..dea13d424 100644
--- a/test/function/arithmetic/lcm.test.js
+++ b/test/function/arithmetic/lcm.test.js
@@ -82,7 +82,7 @@ describe('lcm', function() {
 
   it('should LaTeX lcm', function () {
     var expression = math.parse('lcm(2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{lcm}\\left({2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{lcm}\\left(2,3\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/log.test.js b/test/function/arithmetic/log.test.js
index ba36600ad..c34ff36a3 100644
--- a/test/function/arithmetic/log.test.js
+++ b/test/function/arithmetic/log.test.js
@@ -105,8 +105,8 @@ describe('log', function() {
     var expr1 = math.parse('log(e)');
     var expr2 = math.parse('log(32,2)');
 
-    assert.equal(expr1.toTex(), '\\ln\\left({\\mathrm{e}}\\right)');
-    assert.equal(expr2.toTex(), '\\log_{2}\\left({32}\\right)');
+    assert.equal(expr1.toTex(), '\\ln\\left(\\mathrm{e}\\right)');
+    assert.equal(expr2.toTex(), '\\log_{2}\\left(32\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/log10.test.js b/test/function/arithmetic/log10.test.js
index bb024e8ce..f3faa5540 100644
--- a/test/function/arithmetic/log10.test.js
+++ b/test/function/arithmetic/log10.test.js
@@ -102,7 +102,7 @@ describe('log10', function() {
 
   it('should LaTeX log10', function () {
     var expression = math.parse('log10(10)');
-    assert.equal(expression.toTex(), '\\log_{10}\\left({10}\\right)');
+    assert.equal(expression.toTex(), '\\log_{10}\\left(10\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/mod.test.js b/test/function/arithmetic/mod.test.js
index 44e3fdeb7..d3820fa98 100644
--- a/test/function/arithmetic/mod.test.js
+++ b/test/function/arithmetic/mod.test.js
@@ -106,7 +106,7 @@ describe('mod', function() {
 
   it('should LaTeX mod', function () {
     var expression = math.parse('mod(11,2)');
-    assert.equal(expression.toTex(), '\\left({11}\\mod{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(11\\mod2\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/multiply.test.js b/test/function/arithmetic/multiply.test.js
index cba3ef8ea..f6ce33eef 100644
--- a/test/function/arithmetic/multiply.test.js
+++ b/test/function/arithmetic/multiply.test.js
@@ -278,7 +278,7 @@ describe('multiply', function() {
 
   it('should LaTeX mutliply', function () {
     var expression = math.parse('multiply(2,3)');
-    assert.equal(expression.toTex(), '\\left({2}\\cdot{3}\\right)');
+    assert.equal(expression.toTex(), '\\left(2\\cdot3\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/norm.test.js b/test/function/arithmetic/norm.test.js
index 967550430..b0c9ba93d 100644
--- a/test/function/arithmetic/norm.test.js
+++ b/test/function/arithmetic/norm.test.js
@@ -105,7 +105,7 @@ describe('norm', function () {
     var expr1 = math.parse('norm(a)');
     var expr2 = math.parse("norm(a,2)");
 
-    assert.equal(expr1.toTex(), '\\left\\|{\\mathrm{a}}\\right\\|');
-    assert.equal(expr2.toTex(), '\\mathrm{norm}\\left({\\mathrm{a}},{2}\\right)');
+    assert.equal(expr1.toTex(), '\\left\\|\\mathrm{a}\\right\\|');
+    assert.equal(expr2.toTex(), '\\mathrm{norm}\\left(\\mathrm{a},2\\right)');
   });
 });
diff --git a/test/function/arithmetic/nthRoot.test.js b/test/function/arithmetic/nthRoot.test.js
index 78f5cc533..e3e887e27 100644
--- a/test/function/arithmetic/nthRoot.test.js
+++ b/test/function/arithmetic/nthRoot.test.js
@@ -111,7 +111,7 @@ describe('nthRoot', function() {
 
   it('should LaTeX nthRoot', function () {
     var expression = math.parse('nthRoot(8,3)');
-    assert.equal(expression.toTex(), '\\sqrt[{3}]{8}');
+    assert.equal(expression.toTex(), '\\sqrt[3]{8}');
   });
 
 });
diff --git a/test/function/arithmetic/pow.test.js b/test/function/arithmetic/pow.test.js
index afff86179..6f4b82224 100644
--- a/test/function/arithmetic/pow.test.js
+++ b/test/function/arithmetic/pow.test.js
@@ -170,7 +170,7 @@ describe('pow', function() {
 
   it('should LaTeX pow', function () {
     var expression = math.parse('pow(2,10)');
-    assert.equal(expression.toTex(), '\\left({2}^{10}\\right)');
+    assert.equal(expression.toTex(), '\\left(2\\right)^{10}');
   });
 
 });
diff --git a/test/function/arithmetic/round.test.js b/test/function/arithmetic/round.test.js
index a30d56c8f..3d5b9e7d8 100644
--- a/test/function/arithmetic/round.test.js
+++ b/test/function/arithmetic/round.test.js
@@ -88,8 +88,8 @@ describe('round', function() {
     var expr1 = math.parse('round(1.1)');
     var expr2 = math.parse('round(1.1,2)');
 
-    assert.equal(expr1.toTex(), '\\left\\lfloor{1.1}\\right\\rceil');
-    assert.equal(expr2.toTex(), '\\mathrm{round}\\left({1.1},{2}\\right)');
+    assert.equal(expr1.toTex(), '\\left\\lfloor1.1\\right\\rceil');
+    assert.equal(expr2.toTex(), '\\mathrm{round}\\left(1.1,2\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/sign.test.js b/test/function/arithmetic/sign.test.js
index cc397a536..7f49d1ddd 100644
--- a/test/function/arithmetic/sign.test.js
+++ b/test/function/arithmetic/sign.test.js
@@ -54,7 +54,7 @@ describe('sign', function() {
 
   it('should LaTeX sign', function () {
     var expression = math.parse('sign(-4)');
-    assert.equal(expression.toTex(), '\\mathrm{sign}\\left({-{4}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{sign}\\left(-4\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/square.test.js b/test/function/arithmetic/square.test.js
index 305c70098..7e257fb2a 100644
--- a/test/function/arithmetic/square.test.js
+++ b/test/function/arithmetic/square.test.js
@@ -57,7 +57,7 @@ describe('square', function() {
 
   it('should LaTeX square', function () {
     var expression = math.parse('square(4)');
-    assert.equal(expression.toTex(), '\\left({4}\\right)^{2}');
+    assert.equal(expression.toTex(), '\\left(4\\right)^2');
   });
 
 });
diff --git a/test/function/arithmetic/subtract.test.js b/test/function/arithmetic/subtract.test.js
index 6f5675be5..7fbd19df5 100644
--- a/test/function/arithmetic/subtract.test.js
+++ b/test/function/arithmetic/subtract.test.js
@@ -128,7 +128,7 @@ describe('subtract', function() {
 
   it('should LaTeX subtract', function () {
     var expression = math.parse('subtract(2,1)');
-    assert.equal(expression.toTex(), '\\left({2}-{1}\\right)');
+    assert.equal(expression.toTex(), '\\left(2-1\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/unaryMinus.test.js b/test/function/arithmetic/unaryMinus.test.js
index a343578e9..1544a5af8 100644
--- a/test/function/arithmetic/unaryMinus.test.js
+++ b/test/function/arithmetic/unaryMinus.test.js
@@ -74,7 +74,7 @@ describe('unaryMinus', function() {
 
   it('should LaTeX unaryMinus', function () {
     var expression = math.parse('unaryMinus(1)');
-    assert.equal(expression.toTex(), '-\\left({1}\\right)');
+    assert.equal(expression.toTex(), '-\\left(1\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/unaryPlus.test.js b/test/function/arithmetic/unaryPlus.test.js
index 34458a7f8..8a35e0a08 100644
--- a/test/function/arithmetic/unaryPlus.test.js
+++ b/test/function/arithmetic/unaryPlus.test.js
@@ -74,7 +74,7 @@ describe('unaryPlus', function() {
 
   it('should LaTeX unaryPlus', function () {
     var expression = math.parse('unaryPlus(1)');
-    assert.equal(expression.toTex(), '+\\left({1}\\right)');
+    assert.equal(expression.toTex(), '+\\left(1\\right)');
   });
 
 });
diff --git a/test/function/arithmetic/xgcd.test.js b/test/function/arithmetic/xgcd.test.js
index 23fd42061..ae620830d 100644
--- a/test/function/arithmetic/xgcd.test.js
+++ b/test/function/arithmetic/xgcd.test.js
@@ -122,7 +122,7 @@ describe('xgcd', function() {
 
   it('should LaTeX xgcd', function () {
     var expression = math.parse('xgcd(2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{xgcd}\\left({2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{xgcd}\\left(2,3\\right)');
   });
 
 });
diff --git a/test/function/bitwise/bitAnd.test.js b/test/function/bitwise/bitAnd.test.js
index a7233d959..bbc788380 100644
--- a/test/function/bitwise/bitAnd.test.js
+++ b/test/function/bitwise/bitAnd.test.js
@@ -136,7 +136,7 @@ describe('bitAnd', function () {
 
   it('should LaTeX bitAnd', function () {
     var expression = math.parse('bitAnd(4,2)');
-    assert.equal(expression.toTex(), '\\left({4}\\&{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(4\\&2\\right)');
   });
 
 });
diff --git a/test/function/bitwise/bitNot.test.js b/test/function/bitwise/bitNot.test.js
index 10a21333a..526a7101e 100644
--- a/test/function/bitwise/bitNot.test.js
+++ b/test/function/bitwise/bitNot.test.js
@@ -65,7 +65,7 @@ describe('bitNot', function () {
 
   it('should LaTeX bitNot', function () {
     var expression = math.parse('bitNot(4)');
-    assert.equal(expression.toTex(), '~\\left({4}\\right)');
+    assert.equal(expression.toTex(), '~\\left(4\\right)');
   });
 
 });
diff --git a/test/function/bitwise/bitOr.test.js b/test/function/bitwise/bitOr.test.js
index 2140e90ae..1a1cd5e43 100644
--- a/test/function/bitwise/bitOr.test.js
+++ b/test/function/bitwise/bitOr.test.js
@@ -134,7 +134,7 @@ describe('bitOr', function () {
 
   it('should LaTeX bitOr', function () {
     var expression = math.parse('bitOr(2,3)');
-    assert.equal(expression.toTex(), '\\left({2}|{3}\\right)');
+    assert.equal(expression.toTex(), '\\left(2|3\\right)');
   });
 
 });
diff --git a/test/function/bitwise/bitXor.test.js b/test/function/bitwise/bitXor.test.js
index aee0bca40..afad41924 100644
--- a/test/function/bitwise/bitXor.test.js
+++ b/test/function/bitwise/bitXor.test.js
@@ -136,7 +136,7 @@ describe('bitXor', function () {
 
   it('should LaTeX bitXor', function () {
     var expression = math.parse('bitXor(2,3)');
-    assert.equal(expression.toTex(), '\\left({2}\\underline{|}{3}\\right)');
+    assert.equal(expression.toTex(), '\\left(2\\underline{|}3\\right)');
   });
 
 });
diff --git a/test/function/bitwise/leftShift.test.js b/test/function/bitwise/leftShift.test.js
index 7b79c101a..c9a777726 100644
--- a/test/function/bitwise/leftShift.test.js
+++ b/test/function/bitwise/leftShift.test.js
@@ -130,7 +130,7 @@ describe('leftShift', function () {
 
   it('should LaTeX leftShift', function () {
     var expression = math.parse('leftShift(2,3)');
-    assert.equal(expression.toTex(), '\\left({2}<<{3}\\right)');
+    assert.equal(expression.toTex(), '\\left(2<<3\\right)');
   });
 
 });
diff --git a/test/function/bitwise/rightArithShift.test.js b/test/function/bitwise/rightArithShift.test.js
index 3f6723ae1..1e20377d0 100644
--- a/test/function/bitwise/rightArithShift.test.js
+++ b/test/function/bitwise/rightArithShift.test.js
@@ -133,7 +133,7 @@ describe('rightArithShift', function () {
 
   it('should LaTeX rightArithShift', function () {
     var expression = math.parse('rightArithShift(3,2)');
-    assert.equal(expression.toTex(), '\\left({3}>>{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(3>>2\\right)');
   });
 
 });
diff --git a/test/function/bitwise/rightLogShift.test.js b/test/function/bitwise/rightLogShift.test.js
index f1c959158..c35de941e 100644
--- a/test/function/bitwise/rightLogShift.test.js
+++ b/test/function/bitwise/rightLogShift.test.js
@@ -92,7 +92,7 @@ describe('rightLogShift', function () {
 
   it('should LaTeX rightLogShift', function () {
     var expression = math.parse('rightLogShift(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}>>>{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1>>>2\\right)');
   });
 
 });
diff --git a/test/function/complex/arg.test.js b/test/function/complex/arg.test.js
index 5930fcc65..9a1f6f50b 100644
--- a/test/function/complex/arg.test.js
+++ b/test/function/complex/arg.test.js
@@ -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)');
   });
 
 });
diff --git a/test/function/complex/conj.test.js b/test/function/complex/conj.test.js
index 7db4659e3..a3d5fc810 100644
--- a/test/function/complex/conj.test.js
+++ b/test/function/complex/conj.test.js
@@ -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)^*');
   });
 
 });
diff --git a/test/function/complex/im.test.js b/test/function/complex/im.test.js
index 51c7caf2f..cdde02b82 100644
--- a/test/function/complex/im.test.js
+++ b/test/function/complex/im.test.js
@@ -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\\lbrace1+ i\\right\\rbrace');
   });
 
 });
diff --git a/test/function/complex/re.test.js b/test/function/complex/re.test.js
index 2a1ba487d..59d7ac164 100644
--- a/test/function/complex/re.test.js
+++ b/test/function/complex/re.test.js
@@ -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\\lbrace1+ i\\right\\rbrace');
   });
 
 });
diff --git a/test/function/construction/bignumber.test.js b/test/function/construction/bignumber.test.js
index 190105330..45069e39b 100644
--- a/test/function/construction/bignumber.test.js
+++ b/test/function/construction/bignumber.test.js
@@ -79,7 +79,7 @@ describe('bignumber', function() {
     var expr2 = math.parse('bignumber(1)');
 
     assert.equal(expr1.toTex(), '0');
-    assert.equal(expr2.toTex(), '\\left({1}\\right)');
+    assert.equal(expr2.toTex(), '\\left(1\\right)');
   });
 
 });
diff --git a/test/function/construction/boolean.test.js b/test/function/construction/boolean.test.js
index 45a6a90dd..4351b919c 100644
--- a/test/function/construction/boolean.test.js
+++ b/test/function/construction/boolean.test.js
@@ -76,7 +76,7 @@ describe('boolean', function() {
 
   it('should LaTeX boolean', function () {
     var expression = math.parse('boolean(1)');
-    assert.equal(expression.toTex(), '\\mathrm{boolean}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{boolean}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/construction/chain.test.js b/test/function/construction/chain.test.js
index 871d793ad..5423d27a5 100644
--- a/test/function/construction/chain.test.js
+++ b/test/function/construction/chain.test.js
@@ -19,7 +19,7 @@ describe('chain', function() {
 
   it('should LaTeX chain', function () {
     var expression = math.parse('chain(1)');
-    assert.equal(expression.toTex(), '\\mathrm{chain}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{chain}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/construction/complex.test.js b/test/function/construction/complex.test.js
index bb044b612..8b867b08a 100644
--- a/test/function/construction/complex.test.js
+++ b/test/function/construction/complex.test.js
@@ -86,7 +86,7 @@ describe('complex', function() {
     var expr3 = math.parse('complex(1,2)');
 
     assert.equal(expr1.toTex(), '0');
-    assert.equal(expr2.toTex(), '\\left({1}\\right)');
-    assert.equal(expr3.toTex(), '\\left({\\left({1}\\right)+i\\cdot\\left({2}\\right)}\\right)');
+    assert.equal(expr2.toTex(), '\\left(1\\right)');
+    assert.equal(expr3.toTex(), '\\left(\\left(1\\right)+i\\cdot\\left(2\\right)\\right)');
   });
 });
diff --git a/test/function/construction/index.test.js b/test/function/construction/index.test.js
index 72c28f0ed..18e53b9a5 100644
--- a/test/function/construction/index.test.js
+++ b/test/function/construction/index.test.js
@@ -26,9 +26,9 @@ describe('index', function() {
     var expr2 = math.parse('index(1,2)');
     var expr3 = math.parse('index(1,2,3)');
 
-    assert.equal(expr1.toTex(), '\\mathrm{index}\\left({1}\\right)');
-    assert.equal(expr2.toTex(), '\\mathrm{index}\\left({1},{2}\\right)');
-    assert.equal(expr3.toTex(), '\\mathrm{index}\\left({1},{2},{3}\\right)');
+    assert.equal(expr1.toTex(), '\\mathrm{index}\\left(1\\right)');
+    assert.equal(expr2.toTex(), '\\mathrm{index}\\left(1,2\\right)');
+    assert.equal(expr3.toTex(), '\\mathrm{index}\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/construction/matrix.test.js b/test/function/construction/matrix.test.js
index 36681df84..7c5994b59 100644
--- a/test/function/construction/matrix.test.js
+++ b/test/function/construction/matrix.test.js
@@ -89,6 +89,6 @@ describe('matrix', function() {
     var expr2 = math.parse('matrix([1])');
 
     assert.equal(expr1.toTex(), '\\begin{bmatrix}\\end{bmatrix}');
-    assert.equal(expr2.toTex(), '\\left({\\begin{bmatrix}1\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expr2.toTex(), '\\left(\\begin{bmatrix}1\\\\\\end{bmatrix}\\right)');
   });
 });
diff --git a/test/function/construction/number.test.js b/test/function/construction/number.test.js
index 9d3474490..5bdcd2020 100644
--- a/test/function/construction/number.test.js
+++ b/test/function/construction/number.test.js
@@ -73,8 +73,8 @@ describe('number', function() {
     var expr3 = math.parse('number(1,cm)');
 
     assert.equal(expr1.toTex(), '0');
-    assert.equal(expr2.toTex(), '\\left({1}\\right)');
-    assert.equal(expr3.toTex(), '\\left(\\left({1}\\right){\\mathrm{cm}}\\right)');
+    assert.equal(expr2.toTex(), '\\left(1\\right)');
+    assert.equal(expr3.toTex(), '\\left(\\left(1\\right)\\mathrm{cm}\\right)');
   });
 });
 
diff --git a/test/function/construction/unit.test.js b/test/function/construction/unit.test.js
index 8af58d09a..c6eb9e7c6 100644
--- a/test/function/construction/unit.test.js
+++ b/test/function/construction/unit.test.js
@@ -73,7 +73,7 @@ describe('unit', function() {
     var expr1 = math.parse('unit(cm)');
     var expr2 = math.parse('unit(1,cm)');
 
-    assert.equal(expr1.toTex(), '\\left({\\mathrm{cm}}\\right)');
-    assert.equal(expr2.toTex(), '\\left({\\left({1}\\right){\\mathrm{cm}}}\\right)');
+    assert.equal(expr1.toTex(), '\\left(\\mathrm{cm}\\right)');
+    assert.equal(expr2.toTex(), '\\left(\\left(1\\right)\\mathrm{cm}\\right)');
   });
 });
diff --git a/test/function/expression/compile.test.js b/test/function/expression/compile.test.js
index ef06086ad..37418abfa 100644
--- a/test/function/expression/compile.test.js
+++ b/test/function/expression/compile.test.js
@@ -34,7 +34,7 @@ describe('parse', function() {
 
   it('should LaTeX compile', function () {
     var expression = math.parse('compile(1)');
-    assert.equal(expression.toTex(), '\\mathrm{compile}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{compile}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/expression/eval.test.js b/test/function/expression/eval.test.js
index d5d34de4e..31b8889c9 100644
--- a/test/function/expression/eval.test.js
+++ b/test/function/expression/eval.test.js
@@ -77,8 +77,8 @@ describe('eval', function() {
     var expr1 = math.parse('eval(expr)');
     var expr2 = math.parse('eval(expr,scope)');
 
-    assert.equal(expr1.toTex(), '\\mathrm{eval}\\left({\\mathrm{expr}}\\right)');
-    assert.equal(expr2.toTex(), '\\mathrm{eval}\\left({\\mathrm{expr}},{\\mathrm{scope}}\\right)');
+    assert.equal(expr1.toTex(), '\\mathrm{eval}\\left(\\mathrm{expr}\\right)');
+    assert.equal(expr2.toTex(), '\\mathrm{eval}\\left(\\mathrm{expr},\\mathrm{scope}\\right)');
   });
 
 });
diff --git a/test/function/expression/help.test.js b/test/function/expression/help.test.js
index ecb91a647..803b8c7af 100644
--- a/test/function/expression/help.test.js
+++ b/test/function/expression/help.test.js
@@ -54,7 +54,7 @@ describe('help', function() {
 
   it('should LaTeX help', function () {
     var expression = math.parse('help(parse)');
-    assert.equal(expression.toTex(), '\\mathrm{help}\\left({\\mathrm{parse}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{help}\\left(\\mathrm{parse}\\right)');
   });
 
 });
diff --git a/test/function/expression/parse.test.js b/test/function/expression/parse.test.js
index ceabe6335..d1767dcd0 100644
--- a/test/function/expression/parse.test.js
+++ b/test/function/expression/parse.test.js
@@ -25,7 +25,7 @@ describe('parse', function() {
 
   it('should LaTeX parse', function () {
     var expression = math.parse('parse(expr,options)');
-    assert.equal(expression.toTex(), '\\mathrm{parse}\\left({\\mathrm{expr}},{\\mathrm{options}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{parse}\\left(\\mathrm{expr},\\mathrm{options}\\right)');
   });
 
 });
diff --git a/test/function/logical/and.test.js b/test/function/logical/and.test.js
index df69478b8..9c96606bb 100644
--- a/test/function/logical/and.test.js
+++ b/test/function/logical/and.test.js
@@ -153,7 +153,7 @@ describe('and', function () {
 
   it('should LaTeX and', function () {
     var expression = math.parse('and(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}\\wedge{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1\\wedge2\\right)');
   });
 
 });
diff --git a/test/function/logical/not.test.js b/test/function/logical/not.test.js
index 9160a8b34..382a235da 100644
--- a/test/function/logical/not.test.js
+++ b/test/function/logical/not.test.js
@@ -87,7 +87,7 @@ describe('not', function () {
   it('should LaTeX not', function () {
     var c = new ConstantNode(1);
     var node = new FunctionNode('not', [c]);
-    assert.equal(node.toTex(), '\\neg\\left({1}\\right)');
+    assert.equal(node.toTex(), '\\neg\\left(1\\right)');
   });
 
 });
diff --git a/test/function/logical/or.test.js b/test/function/logical/or.test.js
index e10554ef1..109385fab 100644
--- a/test/function/logical/or.test.js
+++ b/test/function/logical/or.test.js
@@ -177,7 +177,7 @@ describe('or', function () {
 
   it('should LaTeX or', function () {
     var expression = math.parse('or(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}\\vee{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1\\vee2\\right)');
   });
 
 });
diff --git a/test/function/logical/xor.test.js b/test/function/logical/xor.test.js
index 9cacee0a6..53689c4bd 100644
--- a/test/function/logical/xor.test.js
+++ b/test/function/logical/xor.test.js
@@ -173,7 +173,7 @@ describe('xor', function () {
 
   it('should LaTeX xor', function () {
     var expression = math.parse('xor(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}\\veebar{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1\\veebar2\\right)');
   });
 
 });
diff --git a/test/function/matrix/concat.test.js b/test/function/matrix/concat.test.js
index be54fc6e1..d9ce18a12 100644
--- a/test/function/matrix/concat.test.js
+++ b/test/function/matrix/concat.test.js
@@ -103,7 +103,7 @@ describe('concat', function() {
 
   it('should LaTeX concat', function () {
     var expression = math.parse('concat([1],[2])');
-    assert.equal(expression.toTex(), '\\mathrm{concat}\\left({\\begin{bmatrix}1\\\\\\end{bmatrix}},{\\begin{bmatrix}2\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{concat}\\left(\\begin{bmatrix}1\\\\\\end{bmatrix},\\begin{bmatrix}2\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/matrix/cross.test.js b/test/function/matrix/cross.test.js
index cd7097c67..f96169b40 100644
--- a/test/function/matrix/cross.test.js
+++ b/test/function/matrix/cross.test.js
@@ -40,7 +40,7 @@ describe('cross', function() {
 
   it('should LaTeX cross', function () {
     var expression = math.parse('cross([1],[2])');
-    assert.equal(expression.toTex(), '{\\begin{bmatrix}1\\\\\\end{bmatrix}}\\times{\\begin{bmatrix}2\\\\\\end{bmatrix}}');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1\\\\\\end{bmatrix}\\right)\\times\\left(\\begin{bmatrix}2\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/matrix/det.test.js b/test/function/matrix/det.test.js
index 509e5ec60..f99187ca3 100644
--- a/test/function/matrix/det.test.js
+++ b/test/function/matrix/det.test.js
@@ -132,7 +132,7 @@ describe('det', function() {
 
   it('should LaTeX det', function () {
     var expression = math.parse('det([1])');
-    assert.equal(expression.toTex(), '\\det\\left({\\begin{bmatrix}1\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\det\\left(\\begin{bmatrix}1\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/matrix/diag.test.js b/test/function/matrix/diag.test.js
index 0364e15c3..3af52c970 100644
--- a/test/function/matrix/diag.test.js
+++ b/test/function/matrix/diag.test.js
@@ -129,8 +129,8 @@ describe('diag', function() {
     var expr1 = math.parse('diag([1,2,3])');
     var expr2 = math.parse('diag([1,2,3],1)');
 
-    assert.equal(expr1.toTex(), '\\mathrm{diag}\\left({\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}}\\right)');
-    assert.equal(expr2.toTex(), '\\mathrm{diag}\\left({\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}},{1}\\right)');
+    assert.equal(expr1.toTex(), '\\mathrm{diag}\\left(\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}\\right)');
+    assert.equal(expr2.toTex(), '\\mathrm{diag}\\left(\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix},1\\right)');
   });
 
 });
diff --git a/test/function/matrix/dot.test.js b/test/function/matrix/dot.test.js
index 2809e2833..d0a90072d 100644
--- a/test/function/matrix/dot.test.js
+++ b/test/function/matrix/dot.test.js
@@ -37,7 +37,7 @@ describe('dot', function() {
 
   it('should LaTeX dot', function () {
     var expression = math.parse('dot([1,2],[3,4])');
-    assert.equal(expression.toTex(), '\\left({\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}}\\cdot{\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}\\cdot\\begin{bmatrix}3\\\\4\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/matrix/eye.test.js b/test/function/matrix/eye.test.js
index 9a02d24ce..a54a9bed5 100644
--- a/test/function/matrix/eye.test.js
+++ b/test/function/matrix/eye.test.js
@@ -60,7 +60,7 @@ describe('eye', function() {
 
   it('should LaTeX eye', function () {
     var expression = math.parse('eye(2)');
-    assert.equal(expression.toTex(), '\\mathrm{eye}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{eye}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/matrix/flatten.test.js b/test/function/matrix/flatten.test.js
index 3006fe413..8cad79d45 100644
--- a/test/function/matrix/flatten.test.js
+++ b/test/function/matrix/flatten.test.js
@@ -49,7 +49,7 @@ describe('flatten', function() {
 
   it('should LaTeX flatten', function () {
     var expression = math.parse('flatten([[1,2],[3,4]])');
-    assert.equal(expression.toTex(), '\\mathrm{flatten}\\left({\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{flatten}\\left(\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/matrix/inv.test.js b/test/function/matrix/inv.test.js
index 828e0dbf4..228948c2a 100644
--- a/test/function/matrix/inv.test.js
+++ b/test/function/matrix/inv.test.js
@@ -86,7 +86,7 @@ describe('inv', function() {
 
   it('should  LaTeX inv', function () {
     var expression = math.parse('inv([[1,2],[3,4]])');
-    assert.equal(expression.toTex(), '{\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}}^{-1}');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}\\right)^{-1}');
   });
 
 });
diff --git a/test/function/matrix/ones.test.js b/test/function/matrix/ones.test.js
index 5ee38e6c2..f5ac45159 100644
--- a/test/function/matrix/ones.test.js
+++ b/test/function/matrix/ones.test.js
@@ -79,7 +79,7 @@ describe('ones', function() {
 
   it('should LaTeX ones', function () {
     var expression = math.parse('ones(2)');
-    assert.equal(expression.toTex(), '\\mathrm{ones}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{ones}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/matrix/range.test.js b/test/function/matrix/range.test.js
index 0ccba4f57..8b8ffbce6 100644
--- a/test/function/matrix/range.test.js
+++ b/test/function/matrix/range.test.js
@@ -150,6 +150,6 @@ describe('range', function() {
 
   it('should LaTeX range', function () {
     var expression = math.parse('range(1,10)');
-    assert.equal(expression.toTex(), '\\mathrm{range}\\left({1},{10}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{range}\\left(1,10\\right)');
   });
 });
diff --git a/test/function/matrix/resize.test.js b/test/function/matrix/resize.test.js
index 0da37b93e..b88cb6c48 100644
--- a/test/function/matrix/resize.test.js
+++ b/test/function/matrix/resize.test.js
@@ -123,7 +123,7 @@ describe('resize', function() {
 
   it('should LaTeX resize', function () {
     var expression = math.parse('resize([1,2],1)');
-    assert.equal(expression.toTex(), '\\mathrm{resize}\\left({\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}},{1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{resize}\\left(\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix},1\\right)');
   });
 });
 
diff --git a/test/function/matrix/size.test.js b/test/function/matrix/size.test.js
index 4c0198b2f..4eb8ecbb2 100644
--- a/test/function/matrix/size.test.js
+++ b/test/function/matrix/size.test.js
@@ -63,6 +63,6 @@ describe('size', function() {
 
   it('should LaTeX size', function () {
     var expression = math.parse('size(1)');
-    assert.equal(expression.toTex(), '\\mathrm{size}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{size}\\left(1\\right)');
   });
 });
diff --git a/test/function/matrix/squeeze.test.js b/test/function/matrix/squeeze.test.js
index 60daa277b..a51df4320 100644
--- a/test/function/matrix/squeeze.test.js
+++ b/test/function/matrix/squeeze.test.js
@@ -34,6 +34,6 @@ describe('squeeze', function() {
 
   it('should LaTeX squeeze', function () {
     var expression = math.parse('squeeze([[0],[0]])');
-    assert.equal(expression.toTex(), '\\mathrm{squeeze}\\left({\\begin{bmatrix}0\\\\0\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{squeeze}\\left(\\begin{bmatrix}0\\\\0\\\\\\end{bmatrix}\\right)');
   });
 });
diff --git a/test/function/matrix/subset.test.js b/test/function/matrix/subset.test.js
index 6a147e46c..49d73f7ed 100644
--- a/test/function/matrix/subset.test.js
+++ b/test/function/matrix/subset.test.js
@@ -150,7 +150,7 @@ describe('subset', function() {
 
   it('should LaTeX subset', function () {
     var expression = math.parse('subset([1],index(0,0))');
-    assert.equal(expression.toTex(), '\\mathrm{subset}\\left({\\begin{bmatrix}1\\\\\\end{bmatrix}},{\\mathrm{index}\\left({0},{0}\\right)}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{subset}\\left(\\begin{bmatrix}1\\\\\\end{bmatrix},\\mathrm{index}\\left(0,0\\right)\\right)');
   });
 });
 
diff --git a/test/function/matrix/trace.test.js b/test/function/matrix/trace.test.js
index 83bd82315..842d83eaf 100644
--- a/test/function/matrix/trace.test.js
+++ b/test/function/matrix/trace.test.js
@@ -207,7 +207,7 @@ describe('trace', function() {
 
   it('should LaTeX trace', function () {
     var expression = math.parse('trace([[1,2],[3,4]])');
-    assert.equal(expression.toTex(), '\\mathrm{tr}\\left({\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{tr}\\left(\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/matrix/transpose.test.js b/test/function/matrix/transpose.test.js
index 2d3ef5ed3..88ecf2292 100644
--- a/test/function/matrix/transpose.test.js
+++ b/test/function/matrix/transpose.test.js
@@ -38,6 +38,6 @@ describe('transpose', function() {
 
   it('should LaTeX transpose', function () {
     var expression = math.parse('transpose([[1,2],[3,4]])');
-    assert.equal(expression.toTex(), '{\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}}^{\\top}');
+    assert.equal(expression.toTex(), '\\left(\\begin{bmatrix}1&2\\\\3&4\\\\\\end{bmatrix}\\right)^\\top');
   });
 });
diff --git a/test/function/matrix/zeros.test.js b/test/function/matrix/zeros.test.js
index 43e9f24c0..b825a5625 100644
--- a/test/function/matrix/zeros.test.js
+++ b/test/function/matrix/zeros.test.js
@@ -79,6 +79,6 @@ describe('zeros', function() {
 
   it('should LaTeX zeros', function () {
     var expression = math.parse('zeros(2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{zeros}\\left({2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{zeros}\\left(2,3\\right)');
   });
 });
diff --git a/test/function/probability/distribution.test.js b/test/function/probability/distribution.test.js
index dd2c7a0db..e839476e0 100644
--- a/test/function/probability/distribution.test.js
+++ b/test/function/probability/distribution.test.js
@@ -329,6 +329,6 @@ describe('distribution', function () {
 
   it('should LaTeX distribution', function () {
     var expression = math.parse('distribution(normal)');
-    assert.equal(expression.toTex(), '\\mathrm{distribution}\\left({\\mathrm{normal}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{distribution}\\left(\\mathrm{normal}\\right)');
   });
 });
diff --git a/test/function/probability/factorial.test.js b/test/function/probability/factorial.test.js
index 80f8a9e6e..3438737dd 100644
--- a/test/function/probability/factorial.test.js
+++ b/test/function/probability/factorial.test.js
@@ -90,7 +90,7 @@ describe('factorial', function() {
 
   it('should LaTeX factorial', function () {
     var expression = math.parse('factorial(6)');
-    assert.equal(expression.toTex(), '\\left({6}\\right)!');
+    assert.equal(expression.toTex(), '\\left(6\\right)!');
   });
 
 });
diff --git a/test/function/probability/gamma.test.js b/test/function/probability/gamma.test.js
index 479694b2d..190d6e177 100644
--- a/test/function/probability/gamma.test.js
+++ b/test/function/probability/gamma.test.js
@@ -159,7 +159,7 @@ describe('gamma', function () {
 
   it('should LaTeX gamma', function () {
     var expression = math.parse('gamma(2.5)');
-    assert.equal(expression.toTex(), '\\Gamma\\left({2.5}\\right)');
+    assert.equal(expression.toTex(), '\\Gamma\\left(2.5\\right)');
   });
 
 });
diff --git a/test/function/probability/permutations.test.js b/test/function/probability/permutations.test.js
index b7ca222c6..ba56ee9c6 100644
--- a/test/function/probability/permutations.test.js
+++ b/test/function/probability/permutations.test.js
@@ -57,7 +57,7 @@ describe('permutations', function() {
 
   it('should LaTeX permutations', function () {
     var expression = math.parse('permutations(2)');
-    assert.equal(expression.toTex(), '\\mathrm{permutations}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{permutations}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/probability/pickRandom.test.js b/test/function/probability/pickRandom.test.js
index 33383d009..8404390f6 100644
--- a/test/function/probability/pickRandom.test.js
+++ b/test/function/probability/pickRandom.test.js
@@ -11,7 +11,7 @@ describe('pickRandom', function () {
 
   it('should LaTeX pickRandom', function () {
     var expression = math.parse('pickRandom([1,2,3])');
-    assert.equal(expression.toTex(), '\\mathrm{pickRandom}\\left({\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{pickRandom}\\left(\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/probability/random.test.js b/test/function/probability/random.test.js
index c36959a1f..38c48b318 100644
--- a/test/function/probability/random.test.js
+++ b/test/function/probability/random.test.js
@@ -11,6 +11,6 @@ describe('random', function () {
 
   it('should LaTeX random', function () {
     var expression = math.parse('random(0,1)');
-    assert.equal(expression.toTex(), '\\mathrm{random}\\left({0},{1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{random}\\left(0,1\\right)');
   });
 });
diff --git a/test/function/probability/randomInt.test.js b/test/function/probability/randomInt.test.js
index b59b0c264..31a36f2e4 100644
--- a/test/function/probability/randomInt.test.js
+++ b/test/function/probability/randomInt.test.js
@@ -11,6 +11,6 @@ describe('randomInt', function () {
 
   it('should LaTeX randomInt', function () {
     var expression = math.parse('randomInt(0,100)');
-    assert.equal(expression.toTex(), '\\mathrm{randomInt}\\left({0},{100}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{randomInt}\\left(0,100\\right)');
   });
 });
diff --git a/test/function/relational/compare.test.js b/test/function/relational/compare.test.js
index ef0b2ba1c..aee98c0a0 100644
--- a/test/function/relational/compare.test.js
+++ b/test/function/relational/compare.test.js
@@ -137,7 +137,7 @@ describe('compare', function() {
 
   it('should LaTeX compare', function () {
     var expression = math.parse('compare(1,2)');
-    assert.equal(expression.toTex(), '\\mathrm{compare}\\left({1},{2}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{compare}\\left(1,2\\right)');
   });
 
 });
diff --git a/test/function/relational/deepEqual.test.js b/test/function/relational/deepEqual.test.js
index 03545658e..2ad5bfb2e 100644
--- a/test/function/relational/deepEqual.test.js
+++ b/test/function/relational/deepEqual.test.js
@@ -55,7 +55,7 @@ describe('deepEqual', function() {
 
   it('should LaTeX deepEqual', function () {
     var expression = math.parse('deepEqual([1,2],[1,3])');
-    assert.equal(expression.toTex(), '\\mathrm{deepEqual}\\left({\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix}},{\\begin{bmatrix}1\\\\3\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{deepEqual}\\left(\\begin{bmatrix}1\\\\2\\\\\\end{bmatrix},\\begin{bmatrix}1\\\\3\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/relational/equal.test.js b/test/function/relational/equal.test.js
index b6593a720..f409a8172 100644
--- a/test/function/relational/equal.test.js
+++ b/test/function/relational/equal.test.js
@@ -164,7 +164,7 @@ describe('equal', function() {
 
   it('should LaTeX equal', function () {
     var expression = math.parse('equal(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}={2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1=2\\right)');
   });
 
 });
diff --git a/test/function/relational/larger.test.js b/test/function/relational/larger.test.js
index 3f8c8cf7b..b17c0be4a 100644
--- a/test/function/relational/larger.test.js
+++ b/test/function/relational/larger.test.js
@@ -141,7 +141,7 @@ describe('larger', function() {
 
   it('should LaTeX larger', function () {
     var expression = math.parse('larger(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}>{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1>2\\right)');
   });
 
 });
diff --git a/test/function/relational/largerEq.test.js b/test/function/relational/largerEq.test.js
index a0dac3237..1d4bd3a35 100644
--- a/test/function/relational/largerEq.test.js
+++ b/test/function/relational/largerEq.test.js
@@ -143,7 +143,7 @@ describe('largerEq', function() {
 
   it('should LaTeX largerEq', function () {
     var expression = math.parse('largerEq(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}\\geq{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1\\geq2\\right)');
   });
 
 });
diff --git a/test/function/relational/smaller.test.js b/test/function/relational/smaller.test.js
index bbbe6409f..c0ad5a50d 100644
--- a/test/function/relational/smaller.test.js
+++ b/test/function/relational/smaller.test.js
@@ -145,7 +145,7 @@ describe('smaller', function() {
 
   it('should LaTeX smaller', function () {
     var expression = math.parse('smaller(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}<{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1<2\\right)');
   });
 
 });
diff --git a/test/function/relational/smallerEq.test.js b/test/function/relational/smallerEq.test.js
index 341bb0717..024350ac1 100644
--- a/test/function/relational/smallerEq.test.js
+++ b/test/function/relational/smallerEq.test.js
@@ -148,7 +148,7 @@ describe('smallerEq', function() {
 
   it('should LaTeX smallerEq', function () {
     var expression = math.parse('smallerEq(1,2)');
-    assert.equal(expression.toTex(), '\\left({1}\\leq{2}\\right)');
+    assert.equal(expression.toTex(), '\\left(1\\leq2\\right)');
   });
 
 });
diff --git a/test/function/relational/unequal.test.js b/test/function/relational/unequal.test.js
index c9eaea5ff..264ef2ece 100644
--- a/test/function/relational/unequal.test.js
+++ b/test/function/relational/unequal.test.js
@@ -169,7 +169,7 @@ describe('unequal', function() {
 
   it('should LaTeX unequal', function () {
     var expression = math.parse('unequal(1,0)');
-    assert.equal(expression.toTex(), '\\left({1}\\neq{0}\\right)');
+    assert.equal(expression.toTex(), '\\left(1\\neq0\\right)');
   });
 
 });
diff --git a/test/function/statistics/max.test.js b/test/function/statistics/max.test.js
index 049ee70e7..a4b9732dc 100644
--- a/test/function/statistics/max.test.js
+++ b/test/function/statistics/max.test.js
@@ -91,7 +91,7 @@ describe('max', function() {
 
   it('should LaTeX max', function () {
     var expression = math.parse('max(1,2,3)');
-    assert.equal(expression.toTex(), '\\max\\left({1},{2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\max\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/statistics/mean.test.js b/test/function/statistics/mean.test.js
index a0c4c480e..80f0ef832 100644
--- a/test/function/statistics/mean.test.js
+++ b/test/function/statistics/mean.test.js
@@ -86,7 +86,7 @@ describe('mean', function() {
 
   it('should LaTeX mean', function () {
     var expression = math.parse('mean(1,2,3,4)');
-    assert.equal(expression.toTex(), '\\mathrm{mean}\\left({1},{2},{3},{4}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{mean}\\left(1,2,3,4\\right)');
   });
 
 });
diff --git a/test/function/statistics/median.test.js b/test/function/statistics/median.test.js
index 24ce48f48..1c25aec2c 100644
--- a/test/function/statistics/median.test.js
+++ b/test/function/statistics/median.test.js
@@ -80,7 +80,7 @@ describe('median', function() {
   
   it('should LaTeX median', function () {
     var expression = math.parse('median(1,2,3,4)');
-    assert.equal(expression.toTex(), '\\mathrm{median}\\left({1},{2},{3},{4}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{median}\\left(1,2,3,4\\right)');
   });
 
 });
diff --git a/test/function/statistics/min.test.js b/test/function/statistics/min.test.js
index bd99df4f4..1f7c49f2a 100644
--- a/test/function/statistics/min.test.js
+++ b/test/function/statistics/min.test.js
@@ -100,7 +100,7 @@ describe('min', function() {
 
   it('should LaTeX min', function () {
     var expression = math.parse('min(1,2,3)');
-    assert.equal(expression.toTex(), '\\min\\left({1},{2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\min\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/statistics/prod.test.js b/test/function/statistics/prod.test.js
index d03d75056..ed630fce4 100644
--- a/test/function/statistics/prod.test.js
+++ b/test/function/statistics/prod.test.js
@@ -63,7 +63,7 @@ describe('prod', function() {
 
   it('should LaTeX prod', function () {
     var expression = math.parse('prod(1,2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{prod}\\left({1},{2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{prod}\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/statistics/std.test.js b/test/function/statistics/std.test.js
index 9e1369aed..1e531a121 100644
--- a/test/function/statistics/std.test.js
+++ b/test/function/statistics/std.test.js
@@ -80,7 +80,7 @@ describe('std', function() {
 
   it('should LaTeX std', function () {
     var expression = math.parse('std(1,2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{std}\\left({1},{2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{std}\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/statistics/sum.test.js b/test/function/statistics/sum.test.js
index ef4a9ea9d..a02cd90c1 100644
--- a/test/function/statistics/sum.test.js
+++ b/test/function/statistics/sum.test.js
@@ -74,7 +74,7 @@ describe('sum', function() {
 
   it('should LaTeX sum', function () {
     var expression = math.parse('sum(1,2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{sum}\\left({1},{2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{sum}\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/statistics/var.test.js b/test/function/statistics/var.test.js
index cd7e2ab18..fe3b4fdcf 100644
--- a/test/function/statistics/var.test.js
+++ b/test/function/statistics/var.test.js
@@ -78,7 +78,7 @@ describe('variance', function() {
 
   it('should LaTeX var', function () {
     var expression = math.parse('var(1,2,3)');
-    assert.equal(expression.toTex(), '\\mathrm{Var}\\left({1},{2},{3}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{Var}\\left(1,2,3\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/acos.test.js b/test/function/trigonometry/acos.test.js
index 63d68c2b7..93baca58b 100644
--- a/test/function/trigonometry/acos.test.js
+++ b/test/function/trigonometry/acos.test.js
@@ -108,7 +108,7 @@ describe('acos', function() {
 
   it('should LaTeX acos', function () {
     var expression = math.parse('acos(1)');
-    assert.equal(expression.toTex(), '\\cos^{-1}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\cos^{-1}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/acosh.test.js b/test/function/trigonometry/acosh.test.js
index 28ddc2d8f..b7aef0f58 100644
--- a/test/function/trigonometry/acosh.test.js
+++ b/test/function/trigonometry/acosh.test.js
@@ -110,7 +110,7 @@ describe('acosh', function() {
 
   it('should LaTeX acosh', function () {
     var expression = math.parse('acosh(1)');
-    assert.equal(expression.toTex(), '\\cosh^{-1}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\cosh^{-1}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/acot.test.js b/test/function/trigonometry/acot.test.js
index b4e19af65..941165beb 100644
--- a/test/function/trigonometry/acot.test.js
+++ b/test/function/trigonometry/acot.test.js
@@ -114,7 +114,7 @@ describe('acot', function() {
 
   it('should LaTeX acot', function () {
     var expression = math.parse('acot(2)');
-    assert.equal(expression.toTex(), '\\cot^{-1}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\cot^{-1}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/acoth.test.js b/test/function/trigonometry/acoth.test.js
index 6a4a90078..aca43babc 100644
--- a/test/function/trigonometry/acoth.test.js
+++ b/test/function/trigonometry/acoth.test.js
@@ -117,7 +117,7 @@ describe('acoth', function() {
 
   it('should LaTeX acoth', function () {
     var expression = math.parse('acoth(2)');
-    assert.equal(expression.toTex(), '\\coth^{-1}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\coth^{-1}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/acsc.test.js b/test/function/trigonometry/acsc.test.js
index b37b370aa..f7249b792 100644
--- a/test/function/trigonometry/acsc.test.js
+++ b/test/function/trigonometry/acsc.test.js
@@ -138,7 +138,7 @@ describe('acsc', function() {
 
   it('should LaTex acsc', function () {
     var expression = math.parse('acsc(2)');
-    assert.equal(expression.toTex(), '\\csc^{-1}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\csc^{-1}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/acsch.test.js b/test/function/trigonometry/acsch.test.js
index 798675ee2..2d6f05a41 100644
--- a/test/function/trigonometry/acsch.test.js
+++ b/test/function/trigonometry/acsch.test.js
@@ -95,7 +95,7 @@ describe('acsch', function() {
 
   it('should LaTeX acsch', function () {
     var expression = math.parse('acsch(2)');
-    assert.equal(expression.toTex(), '\\mathrm{csch}^{-1}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{csch}^{-1}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/asec.test.js b/test/function/trigonometry/asec.test.js
index 00fb218a9..a2165c773 100644
--- a/test/function/trigonometry/asec.test.js
+++ b/test/function/trigonometry/asec.test.js
@@ -120,7 +120,7 @@ describe('asec', function() {
 
   it('should LaTeX asec', function () {
     var expression = math.parse('asec(2)');
-    assert.equal(expression.toTex(), '\\sec^{-1}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\sec^{-1}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/asech.test.js b/test/function/trigonometry/asech.test.js
index a0a7f84b6..31309b8c0 100644
--- a/test/function/trigonometry/asech.test.js
+++ b/test/function/trigonometry/asech.test.js
@@ -114,7 +114,7 @@ describe('asech', function() {
 
   it('should LaTeX asech', function () {
     var expression = math.parse('asech(1)');
-    assert.equal(expression.toTex(), '\\mathrm{sech}^{-1}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{sech}^{-1}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/asin.test.js b/test/function/trigonometry/asin.test.js
index 47e752c14..a0fccb342 100644
--- a/test/function/trigonometry/asin.test.js
+++ b/test/function/trigonometry/asin.test.js
@@ -132,7 +132,7 @@ describe('asin', function() {
 
   it('should LaTeX asin', function () {
     var expression = math.parse('asin(0.5)');
-    assert.equal(expression.toTex(), '\\sin^{-1}\\left({0.5}\\right)');
+    assert.equal(expression.toTex(), '\\sin^{-1}\\left(0.5\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/asinh.test.js b/test/function/trigonometry/asinh.test.js
index 95306fdc9..fdbcc5599 100644
--- a/test/function/trigonometry/asinh.test.js
+++ b/test/function/trigonometry/asinh.test.js
@@ -96,7 +96,7 @@ describe('asinh', function() {
 
   it('should LaTeX asinh', function () {
     var expression = math.parse('asinh(2)');
-    assert.equal(expression.toTex(), '\\sinh^{-1}\\left({2}\\right)');
+    assert.equal(expression.toTex(), '\\sinh^{-1}\\left(2\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/atan.test.js b/test/function/trigonometry/atan.test.js
index bec4a1228..d57c98cc1 100644
--- a/test/function/trigonometry/atan.test.js
+++ b/test/function/trigonometry/atan.test.js
@@ -110,7 +110,7 @@ describe('atan', function() {
 
   it('should LaTeX atan', function () {
     var expression = math.parse('atan(10)');
-    assert.equal(expression.toTex(), '\\tan^{-1}\\left({10}\\right)');
+    assert.equal(expression.toTex(), '\\tan^{-1}\\left(10\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/atan2.test.js b/test/function/trigonometry/atan2.test.js
index 53a0a2489..b5831755a 100644
--- a/test/function/trigonometry/atan2.test.js
+++ b/test/function/trigonometry/atan2.test.js
@@ -105,7 +105,7 @@ describe('atan2', function() {
 
   it('should LaTeX atan2', function () {
     var expression = math.parse('atan2(1,1)');
-    assert.equal(expression.toTex(), '\\mathrm{atan2}\\left({1},{1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{atan2}\\left(1,1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/atanh.test.js b/test/function/trigonometry/atanh.test.js
index 05d5405ab..11c88cb26 100644
--- a/test/function/trigonometry/atanh.test.js
+++ b/test/function/trigonometry/atanh.test.js
@@ -114,7 +114,7 @@ describe('atanh', function() {
 
   it('should LaTeX atanh', function () {
     var expression = math.parse('atanh(0.5)');
-    assert.equal(expression.toTex(), '\\tanh^{-1}\\left({0.5}\\right)');
+    assert.equal(expression.toTex(), '\\tanh^{-1}\\left(0.5\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/cos.test.js b/test/function/trigonometry/cos.test.js
index 536b7afd0..8d21f66f2 100644
--- a/test/function/trigonometry/cos.test.js
+++ b/test/function/trigonometry/cos.test.js
@@ -114,7 +114,7 @@ describe('cos', function() {
 
   it('should LaTeX cos', function () {
     var expression = math.parse('cos(1)');
-    assert.equal(expression.toTex(), '\\cos\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\cos\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/cosh.test.js b/test/function/trigonometry/cosh.test.js
index 40f3404d7..c0e71a385 100644
--- a/test/function/trigonometry/cosh.test.js
+++ b/test/function/trigonometry/cosh.test.js
@@ -88,6 +88,6 @@ describe('cosh', function() {
 
   it('should LaTeX cosh', function () {
     var expression = math.parse('cosh(1)');
-    assert.equal(expression.toTex(), '\\cosh\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\cosh\\left(1\\right)');
   });
 });
diff --git a/test/function/trigonometry/cot.test.js b/test/function/trigonometry/cot.test.js
index 934a63513..2a02d4780 100644
--- a/test/function/trigonometry/cot.test.js
+++ b/test/function/trigonometry/cot.test.js
@@ -106,7 +106,7 @@ describe('cot', function() {
 
   it('should LaTeX cot', function () {
     var expression = math.parse('cot(1)');
-    assert.equal(expression.toTex(), '\\cot\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\cot\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/coth.test.js b/test/function/trigonometry/coth.test.js
index e9b7802c9..2f1878f50 100644
--- a/test/function/trigonometry/coth.test.js
+++ b/test/function/trigonometry/coth.test.js
@@ -76,6 +76,6 @@ describe('coth', function() {
 
   it('should LaTeX coth', function () {
     var expression = math.parse('coth(1)');
-    assert.equal(expression.toTex(), '\\coth\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\coth\\left(1\\right)');
   });
 });
diff --git a/test/function/trigonometry/csc.test.js b/test/function/trigonometry/csc.test.js
index 24b33d0a2..27a9b608e 100644
--- a/test/function/trigonometry/csc.test.js
+++ b/test/function/trigonometry/csc.test.js
@@ -97,7 +97,7 @@ describe('csc', function() {
 
   it('should LaTeX csc', function () {
     var expression = math.parse('csc(1)');
-    assert.equal(expression.toTex(), '\\csc\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\csc\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/csch.test.js b/test/function/trigonometry/csch.test.js
index cd5283b48..d8aee1c66 100644
--- a/test/function/trigonometry/csch.test.js
+++ b/test/function/trigonometry/csch.test.js
@@ -79,6 +79,6 @@ describe('csch', function() {
 
   it('should LaTeX csch', function () {
     var expression = math.parse('csch(1)');
-    assert.equal(expression.toTex(), '\\mathrm{csch}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{csch}\\left(1\\right)');
   });
 });
diff --git a/test/function/trigonometry/sec.test.js b/test/function/trigonometry/sec.test.js
index d533eaa50..1e16ac68b 100644
--- a/test/function/trigonometry/sec.test.js
+++ b/test/function/trigonometry/sec.test.js
@@ -106,7 +106,7 @@ describe('sec', function() {
 
   it('should LaTeX sec', function () {
     var expression = math.parse('sec(1)');
-    assert.equal(expression.toTex(), '\\sec\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\sec\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/sech.test.js b/test/function/trigonometry/sech.test.js
index 4c28263e8..50c59e47f 100644
--- a/test/function/trigonometry/sech.test.js
+++ b/test/function/trigonometry/sech.test.js
@@ -77,6 +77,6 @@ describe('sech', function() {
 
   it('should LaTeX sech', function () {
     var expression = math.parse('sech(1)');
-    assert.equal(expression.toTex(), '\\mathrm{sech}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{sech}\\left(1\\right)');
   });
 });
diff --git a/test/function/trigonometry/sin.test.js b/test/function/trigonometry/sin.test.js
index 44443d5c2..6994285c4 100644
--- a/test/function/trigonometry/sin.test.js
+++ b/test/function/trigonometry/sin.test.js
@@ -109,7 +109,7 @@ describe('sin', function() {
 
   it('should LaTeX sin', function () {
     var expression = math.parse('sin(0.5)');
-    assert.equal(expression.toTex(), '\\sin\\left({0.5}\\right)');
+    assert.equal(expression.toTex(), '\\sin\\left(0.5\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/sinh.test.js b/test/function/trigonometry/sinh.test.js
index f88f9a9b1..b6d5fcb00 100644
--- a/test/function/trigonometry/sinh.test.js
+++ b/test/function/trigonometry/sinh.test.js
@@ -91,6 +91,6 @@ describe('sinh', function() {
 
   it('should LaTeX sinh', function () {
     var expression = math.parse('sinh(1)');
-    assert.equal(expression.toTex(), '\\sinh\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\sinh\\left(1\\right)');
   });
 });
diff --git a/test/function/trigonometry/tan.test.js b/test/function/trigonometry/tan.test.js
index 81ec47d0e..9073b029d 100644
--- a/test/function/trigonometry/tan.test.js
+++ b/test/function/trigonometry/tan.test.js
@@ -100,7 +100,7 @@ describe('tan', function() {
 
   it('should LaTeX tan', function () {
     var expression = math.parse('tan(1)');
-    assert.equal(expression.toTex(), '\\tan\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\tan\\left(1\\right)');
   });
 
 });
diff --git a/test/function/trigonometry/tanh.test.js b/test/function/trigonometry/tanh.test.js
index ad053ab62..9753ed39a 100644
--- a/test/function/trigonometry/tanh.test.js
+++ b/test/function/trigonometry/tanh.test.js
@@ -87,6 +87,6 @@ describe('tanh', function() {
 
   it('should LaTeX tanh', function () {
     var expression = math.parse('tanh(1)');
-    assert.equal(expression.toTex(), '\\tanh\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\tanh\\left(1\\right)');
   });
 });
diff --git a/test/function/units/to.test.js b/test/function/units/to.test.js
index 9bcebf106..99ad2d88f 100644
--- a/test/function/units/to.test.js
+++ b/test/function/units/to.test.js
@@ -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)');
   });
 
 });
diff --git a/test/function/utils/clone.test.js b/test/function/utils/clone.test.js
index 59af563d2..1a604a73a 100644
--- a/test/function/utils/clone.test.js
+++ b/test/function/utils/clone.test.js
@@ -77,7 +77,7 @@ describe('clone', function() {
 
   it('should LaTeX clone', function () {
     var expression = math.parse('clone(1)');
-    assert.equal(expression.toTex(), '\\mathrm{clone}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{clone}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/utils/filter.test.js b/test/function/utils/filter.test.js
index 47d08483d..70339927c 100644
--- a/test/function/utils/filter.test.js
+++ b/test/function/utils/filter.test.js
@@ -48,7 +48,7 @@ describe('filter', function() {
 
   it('should LaTeX filter', function () {
     var expression = math.parse('filter(1,test)');
-    assert.equal(expression.toTex(), '\\mathrm{filter}\\left({1},{\\mathrm{test}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{filter}\\left(1,\\mathrm{test}\\right)');
   });
 
 });
diff --git a/test/function/utils/forEach.test.js b/test/function/utils/forEach.test.js
index d16c3530c..25b1024a1 100644
--- a/test/function/utils/forEach.test.js
+++ b/test/function/utils/forEach.test.js
@@ -47,7 +47,7 @@ describe('forEach', function() {
 
   it('should LaTeX forEach', function () {
     var expression = math.parse('forEach([1,2,3],callback)');
-    assert.equal(expression.toTex(), '\\mathrm{forEach}\\left({\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}},{\\mathrm{callback}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{forEach}\\left(\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix},\\mathrm{callback}\\right)');
   });
 
 });
diff --git a/test/function/utils/format.test.js b/test/function/utils/format.test.js
index 342af3de0..c8c162d85 100644
--- a/test/function/utils/format.test.js
+++ b/test/function/utils/format.test.js
@@ -87,7 +87,7 @@ describe('format', function() {
 
   it('should LaTeX format', function () {
     var expression = math.parse('format(1)');
-    assert.equal(expression.toTex(), '\\mathrm{format}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{format}\\left(1\\right)');
   });
 
 });
diff --git a/test/function/utils/import.test.js b/test/function/utils/import.test.js
index 1cf175276..4a4938723 100644
--- a/test/function/utils/import.test.js
+++ b/test/function/utils/import.test.js
@@ -157,7 +157,7 @@ describe('import', function() {
 
   it('should LaTeX import', function () {
     var expression = math.parse('import(object)');
-    assert.equal(expression.toTex(), '\\mathrm{import}\\left({\\mathrm{object}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{import}\\left(\\mathrm{object}\\right)');
   });
 
 });
diff --git a/test/function/utils/map.test.js b/test/function/utils/map.test.js
index ba95883a2..e0c1d1662 100644
--- a/test/function/utils/map.test.js
+++ b/test/function/utils/map.test.js
@@ -50,7 +50,7 @@ describe('map', function() {
 
   it('should LaTeX map', function () {
     var expression = math.parse('map([1,2,3],callback)');
-    assert.equal(expression.toTex(), '\\mathrm{map}\\left({\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix}},{\\mathrm{callback}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{map}\\left(\\begin{bmatrix}1\\\\2\\\\3\\\\\\end{bmatrix},\\mathrm{callback}\\right)');
   });
 
 });
diff --git a/test/function/utils/print.test.js b/test/function/utils/print.test.js
index 226074c50..768a44339 100644
--- a/test/function/utils/print.test.js
+++ b/test/function/utils/print.test.js
@@ -46,7 +46,7 @@ describe('print', function() {
 
   it('should LaTeX print', function () {
     var expression = math.parse('print(template,values)');
-    assert.equal(expression.toTex(), '\\mathrm{print}\\left({\\mathrm{template}},{\\mathrm{values}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{print}\\left(\\mathrm{template},\\mathrm{values}\\right)');
   });
 
 });
diff --git a/test/function/utils/sort.test.js b/test/function/utils/sort.test.js
index dd360421c..ef2421472 100644
--- a/test/function/utils/sort.test.js
+++ b/test/function/utils/sort.test.js
@@ -50,7 +50,7 @@ describe('sort', function() {
 
   it('should LaTeX sort', function () {
     var expression = math.parse('sort([3,2,1])');
-    assert.equal(expression.toTex(), '\\mathrm{sort}\\left({\\begin{bmatrix}3\\\\2\\\\1\\\\\\end{bmatrix}}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{sort}\\left(\\begin{bmatrix}3\\\\2\\\\1\\\\\\end{bmatrix}\\right)');
   });
 
 });
diff --git a/test/function/utils/typeof.test.js b/test/function/utils/typeof.test.js
index 27b308b2e..4e3d31339 100644
--- a/test/function/utils/typeof.test.js
+++ b/test/function/utils/typeof.test.js
@@ -101,7 +101,7 @@ describe('typeof', function() {
 
   it('should LaTeX typeof', function () {
     var expression = math.parse('typeof(1)');
-    assert.equal(expression.toTex(), '\\mathrm{typeof}\\left({1}\\right)');
+    assert.equal(expression.toTex(), '\\mathrm{typeof}\\left(1\\right)');
   });
 
 });
diff --git a/test/util/latex.test.js b/test/util/latex.test.js
index feddfb61f..1554f5886 100644
--- a/test/util/latex.test.js
+++ b/test/util/latex.test.js
@@ -3,6 +3,10 @@ var assert = require('assert'),
 
 describe('util.latex', function() {
   it('should convert symbols with indices', function () {
-    assert.equal(latex.toSymbol('alpha_1'), '{{\\alpha}}_{\\mathrm{1}}');
+    assert.equal(latex.toSymbol('alpha_1'), '\\alpha_{\\mathrm{1}}');
+  });
+
+  it('should convert units', function () {
+    assert.equal(latex.toSymbol('deg'), '^\\circ');
   });
 });