8

In my investigation of the possibilities offered by the Notation package, I came over a limitation in the complexity of the left hand side symbol. For instance, although I am able to enter

 Notation[
   ParsedBoxWrapper[
     OverBar[SuperStar[af]]]
   \[DoubleLongLeftRightArrow]
   ParsedBoxWrapper["afstarbar"]]

without Mathematica complaining, evaluating afstarbar returns an incorrectly formatted symbol (the whole symbol is replaced by a red error square instead of displaying $\overline{af^*}$). The output is:

 OverBar[SuperStar[$CellContext`af]]

 An unknown box name (OverBar) was sent as the BoxForm for the expression.
 Check the format rules for the expression.

I am unfamiliar with the concept of "boxing", but I tried the following:

Notation[
  ParsedBoxWrapper[
    MakeBoxes[
      OverBar[SuperStar[af]]]]
  \[DoubleLongLeftRightArrow]
  ParsedBoxWrapper["afstarbar"]]

And the display is slightly better, as the $af^*$ is here, but the bar is replaced by the red error square and the output is:

\!\(\*OverscriptBox[
SuperscriptBox[\(af\), \(*\)], 
Notation`Private`singleBlank[]]\)

An unknown box name (Notation`Private`singleBlank) was sent as the BoxForm 
for the expression. Check the format rules for the expression.

Any trick on how to get the symbol to display correctly with the Notation package?

rcollyer
  • 33,976
  • 7
  • 92
  • 191
agravier
  • 609
  • 4
  • 10
  • I don't remember having this problem with OverBar before... is this "bug" a regression or is my memory just faulty? – Simon Jan 18 '12 at 07:49
  • 1
    It could be a Mac-OS specific problem as I have noticed that Notation behaves differently between Mathematica 8.0.0.0 for Windows and for Linux and the same version for Mac. cf. reddit discussion – agravier Jan 18 '12 at 07:54
  • The same problem is happening on my linux box.
    (Btw, thanks for the link to the reddit Mma "group". I didn't know that such a thing existed!)
    – Simon Jan 18 '12 at 07:57

1 Answers1

5

So (I guess that) the problem occurs because
Notation[LHS \[DoubleLongLeftRightArrow] RHS] converts the LHS into boxes,
where OverBar[x] is OverscriptBox[x,"_"].
It then interprets the underscore as a Blank (_), which it tries to match up with a pattern on the RHS.

I'm sure that I've used the Notation package with OverBars before and have not had troubles with it. But then again, maybe not.

Anyway, you can forget about the Notation package for this since you can easily use the underlying box mechanism to implement the notation that you want:

MakeBoxes[afstarbar, form_] := InterpretationBox[
    OverscriptBox[SuperscriptBox["af", "*"], "_"], afstarbar]
Simon
  • 10,167
  • 5
  • 57
  • 72