Repository: sympy/sympy

Issue:
Use \left \| instead of \lvert in latex(Abs)
See https://groups.google.com/forum/#!topic/sympy/4kVZq27x6T0. It looks like `\lvert` isn't supported by matplotlib. Is there any good reason to use `\lvert` over `\|`?

Discussion:

Patch:
diff --git a/sympy/printing/latex.py b/sympy/printing/latex.py
index e512c9edd7..ffd155c9c6 100644
--- a/sympy/printing/latex.py
+++ b/sympy/printing/latex.py
@@ -89,7 +89,7 @@
     # Brackets
     'norm': lambda s: r'\left\lVert{'+s+r'}\right\rVert',
     'avg': lambda s: r'\left\langle{'+s+r'}\right\rangle',
-    'abs': lambda s: r'\left\lvert{'+s+r'}\right\rvert',
+    'abs': lambda s: r'\left\|{'+s+r'}\right\|',
     'mag': lambda s: r'\left\lvert{'+s+r'}\right\rvert',
 }
 
@@ -753,7 +753,7 @@ def _print_ceiling(self, expr, exp=None):
             return tex
 
     def _print_Abs(self, expr, exp=None):
-        tex = r"\left\lvert{%s}\right\rvert" % self._print(expr.args[0])
+        tex = r"\left\|{%s}\right\|" % self._print(expr.args[0])
 
         if exp is not None:
             return r"%s^{%s}" % (tex, exp)


Test patch:
diff --git a/sympy/printing/tests/test_latex.py b/sympy/printing/tests/test_latex.py
index a3b68b7b40..4ded4f4845 100644
--- a/sympy/printing/tests/test_latex.py
+++ b/sympy/printing/tests/test_latex.py
@@ -232,7 +232,7 @@ def test_latex_functions():
     assert latex(Min(x, y)**2) == r"\min\left(x, y\right)^{2}"
     assert latex(Max(x, 2, x**3)) == r"\max\left(2, x, x^{3}\right)"
     assert latex(Max(x, y)**2) == r"\max\left(x, y\right)^{2}"
-    assert latex(Abs(x)) == r"\left\lvert{x}\right\rvert"
+    assert latex(Abs(x)) == r"\left\|{x}\right\|"
     assert latex(re(x)) == r"\Re{x}"
     assert latex(re(x + y)) == r"\Re{x} + \Re{y}"
     assert latex(im(x)) == r"\Im{x}"
@@ -1178,7 +1178,7 @@ def test_modifiers():
     assert latex(symbols("xDot")) == r"\dot{x}"
     assert latex(symbols("xBar")) == r"\bar{x}"
     assert latex(symbols("xVec")) == r"\vec{x}"
-    assert latex(symbols("xAbs")) == r"\left\lvert{x}\right\rvert"
+    assert latex(symbols("xAbs")) == r"\left\|{x}\right\|"
     assert latex(symbols("xMag")) == r"\left\lvert{x}\right\rvert"
     assert latex(symbols("xPrM")) == r"{x}'"
     assert latex(symbols("xBM")) == r"\boldsymbol{x}"
@@ -1208,7 +1208,7 @@ def test_modifiers():
     assert latex(symbols("xDotVec")) == r"\vec{\dot{x}}"
     assert latex(symbols("xHATNorm")) == r"\left\lVert{\hat{x}}\right\rVert"
     # Check a couple big, ugly combinations
-    assert latex(symbols('xMathringBm_yCheckPRM__zbreveAbs')) == r"\boldsymbol{\mathring{x}}^{\left\lvert{\breve{z}}\right\rvert}_{{\check{y}}'}"
+    assert latex(symbols('xMathringBm_yCheckPRM__zbreveAbs')) == r"\boldsymbol{\mathring{x}}^{\left\|{\breve{z}}\right\|}_{{\check{y}}'}"
     assert latex(symbols('alphadothat_nVECDOT__tTildePrime')) == r"\hat{\dot{\alpha}}^{{\tilde{t}}'}_{\dot{\vec{n}}}"