Question concerning MakeBoxes

• To: mathgroup at smc.vnet.net
• Subject: [mg60378] Question concerning MakeBoxes
• From: Cca <cca at gregosetroianos.mat.br>
• Date: Wed, 14 Sep 2005 03:27:58 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Let's start a new Mathematica (5.1) session and note that

FormatValues[And]

is the empty list. I want to define a rule for formatting logical
conjunctions and disjunctionsin in such a way that, for example,
the conjunction

p&&q&&r

RowBox[{"\[And]",
RowBox[{StyleBox["{",SpanMaxSize->\[Infinity]],
GridBox[{{"p"},{"q"},{"r"}},ColumnAlignments->{Left}],
StyleBox["}",ShowContents->False]}]," "}]//DisplayForm

(As far as I know, the idea for this interesting and convenient "grid notation" is due to
Bruno BuchBerger, but this is another history.)

For me, one obvious solution to this problem should be something like

Unprotect[And];
RowBox[{"\[And]",
RowBox[{StyleBox["{",SpanMaxSize->\[Infinity]],
ColumnAlignments->{Left}],
StyleBox["}",ShowContents->False]}]," "}];
Protect[And];

In fact,

is now displayed as intended. However, it works only once: evaluating again

gives the built-in traditional formatting. After inspecting

FormatValues[And]

we see what is going on: my formatting rule is the LAST on the list. So, in order to
force Mathematica to apply my definition first, I evaluate

Unprotect[And];
FormatValues[And]=Reverse@FormatValues[And];
Protect[And];

This solves my problem, but in a somewhat inelegant way.

My questions are:

(1) what is the explanation for this behavior?
(2) how can I get the intended result without reversing FormatValues[And]?

My anticipated thanks for any help.

Carlos César de Araújo
Gregos & Troianos Educacional
www.gregosetroianos.mat.br
Belo Horizonte, MG, Brazil
(31) 3283-1122

```

• Prev by Date: Re: Forums opened on Mathematica-users.org
• Next by Date: Batch
• Previous by thread: Re: Proposal to get Stephen to Improve the lot ofSpace Shuttle Programmers
• Next by thread: Re: Question concerning MakeBoxes