Message Boards Message Boards

GROUPS:

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

Posted 5 months ago
696 Views
|
6 Replies
|
5 Total Likes
|

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?

6 Replies

This works with double parentheses

fig1

Just remove or move TraditionalForm inside of the parentheses:

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

screenshot

I would do it this way:

wrapInRoundParentheses[expr_] := 
  DisplayForm@RowBox[{"(", expr, ")"}];
wrapInSquareBrackets[expr_] := DisplayForm@RowBox[{"[", expr, "]"}];

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

Attachments:

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

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

screenshot

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

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract