Message Boards Message Boards

Make square parenthesis to grow around an arbitrary expression (in output)?

GROUPS:

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?

POSTED BY: Ernesto Espinosa
Answer
2 months ago

This works with double parentheses

fig1

POSTED BY: Alexander Trounev
Answer
2 months ago

Just remove or move TraditionalForm inside of the parentheses:

dExP[expr_] := Style[""[TraditionalForm@expr]];
dExP[x^x^x]

screenshot

POSTED BY: Alexey Popkov
Answer
2 months ago

I would do it this way:

wrapInRoundParentheses[expr_] := 
  DisplayForm@RowBox[{"(", expr, ")"}];
wrapInSquareBrackets[expr_] := DisplayForm@RowBox[{"[", expr, "]"}];
POSTED BY: Gianluca Gorni
Answer
2 months ago

Thank you all,but the parentheses do not grow enough in the case of square brackets.

Attachments:
POSTED BY: Ernesto Espinosa
Answer
2 months ago

According to this answer, you should specify SpanMaxSize -> Infinity styling directive:

wrapInSquareBrackets[expr_] := DisplayForm@StyleBox[RowBox[{"[", expr, "]"}], SpanMaxSize -> Infinity]

screenshot

POSTED BY: Alexey Popkov
Answer
2 months ago

Thank you very much Alexey. All perfect. It's a bit difficult to know everything.

POSTED BY: Ernesto Espinosa
Answer
2 months ago

Group Abstract Group Abstract