# How can I use Expand with TeXForm[HoldForm]?

I want to use Expand[(x - 7)^2 + 49]] with TeXForm[HoldForm of the expression Cos[Pi/2 + 5/(Expand[(x - 7)^2 + 49])]. I used

TeXForm[HoldForm[Cos[Pi/2 + 5/(Expand[(x - 7)^2 + 49])]]]


I got

\cos \left(\frac{\pi}{2}+\frac{5}{\text{Expand}\left[(x-7)^2+49\right]}\right)

If I use

TeXForm[Cos[Pi/2 + 5/((x - 7)^2 + 49)]]


I got

-\sin\left(\frac{5}{(x-7)^2+49}\right)

How can I get the result like this $\cos\left (\dfrac{\pi}{2} + \dfrac{5}{98 - 14 x + x^2}\right )$

You could use Inactivate instead of HoldForm to avoid evaluating Cos:
TeXForm[StandardForm[Inactivate[Cos[Pi/2 + 5/(Expand[(x - 7)^2 + 49])], Cos]]]

$$\text{cos}\left(\frac{\pi }{2}+\frac{5}{98-14 x+x^2}\right)$$
Now it is easy to change the brackets to parenthesis if you want, as well as the Cos function.
• Your out put different to which I want. Pi/2+ and +Pi/2. – minhthien_2016 Apr 24 '18 at 9:44