1
$\begingroup$

If would like to print $\left(\frac{b}{a}\right)^2$= (b/a)^2 inside a plot or a graphics where a and b have been seted to certain values so the first part is analytic and the second part (after the =) is computed

$\endgroup$
  • $\begingroup$ something like Graphics[Text[Row[{HoldForm[(a/b)^2], "=", (a/b)^2}]]]? $\endgroup$ – kglr Jun 7 at 16:26
3
$\begingroup$

You can use HoldForm to prevent the "formal part" of the label from being evaluated:

a = 2; b = 3;
Graphics[{Circle[], 
  Text[Style[ToString[HoldForm[(a/b)^2], TraditionalForm] <> " = " <> 
     ToString[(a/b)^2, TraditionalForm], 24], {1/3, 0}]}, 
 PlotLabel -> Style[ToString[HoldForm[(a/b)^2], TraditionalForm] <> " = " <> 
    ToString[(a/b)^2, TraditionalForm], 24]]

enter image description here

You can replace HoldForm with Defer to get the same result.

$\endgroup$

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.