TransWikia.com

How to visually present a variable of more than two letters as if it were one.How should I proceed?

Mathematica Asked by BeTDa on February 17, 2021

I can’t find a clear way to express my question but they say that a picture is worth a thousand words.
Attached is an image of the desired result

Example

2 Answers

You could modify the formatting rules for the variables:

xy /: MakeBoxes[xy, StandardForm] := TagBox["xy", #&, SyntaxForm->"*"]
Δx /: MakeBoxes[Δx, StandardForm] := TagBox["Δx", #&, SyntaxForm->"*"]

Then:

Expand[(2x+Δx)^2]
Expand[(2xy+Δx)^2]
Solve[Δx+2 a x==(a+Δx)^2,x]

enter image description here

If you really want parentheses with plus as well, use SyntaxForm->"+" instead of SyntaxForm->"*".

Answered by Carl Woll on February 17, 2021

xy /: MakeBoxes[xy, _] := RowBox[{"(", "xy", ")"}]
Δx /: MakeBoxes[Δx, _] := RowBox[{"(", "Δx", ")"}]
Expand[(2 x + Δx)^2]
Expand[(2 xy + Δx)^2]
Solve[Δx + 2 a x == (a + Δx)^2, x]

enter image description here

Answered by Rolf Mertig on February 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP