Define arithmetic operations with the 'operation' keyword
masterIf your custom type represents a specific arithmetic operation (like subtraction or multiplication), you can use the operation keyword within an @latexrecipe to inform latexify of its nature. This allows latexify to apply correct mathematical parenthesis rules when the type is used within larger expressions.
To do this, use the := operator to ensure the operation is fixed:
operation := :<operator> (where <operator> is a symbol like :-, :+, etc.).
Example:
If you have a type MyDifference representing x - y, defining the recipe with operation := :- ensures that @latexify $(MyDifference(2,3))*4 results in \left( 3 - 2 \right) \cdot 4 instead of the incorrect 3 - 2 \cdot 4.
struct MyDifference
x
y
end
@latexrecipe function f(m::MyDifference)
operation := :-
return :($(m.y) - $(m.x))
end