0
$\begingroup$

I have an equation with random integer coefficients. The structure is to demonstrate the distributive property.

{a, b, c, d} = RandomInteger[{1, 9}, 4];
Row[{TraditionalForm[a f[x] (b g[x] + c h[x])], " = ",TraditionalForm[Expand[a f[x] (b g[x] + c h[x])]]}]

I would like the parentheses surrounding the sum on the LHS to be slightly bigger to give is a more professional appearance. I've tried getting the inline Tex to work and I did find a discussion about using nudge right to do it. Is there a straightforward way to control the size of parentheses?

$\endgroup$
2
  • $\begingroup$ If you want it to use in the document to give away or in a demonstration, the most simple way is to select one of the parentheses in question, go to Menu/Format/Size, and select, say, 16. Then do the same with the second one. If you want it to work in a usual working file where you make your calculation, I think the task is too complex and will not pay off. $\endgroup$ Commented Oct 27, 2022 at 18:53
  • $\begingroup$ The title is a bit ambiguous, for future users looking for a similar question, a possible modification could be "How to change the size/style of parentheses" $\endgroup$ Commented Oct 28, 2022 at 0:40

2 Answers 2

2
$\begingroup$

First off a side comment. I think you'll get something more professional right off the bat by avoiding the row and just putting the whole expression/equation inside TraditionalForm (note the ==, but TraditionalForm will display it as a single equation symbol):

TraditionalForm[a f[x] (b g[x] + c h[x]) == Expand[a f[x] (b g[x] + c h[x])]]

Second, I don't think these particular forms allow control of the various box options/behavior explicitly. However, you can force things to happen by adding semantically irrelevant things. So, for example, you could add an invisible space that was styled to be slightly larger than the nearby text:

TraditionalForm[a f[x] (Style["\[InvisibleSpace]", 24] b g[x] + c h[x]) == Expand[a f[x] (b g[x] + c h[x])]]

The trick would be to figure out how to do this programmatically. How many of these will you need to do? Maybe you want to build your own Parenthesize[...] function that adds such things recursively for nested Parenthesize expressions.

$\endgroup$
7
  • $\begingroup$ That is an awesome trick using the invisibility of "*" and creating an invisible tower of nothing to force the bracket to be larger $\endgroup$ Commented Oct 27, 2022 at 22:14
  • $\begingroup$ It seem like one does not have to multiply both terms by Style["\[InvisibleSpace]", 24], it suffices to multiply one term. In that case one can use a replacement rule to make the substitution automatically for a particular structure. For example: p + a f[x] (b g[x] + c h[x] + b*r[x]) /. c_*(j_ + t_) :> c*(Style["", 24]*j + t) $\endgroup$ Commented Oct 27, 2022 at 22:29
  • $\begingroup$ Yes, you only need one "tall" thing. I was playing around with where it would be most convenient, and apparently didn't clean up the other one. $\endgroup$ Commented Oct 27, 2022 at 22:31
  • 1
    $\begingroup$ And "as for this particular structure", yeah, we need to know how many cases the OP needs to handle. $\endgroup$ Commented Oct 27, 2022 at 22:33
  • $\begingroup$ I am having trouble imagining a case where my last update to the replacement rule would not work. $\endgroup$ Commented Oct 27, 2022 at 22:35
2
$\begingroup$

A solution using Mathematica Boxes :

Note: One can copy expressions as LaTex in a Mathematica notebook but that does not seem to work with the method below.

Testing on a generic expression (my notebook already uses a large font so maybe the image below might look different on your notebook ):

p + a f[x]*(r + n) (b g[x] + c h[x] + b*r[x])^2*(k + d) // ToBoxes // 
ReplaceAll[{"(" -> Style["(", 30], ")" -> Style[")", 30]}] // 
DisplayForm // TraditionalForm

expression_big_parenthesis

Making a function BIGparenthesis:

BIGparenthesis[size_][s_] := 
s // ToBoxes // 
ReplaceAll[{"(" -> Style["(", size], ")" -> Style[")", size]}] //
DisplayForm // TraditionalForm;

Using it for OP's case :

{a, b, c, d} = RandomInteger[{1, 9}, 4]; 
BIGparenthesis[30][a f[x] (b g[x] + c h[x])] == 
BIGparenthesis[30][
Expand[a f[x] (b g[x] + c h[x])]] // TraditionalForm

OP_example

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.