This is similar to my previous question Can one prevent operators like `Factor` or `Apart` from changing full form of some algebraic expressions? but concerns $\TeX$ and I cannot figure out whether I might use the solution found there in this case. I found several questions here about $\LaTeX$ conversion, one of them (Override Equation structure change in mathematica - CopyToLaTeX) addressing this particular issue, but the only relevant answer (using HoldForm) does not work in my case (see below).
When I export expressions to $\TeX$, some undesirable (for me) form changes occur. A minimal example is e. g. (1+q+q^2)(1-4 q) which goes to $(1-4q)(q^2+q+1)$. This happens both while right-clicking and choosing "Copy as" -> "LaTeX" or issuing 1-q+q^2//TeXForm.
Doing TeXForm[StandardForm[(1+q+q^2)(1-4 q)]] helps only partially, it gives $(1-4q)(1+q+q^2)$, i. e. still interchanges the factors which I don't want to do.
In this particular case, TeXForm[HoldForm[(1+q+q^2)(1-4 q)]] helps, but I sometimes need to export really huge expressions where HoldForm does not work the way I want. For example, if I would have Sum[q^n,{n,0,2}](1-4q) instead (and I frequently have large expressions like that) then TeXForm[HoldForm[Sum[q^n,{n,0,2}](1-4q)]] gives $\left(\sum _{i=0}^2 q^i\right) (1-4 q)$ (while TeXForm[StandardForm[Sum[q^n,{n,0,2}](1-4q)]] still interchanges factors giving $(1-4 q) \left(1+q+q^2\right)$).
Clearly it is very annoying to have to change everything back into form I need by hand, especially with large expressions. Is there a way to tell the system to convert just the expression the way it is seen, without changing anything?
TeXForm@DisplayForm@HoldForm[(1 + q + q^2) (1 - 4 q)]work? – march Mar 14 '16 at 16:34HoldFormnot work exactly? I can't figure it out from your post. Do you mean that you want the summation expanded but the factors not reordered? – march Mar 14 '16 at 16:36HoldForm. But issuingTeXForm[HoldForm[%]]just gives\%. Assigning some new symbol also does not work - if I say firste=%and thenTeXForm[HoldForm[e]]this just givese. – მამუკა ჯიბლაძე Mar 14 '16 at 18:19HoldFormjust to prevent additional reordering done byTeXForm, then you can useEvaluate:% // Evaluate // HoldForm // TeXForm. If you want partial evaluation like in your example withSum, then maybe making some operationsInactivecombined withactiveFormwould work for you:Inactive[Times][Sum[q^n, {n, 0, 2}], (1 - 4 q)] // activeForm // TeXForm, it can be combined withEvaluate // HoldFormif needed. – jkuczm Mar 16 '16 at 22:17TeXForm, most likely I don't know all of them. By exactly as in the output you mean "really exactly", for example if you haveSin[x]you want result with capital "S" and square bracket, instead of "\sin (x)"? – jkuczm Mar 17 '16 at 10:05