ejeh
(Ernesto Espinosa)
1
This is a subroutine that I use to put round parentheses around an arbitrary expression (in output).
dExP [expr_]: = TraditionalForm @ Style ["" [expr]];
Parentheses grow according to the size of the expression.
Is there something similar for square brackets?
trounev
(Alexander Trounev)
2
This works with double parentheses
lehinp
(Alexey Popkov)
3
Just remove or move TraditionalForm inside of the parentheses:
dExP[expr_] := Style[""[TraditionalForm@expr]];
dExP[x^x^x]
I would do it this way:
wrapInRoundParentheses[expr_] :=
DisplayForm@RowBox[{"(", expr, ")"}];
wrapInSquareBrackets[expr_] := DisplayForm@RowBox[{"[", expr, "]"}];
ejeh
(Ernesto Espinosa)
5
Thank you all,but the parentheses do not grow enough in the case of square brackets.
lehinp
(Alexey Popkov)
6
According to this answer, you should specify SpanMaxSize -> Infinity styling directive:
wrapInSquareBrackets[expr_] := DisplayForm@StyleBox[RowBox[{"[", expr, "]"}], SpanMaxSize -> Infinity]
ejeh
(Ernesto Espinosa)
7
Thank you very much Alexey. All perfect. It’s a bit difficult to know everything.