I am trying to use the Notation package to define custom notation for chemical reactions. The natural thing to do is to use a


for the operator. In particular, I would like to have the reactants grouped before the arrow, the products grouped after the arrow, and a rate constant over the arrow using Ctrl-7. But when I try to implement this with the Notations Package, I run into several problems. First, trying it as a binary operator without the rate constant over the arrow, the precedence of the arrow is too high, so it shifts products around to the reactants side. I have tried copying in example code from the Complex Patters and Advanced Features source (specifically the Changing Precedences and the TagBox Option SyntaxForm section -- copying the code directly and attempting to modify with the LongArrow fails), setting the SyntaxForm option within a TagBox to something with a very low precedence, like "," or "==", but this doesn't change the output at all.

Example code:

Notation[ParsedBoxWrapper[RowBox[{"a_", "\[LongRightArrow]", "b_"}]] 
ParsedBoxWrapper[RowBox[{"Reaction", "[", RowBox[{"a_", ",", "b_"}], "]"}]]]

When used with the following example reaction:

2 C60s\[LongRightArrow]C60s + C60


C60 + 2 C60s\[LongRightArrow]C60s

Changing the notation with a TagBox like so:

TagBox["\[LongRightArrow]", Identity, SyntaxForm -> ","], "b_"}]]
\[DoubleLongLeftRightArrow]ParsedBoxWrapper[RowBox[{"LongRightArrow", "[", 
RowBox[{"a_", ",", "b_"}], "]"}]]]

Has no effect on my output from the example above. I have also tried using the Full Notation Palette with the Wrapper Boxes to no avail following advice in a StackExchange thread.

And this doesn't begin to address the issue of trying to get a third operand over the arrow.

Any help appreciated!

Edited to add: To get this to work seamlessly, we need the Notation line to include an extra " " between the "a_" and the TagBox.


You need to add an input alias for the TagBox version of the long right arrow:

AddInputAlias["rxn" -> ParsedBoxWrapper[TagBox["\[LongRightArrow]", Identity, SyntaxForm->","]]]

Then, you need to use the "rxn" alias to enter the long right arrow, and things should work as expected.

| improve this answer | |
  • $\begingroup$ Thank you, that worked! I don't see a way to do this through the Palettes, which is a shame, but I am thrilled to have a way that works. $\endgroup$ – Kevin Ausman Apr 3 '19 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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