Repository: sympy/sympy

Issue:
latex(re(x)) should use parentheses
latex(re(x)) returns \Re{x}, but it would be better to use \Re{\left(x\right)}. 

I also don't really like \Re (would prefer \mathrm{Re}), but that's a separate issue. 

Discussion:

Patch:
diff --git a/sympy/printing/latex.py b/sympy/printing/latex.py
index b942a31827..e3f418051f 100644
--- a/sympy/printing/latex.py
+++ b/sympy/printing/latex.py
@@ -811,7 +811,7 @@ def _print_Abs(self, expr, exp=None):
     _print_Determinant = _print_Abs
 
     def _print_re(self, expr, exp=None):
-        tex = r"\Re{%s}" % self.parenthesize(expr.args[0], PRECEDENCE['Func'])
+        tex = r"\Re{%s}" % self.parenthesize(expr.args[0], PRECEDENCE['Atom'])
 
         return self._do_exponent(tex, exp)
 


Test patch:
diff --git a/sympy/printing/tests/test_latex.py b/sympy/printing/tests/test_latex.py
index a550ca0a71..e285f86449 100644
--- a/sympy/printing/tests/test_latex.py
+++ b/sympy/printing/tests/test_latex.py
@@ -279,8 +279,8 @@ def test_latex_functions():
     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|{x}\right|"
-    assert latex(re(x)) == r"\Re{x}"
-    assert latex(re(x + y)) == r"\Re{x} + \Re{y}"
+    assert latex(re(x)) == r"\Re{\left(x\right)}"
+    assert latex(re(x + y)) == r"\Re{\left(x\right)} + \Re{\left(y\right)}"
     assert latex(im(x)) == r"\Im{x}"
     assert latex(conjugate(x)) == r"\overline{x}"
     assert latex(gamma(x)) == r"\Gamma{\left(x \right)}"
@@ -299,7 +299,7 @@ def test_latex_functions():
 
     assert latex(cot(x)) == r'\cot{\left (x \right )}'
     assert latex(coth(x)) == r'\coth{\left (x \right )}'
-    assert latex(re(x)) == r'\Re{x}'
+    assert latex(re(x)) == r'\Re{\left(x\right)}'
     assert latex(im(x)) == r'\Im{x}'
     assert latex(root(x, y)) == r'x^{\frac{1}{y}}'
     assert latex(arg(x)) == r'\arg{\left (x \right )}'
@@ -1586,7 +1586,6 @@ def test_issue_10489():
     assert latex(s) == latexSymbolWithBrace
     assert latex(cos(s)) == r'\cos{\left (C_{x_{0}} \right )}'
 
-
 def test_latex_UnevaluatedExpr():
     x = symbols("x")
     he = UnevaluatedExpr(1/x)