Recently I have been annoyed by an automatic formatting in MMA, that is when a Piecewise function occurs in an equation, it will be enclosed by a pair of brackets automatically by MMA, although when it emerges solitarily, there are no such pair of brackets.

For example, suppose I have a Piesewise function Piecewise[{{x^2, x < 0}, {x, x > 0}}]. When it is output alone, it is like:

enter image description here

However, when I put this Piesewise function at the Right-Hand-Side of an equation, an annoying pair of brackets occurs:

enter image description here

Generally speaking, placing a Piesewise function at the end of an equation is to discuss all possible results in different cases, where the automatically added pair of brackets is unnecessary and redundant. So I was wondering, how can I remove such kind of brackets both in Standard Form output as well as Traditional Form output?

(The reason why I would like to also remove the brackets in Traditional Form output is that: Traditional Form output is the starting point of latex code conversion. If Traditional Formoutput has such a pair of brackets, then there would also be one in the TeXForm or the latex code MMA generates.)


1 Answer 1


If you don't mind modifying some internal symbols, you can do:

BoxForm`$PiecewiseSyntaxForm = SyntaxForm -> DirectedEdge;

Then, the parentheses should be gone.

  • $\begingroup$ Thanks Carl, your solution works perfectly as I have tested! And it is really impressive, since I had tried to define my own box-making functions with MakeBoxes[] or Format[] as upper values of Piecewise, but neither succeeded. Without your suggestion, I would have never thought of modifying some internal symbols. Thanks for your creative and elegant solution! $\endgroup$
    – AlbertLew
    Jun 5, 2022 at 4:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.