1.How to make following equation have sense?
{+,-}::Symbol. ex:=f_{-}+f_{+};
2.How to make all commutators
[a b... , c d...] or \commutaor{a b... }{ c d...]
become
a b... c d... - c d... a b...
Use fm and fp and define
fm
fp
fm{#}::LaTeXForm("{f_{-}}"). fp{#}::LaTeXForm("{f_{+}}").
To expand, use
substitute(_, $\commutator{A??}{B??} -> A?? B?? - B?? A??$);
Does that help?
Yes, it does. I'm so sorry that I have not give more details about problems. In fact, I want make following equation have sense:
ex:=f_{-\mu\nu}+f_{+\mu\nu}+f_{+}^{\mu\nu};
So write that with the above as
ex:= fm_{\mu\nu} + fp_{\mu\nu} + fp^{\mu\nu};
(and declare your indices with position=free to allow you to have expressions where the index positions do not match up. So in full,
position=free
fm{#}::LaTeXForm("{f_{-}}"). fp{#}::LaTeXForm("{f_{+}}"). {\mu,\nu}::Indices(position=free); ex:= fm_{\mu\nu} + fp_{\mu\nu} + fp^{\mu\nu};
to give
f−μν+f+μν+f+μν
Thanks a lot. It is what I want.