[Date Index]
[Thread Index]
[Author Index]
Re: Question concerning MakeBoxes
*To*: mathgroup at smc.vnet.net
*Subject*: [mg60390] Re: [mg60378] Question concerning MakeBoxes
*From*: "David Park" <djmp at earthlink.net>
*Date*: Thu, 15 Sep 2005 05:16:12 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
Carlos,
First, on Version 5.2 I have no problem with repeated evaluation. The
TraditionalForm output always uses the new formatting.
Second, by using the following definition, it is possible to copy and paste
the output.
Unprotect[And];
And /: MakeBoxes[And[c__], TraditionalForm] :=
(InterpretationBox[#1, #2] &) @@ {RowBox[{"\[And]",
RowBox[{StyleBox["{", SpanMaxSize -> \[Infinity]],
GridBox[({#1} &) /@ (MakeBoxes[#1, TraditionalForm] &) /@ {c},
ColumnAlignments -> {Left}],
StyleBox["}", ShowContents -> False]}], " "}], And[c]};
Protect[And];
Using the pure function form of InterpretationBox allows the arguments to be
evaluated.
Last, when I used the above on Version 5.0.1 and on 5.1.1 I again had no
trouble with repeated evaluation so I wonder if there is some setting on
your system that has gotten changed.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Cca [mailto:cca at gregosetroianos.mat.br]
To: mathgroup at smc.vnet.net
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
is formatted in TraditionalForm as
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];
And/:MakeBoxes[And[c__],TraditionalForm]:=
RowBox[{"\[And]",
RowBox[{StyleBox["{",SpanMaxSize->\[Infinity]],
GridBox[{#}&/@(MakeBoxes[#,TraditionalForm]&/@{c}),
ColumnAlignments->{Left}],
StyleBox["}",ShowContents->False]}]," "}];
Protect[And];
In fact,
p&&q&&r//TraditionalForm
is now displayed as intended. However, it works only once: evaluating again
p&&q&&r//TraditionalForm
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: Re: Proposal to get Stephen to Improve the lot ofSpace Shuttle Programmers**
Next by Date:
**Re: Re: Timed Notebooks for Student Take-home examinations**
Previous by thread:
**Question concerning MakeBoxes**
Next by thread:
**Re: Question concerning MakeBoxes**
| |