2 Remove redundant information after refactoring OP edited May 30 at 14:57 Carl Woll 90.5k33 gold badges119119 silver badges231231 bronze badges I like using Composition (@*) for this kind of thing. Your expression: expr=(x \[LeftAngleBracket]x (-x + \!$$\*UnderscriptBox[\(\[Sum]$$, $$j$$]\)Derivative[1][v][ y[j]])\[RightAngleBracket])/\[LeftAngleBracket]x^2\ \[RightAngleBracket] + \!$$\*UnderscriptBox[\(\[Sum]$$, $$j$$]\)Derivative[1][v][y[j]]; expr //TeXForm  $$\frac{x \left\langle x \left(\sum _j v'(y(j))-x\right)\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$ Using Composition: exprterm /. AngleBracket -> AngleBracket @* Expand //TeXForm  $$\frac{x \left\langle x \sum _j v'(y(j))-x^2\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$ I like using Composition (@*) for this kind of thing. Your expression: expr=(x \[LeftAngleBracket]x (-x + \!$$\*UnderscriptBox[\(\[Sum]$$, $$j$$]\)Derivative[1][v][ y[j]])\[RightAngleBracket])/\[LeftAngleBracket]x^2\ \[RightAngleBracket] + \!$$\*UnderscriptBox[\(\[Sum]$$, $$j$$]\)Derivative[1][v][y[j]]; expr //TeXForm  $$\frac{x \left\langle x \left(\sum _j v'(y(j))-x\right)\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$ Using Composition: expr /. AngleBracket -> AngleBracket @* Expand //TeXForm  $$\frac{x \left\langle x \sum _j v'(y(j))-x^2\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$ I like using Composition (@*) for this kind of thing: term /. AngleBracket -> AngleBracket @* Expand //TeXForm  $$\frac{x \left\langle x \sum _j v'(y(j))-x^2\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$ 1 answered May 30 at 14:40 Carl Woll 90.5k33 gold badges119119 silver badges231231 bronze badges I like using Composition (@*) for this kind of thing. Your expression: expr=(x \[LeftAngleBracket]x (-x + \!$$\*UnderscriptBox[\(\[Sum]$$, $$j$$]\)Derivative[1][v][ y[j]])\[RightAngleBracket])/\[LeftAngleBracket]x^2\ \[RightAngleBracket] + \!$$\*UnderscriptBox[\(\[Sum]$$, $$j$$]\)Derivative[1][v][y[j]]; expr //TeXForm  $$\frac{x \left\langle x \left(\sum _j v'(y(j))-x\right)\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$ Using Composition: expr /. AngleBracket -> AngleBracket @* Expand //TeXForm  $$\frac{x \left\langle x \sum _j v'(y(j))-x^2\right\rangle }{\left\langle x^2\right\rangle }+\sum _j v'(y(j))$$