Message Boards Message Boards

1
|
7403 Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

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

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
6 Replies

This works with double parentheses

fig1

Posted 6 years ago

Just remove or move TraditionalForm inside of the parentheses:

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

screenshot

POSTED BY: Alexey Popkov

I would do it this way:

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

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

Attachments:
POSTED BY: Ernesto Espinosa
Posted 6 years 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

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

POSTED BY: Ernesto Espinosa
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