Let's consider a slightly complicated expression in TraditionalForm:

Reduce[#, Backsubstitution -> True] & /@ 
    x^2 + y^2 <= 1 && y <= x, {x, y}] // TraditionalForm

$(y=0\land x=1)\lor \left(y=-\frac{1}{\sqrt{2}}\land x=-\frac{1}{\sqrt{2}}\right)\lor \left(-\frac{1}{\sqrt{2}}<x\leq \frac{1}{\sqrt{2}}\land -\sqrt{1-x^2}\leq y\leq x\right)\lor \left(\frac{1}{\sqrt{2}}<x<1\land -\sqrt{1-x^2}\leq y\leq \sqrt{1-x^2}\right)$

My question is: How do I split this result for improved readability so that each subexpression of this disjunctive normal form expression is on its own line, and $\lor$ ends the line?


1 Answer 1

exp = Reduce[#, Backsubstitution -> True] & /@ 
   BooleanMinimize@ CylindricalDecomposition[x^2 + y^2 <= 1 && y <= x, {x, y}];

ToBoxes[TraditionalForm @ exp] /. "\[Or]" -> "\[Or]\n" // RawBoxes

enter image description here

Or, wrap with TraditionalForm:

ToBoxes[TraditionalForm@exp] /. "\[Or]" -> "\[Or]\n" // RawBoxes // TraditionalForm 

enter image description here

Original size of $\lor$s can be retained by replacing them with a separate $\lor$ and a newline:

ToBoxes[TraditionalForm@exp] /.
  "\[Or]" -> Sequence["\[Or]", "\n"] // RawBoxes // TraditionalForm

enter image description here

  • $\begingroup$ Even better if you add // TraditionalForm in the end. Size of $\lor$s seems to change, though. That would be fixed with "\[Or]" -> Sequence["\[Or]", "\n"] $\endgroup$
    – kirma
    Commented May 12, 2015 at 16:31
  • $\begingroup$ @kirma, updated with the suggested change. $\endgroup$
    – kglr
    Commented May 12, 2015 at 16: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.