6
$\begingroup$

It's easy to read the steps from Rubi, but kind of tired to copy it out of as $\LaTeX$. That's what now I do:

Int[x Sin[x], x]//Steps

For example,click one step, then paste it to .nb, then //TeXForm to get the TeX code. (kind of monkey job)

I've tried FullForm, get nothing, // Trace gives back a lot of things, which seems a bit hard for me to pick out what I want. So I want a "automatical" way to do this.

$\endgroup$
3
  • $\begingroup$ Hi. I found small problem trying to add your function to my report. Since all integrals I use come from lists, and you have SetAttributes[IntWithStepsOfTeXForm, {HoldFirst}]; then when I pass the integral to your function, it does not work. Here is an example. lst = {{Log[1 + x], x}}; result = IntWithStepsOfTeXForm[ Int[lst[[1, 1]], lst[[1, 2]]] ] ; And now the result does not work. Screen shot !Mathematica graphics $\endgroup$
    – Nasser
    May 9, 2020 at 23:46
  • $\begingroup$ fyi, I posted separate question on this here mathematica.stackexchange.com/questions/221547/… I could not find solution myself. $\endgroup$
    – Nasser
    May 10, 2020 at 1:41
  • $\begingroup$ @Nasser IntWithStepsOfTeXForm[Int[#, x]] & /@ {Sin[x], Cos[x]/x^2, Sin[x]/x^2} // MaTeX can work. $\endgroup$ May 10, 2020 at 4:05

1 Answer 1

7
$\begingroup$

A better version is here:

https://mathematica.stackexchange.com/a/221559/68689


I found this option:

RubiPrintInformation -> False

And then write this:

SetAttributes[IntWithStepsOfTeXForm, {HoldFirst}];
IntWithStepsOfTeXForm[j_] := 
 With[{TeX2Str = Convert`TeX`ExpressionToTeX},
  Steps[j, RubiPrintInformation -> False] //
         Flatten //
        Most //
       Select[Head@# =!= RubiRule &] //
      # /. RubiIntermediateResult[x_] -> x & //
     (*ToString@*TeXForm is OK*)
     Map["=&" <> (TeX2Str[HoldForm @@ #]) <> "\\\\" &] //
    # /. {a___} -> {
        "\\begin{aligned}",
        TeX2Str@HoldForm@j,
        a,
        "\\end{aligned}"} & // StringRiffle
  ]

This function returns a string.

Usage:

Or use Print and then copy the result to clipboard for following use.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.