8
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ I don't remember having this problem with OverBar before... is this "bug" a regression or is my memory just faulty? $\endgroup$
    – Simon
    Jan 18, 2012 at 7:49
  • 1
    $\begingroup$ 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 $\endgroup$
    – agravier
    Jan 18, 2012 at 7:54
  • $\begingroup$ 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!) $\endgroup$
    – Simon
    Jan 18, 2012 at 7:57

1 Answer 1

5
$\begingroup$

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]
$\endgroup$
4
  • $\begingroup$ Thank you, I will try that out in a few hours when I have access to Mathematica. I will also document myself about the boxes mechanism to better understand what is going on. $\endgroup$
    – agravier
    Jan 18, 2012 at 8:04
  • $\begingroup$ What's with the form parameter? $\endgroup$ Jan 18, 2012 at 16:32
  • $\begingroup$ @Sjoerd: You can have different MakeBoxes for StandardForm and TraditionalForm (etc). I didn't use the parameter but named it just so I can remember what it is for. $\endgroup$
    – Simon
    Jan 18, 2012 at 20:59
  • $\begingroup$ @Simon, I confirm that your solution works, thank you! $\endgroup$
    – agravier
    Jan 19, 2012 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.