# How to make a package of notations using the notation package

Alternative question: how to postfixify prefix operators like @, /@, @@

I would like to make a package of notations using the notation package. I want to make postfix notations for common prefix operators.

Edit:

Before addressing the main problem, I will consider a simpler problem that looks like it could work but it does not.

BeginPackage["notations",{"Notation"}]

jj::usage="unusual choice for a postfix version of @ "

Begin["Private"]

NotationAutoLoadNotationPalette = False;

Notation[NotationTemplateTag[o_ jj y_  ] \
[DoubleLongRightArrow] NotationTemplateTag[y_@o_]]

End[]

EndPackage[]


"The external representation NotationTemplateTag[jj\ o_\ y_] does not
have an embedded TemplateBox with tag NotationTemplateTag. The
Notation statement Notation[NotationTemplateTag[jj\ o_\ y_]
[DoubleLongRightArrow]NotationTemplateTag[y_[o_]]] 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"

The actual problem:

The notation choice I took was:

Notation[NotationTemplateTag[o_ /@\ y_  ] \[DoubleLongRightArrow] NotationTemplateTag[Map[y_,o_]]];Notation[NotationTemplateTag[o_ @@\ y_  ] \[DoubleLongRightArrow] NotationTemplateTag[Apply[y_,o_]]];Notation[NotationTemplateTag[o_ @\ y_  ] \[DoubleLongRightArrow] NotationTemplateTag[y_@o_]];


This notation choice adds the extra difficulty that the composite notation /@\ is considered to be a syntax error according to Mathematica but it does work if I use the notation package in a notebook.

the error I get when using @\ instead of jj :

Syntax::sntx: Invalid syntax in or before "Notation[NotationTemplateTag[o_ @\ y_ ] " [DoubleLongRightArrow] NotationTemplateTag[y_@o_]] ^

### What I tried:

failed attempt #1:

BeginPackage["notations",{"Notation"}]

(..notations)

EndPackage[]


failed attempt #2:

BeginPackage["notations",{"Notation"}]

/@\::usage="postfix map"

Begin["Private"]

notations

End[]

EndPackage[]


failed attempt #3:

BeginPackage["notations",{"Notation"}]

Notation::usage="notation"

Begin["Private"]

notations

End[]

EndPackage[]


failed attempt #4:

BeginPackage["notations"]

<< Notation

notations

EndPackage[]


maybe some other combinations of those.

### Seperate questions:

• Is there a way to stop mathematica from highligting custom notation choices like /@\ in purple as if they were syntax errors ?
• I think there is a way for mathematica to define custom notations at startup but I forgot how.
• in the line BeginPackage["notations",{"Notation'"}] do you see the difference between the last characters of the two strings? The first one is correct, the second is not Aug 4 at 16:58
• @JasonB. thank you. I fixed that and checked again and I still can not figure out how to add notations to a package. I will give a simpler example first. Aug 4 at 19:21
• Are you trying to define a notation using the Notation package and then use that notation within your package code? Or do you want to define a notation within your package that can be used by users of your package in a notebook? Based on this comment I don't know if the first one is possible. Aug 4 at 20:12
• @JasonB. I would like the first option. When I load the package with << notations` in a notebook I receive the errors above. Aug 4 at 20:17