# Correct way to use Notation

I have tried to create some Notation declarations as follows

<< Notation
Notation[Subscript[x_, i_] \[DoubleLongLeftRightArrow] x[i]]
Notation[OverBar[x_] \[DoubleLongLeftRightArrow] mean[x]]


Mathematica9 throws the following errors for the declarations

Notation::noexbtag: The external representation Subscript[x_, y_] does not have an embedded TemplateBox with tag NotationTemplateTag. The Notation statement Notation[Subscript[x_, y_][DoubleLongLeftRightArrow]x[y]] may not have been entered using the palette, or the embedded TemplateBox may have been deleted. The embedded TemplateBox ensures correct parsing and retention of proper styling and grouping information. >>

and

Notation::noexbtag: The external representation Overscript[x_, ] does not have an embedded TemplateBox with tag NotationTemplateTag. The Notation statement Notation[Overscript[x, _][DoubleLongLeftRightArrow]mean[x]] may not have been entered using the palette, or the embedded TemplateBox may have been deleted. The embedded TemplateBox ensures correct parsing and retention of proper styling and grouping information. >>

respectively.

It is not really clear to me what is going on. I read the documentation for TemplateBox and looked up NotationTemplateTag which seems to have been replaced by ParsedBoxWrapper. After following some related function I thought the following might be what is required:

Notation[ToBoxes[Subscript[x_, y_]]\[DoubleLongLeftRightArrow] x[y]]
Notation[ToBoxes[OverBar[x_]] \[DoubleLongLeftRightArrow] mean[x]]


or perhaps

Notation[MakeBoxes[Subscript[x_, y_]]\[DoubleLongLeftRightArrow] x[y]]
Notation[MakeBoxes[OverBar[x_]] \[DoubleLongLeftRightArrow] mean[x]]


but both of those throw errors as well. So what is the right way to declare these notations? I am aware that setting up subscripts as a notation for function application is not something you would want to do in practice, but I am just experimenting.

Also do I actually need to import the Notation package or Notation buit-in with Mathematica9?

-
Works for me. Are you using the palette to enter the notation (you must IIRC)? Also, pattern s/b on both sides. – ciao Mar 30 '14 at 21:58
If you've not already, take a look at the section Entering Notations (toward the bottom). Use of ParsedBoxWrapper is covered there for using Notation constructs without the palette. – ciao Mar 31 '14 at 1:00

Notation[OverBar[x_] \[DoubleLongRightArrow] Mean[x_]]

Ok, that did work for me once I used the palette. One difference with what I tried before is that the second x in the Notation is also followed by an underscore in your code. What is the logic behind that? – Daniel Mahler Mar 31 '14 at 1:10
@DanielMahler: Covered in the doc. section I linked in the comment above - I'm not a Notation` expert by any means, but I'm pretty certain an error is thrown if patterns used are not on both sides. Perhaps one of the resident experts will illuminate this, or the referred docs. might clarify. – ciao Mar 31 '14 at 1:18