Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.3K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

StringForm changes the way i want my output

I want to display (output) my expressions as I write them .

However StringForm somehow changes internally. (in this example, commutes the adition)

Outside StringForm everything works OK.

How do I prevent this?

Thanks

Attachments:
POSTED BY: Ernesto Espinosa
4 Replies

It looks like a bug in StringForm. Both TraditionalForm[HoldForm[-b + a]] and

StringForm["`1`", HoldForm[-b + a]]

give -b+a, while

StringForm["`1`", TraditionalForm[HoldForm[-b + a]]]

gives a-b. You may try with ToString instead of StringForm.

POSTED BY: Gianluca Gorni

Gianluca:

A simple change in the definition of my function fixed all, thanks to your suggestion

displayExpr[expr_] := Style[Format[HoldForm[expr], TraditionalForm]]; (Old)

displayExpr[expr_] := Style[ToString[HoldForm[expr], TraditionalForm]]; (New)

I don’t know why.

Best regards

POSTED BY: Ernesto Espinosa
POSTED BY: S M Blinder

But what about the Style, format of the output?

Thanks for the support

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