0
$\begingroup$

Hopefully a simple one...Does anyone know how to preserve "bracket stretching" in a string. For instance, if I copy a formula and use it as a plot label or in any string the brackets revert back to (...) and don't keep the stretched appearance they have when used as an input.

Thanks!

So people can see what I am seeing: So when I input my formula as a Mathematica input to be actually used for calculation and plotting: enter image description here

If I take the same formula in a string, using TraditionalForm[...] enter image description here

As can be seen the parenthesis are not stretched around the formula as they should be.

$\endgroup$
  • 1
    $\begingroup$ Diid you try TraditionalForm? $\endgroup$ – Alexei Boulbitch Jul 8 '16 at 12:02
  • $\begingroup$ @AlexeiBoulbitch Unfortunately this does not work :( $\endgroup$ – QuantumPenguin Jul 8 '16 at 12:49
  • $\begingroup$ What does not work? Please publish your code and, may be, an image of what do you have and what are you after. $\endgroup$ – Alexei Boulbitch Jul 8 '16 at 13:06
  • 1
    $\begingroup$ TraditionalForm does not change a String, remove the quotation marks around the expression within the Print. $\endgroup$ – Bob Hanlon Jul 8 '16 at 14:26
  • 1
    $\begingroup$ Alternatively, convert to TraditionalForm prior to converting to String, i.e., Print[expr // TraditionalForm // ToString] $\endgroup$ – Bob Hanlon Jul 8 '16 at 14:40
1
$\begingroup$

Your code contains numerous syntax errors. The first formula has no sense in Mma. I tried to rewrite its part that seems reasonable:

expr = 10*
Log[10, Re[(1/Subscript[R, p] + 1/(2 \[Nu]*\[Pi]*L*I) + 
    2 \[Pi]*\[Nu]*Subscript[C, p]*I)^-1]] + Subscript[P, 0];

Then you may do the following:

TraditionalForm[expr]

enter image description here

There are also multiple other ways to represent a formula in Mma, and give it the desired form. However, your explanation does not show, what is precisely your need. Anyway, Print is the last way I would use for this purpose.

Have fun!

$\endgroup$
  • $\begingroup$ Thanks, for the input. I don't understand what you mean by syntax errors. The code compiles and behave as it should. If there were syntax errors it would not compile, if you are referring to the double-stamp R and i, then yes these are usually Re[..] and I in mathematica but I changed it for the purposes of being used in a label. Thanks for the help. $\endgroup$ – QuantumPenguin Jul 8 '16 at 15:01
  • $\begingroup$ There are two left square brackets and three right ones. Further, in your expression {P0} and nu have no sense. This I mean by syntax errors. $\endgroup$ – Alexei Boulbitch Jul 11 '16 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.