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


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

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


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

  • 1
    $\begingroup$ maybe ClearAll[f]; f /: MakeBoxes[f[a, b, c, d], TraditionalForm] := RowBox[{"{", "a", "b", "}", "{", "c", "d", "}"}]? ` $\endgroup$ – 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","}"}]}],


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

2 {a b}{c d}


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.