# How define boxes to avoid parenthesis

The following definition for boxes in TraditionalForm formats as $$\{a,b\}\{c,d\}$$ (for simplicty, it matches only if the arguments literally are a, b, c, d):

f /: MakeBoxes[f[a, b, c, d], TraditionalForm] :=
RowBox[{RowBox[{"{", "a", "b", "}"}], RowBox[{"{", "c", "d", "}"}]}]:


Here is an example:

f[a, b, c, d] // TraditionalForm


$$\{a,b\}\{c,d\}$$

However, when this object is multiplied by something, I get an unwanted parenthesis:

2*f[a, b, c, d] // TraditionalForm


$$2\,(\{a,b\}\{c,d\})$$

How do I modify the box definition above to avoid the parenthesis?

• maybe ClearAll[f]; f /: MakeBoxes[f[a, b, c, d], TraditionalForm] := RowBox[{"{", "a", "b", "}", "{", "c", "d", "}"}]?  – kglr Dec 31 '19 at 1:52

Use an InterpretationBox, TagBox or TemplateBox with a SyntaxForm option. For example:

MakeBoxes[f[a, b, c, d], TraditionalForm] ^:= InterpretationBox[
RowBox[{RowBox[{"{","a","b","}"}], RowBox[{"{","c","d","}"}]}],
f[a,b,c,d],
SyntaxForm->"^"
]


Then:

2 f[a,b,c,d] //TraditionalForm
`

2 {a b}{c d}