# How to replace terms without rearranging

I have a long expression which I'd like to export to Latex, so I'm using the copy as latex function. However, in my Latex document I'm using different notation, so I'd like to use the replace rule to change to formatting of my expressions before copying them across.

This sounds fine - however, I'm using a package, 'Quantum', which is for non-commutative algebras, and the ordering of items is very specific and important. I'm finding that when I use my replacement rule, things get reordered and the output expression is no longer correct.

So here's my question: How can I use a replacement rule, whilst making sure that the ordering of the expression remains exactly the same?

Hold[expr]/.Rules nearly does it. The only thing is that one of the rules is $$\beta i\to\beta^{-1}$$, and this then comes out as $$\frac{1}{\beta}$$, even with Hold.
• Try replacing \[Beta]i with Superscript[\[Beta], -1] – b3m2a1 Mar 11 '20 at 8:20
• Try this: βi /. βi -> "\!$$\*SuperscriptBox[\(β$$, $$-1$$]\)" That is, to put it as a string. – Alexei Boulbitch Mar 11 '20 at 9:04