-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to directly get the TeXForm of every step? #34
Comments
After some test, this is a half-done job: Steps[Int[Sin[x]/x^2, x], RubiPrintInformation -> False] //
Flatten //
Most //
Select[Head@# =!= RubiRule &] //
# /. RubiIntermediateResult[x_] -> x & //
(*ToString@*TeXForm is also OK*)
Map["=&" <> (Convert`TeX`ExpressionToTeX[HoldForm @@ #]) <>
"\\\\" &] //
StringRiffle |
OK, I've done it.(I don't deal with the situations that Rubi failed to calculate the int) This function returns a string. 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
] Usage: Or IntWithStepsOfTeXForm[Int[(x + 1)/Sqrt[x^2 + 1], x]] // Print And then choose and copy to clipboard. Maybe I will make a pr for this function in the future. |
Yep, this is exactly what I implemented |
I make it better: IntWithStepsOfTeXForm[formula_, j_]:=
With[{TeX2Str = Convert`TeX`ExpressionToTeX},
Steps[Int[formula, j], RubiPrintInformation -> False] //
Flatten //
Most //
Cases[RubiIntermediateResult[x_]:>"=&" <> (TeX2Str[HoldForm @@ x]) <>"\\\\"] //
{"\\begin{aligned}",TeX2Str@HoldForm@Int[formula, j], Sequence @@ #,"\\end{aligned}"} & //
StringReplace[
"\\, d" <> ToString[var] -> "\\, \\mathrm{d}" <> ToString[var]]//
StringRiffle] Now we can use it just like |
By the way, I modified it to be another display function which doesn't use
|
Actually your don't need to
Without |
Wow, amazing, After running your code, the effort is so nice! Thx. Maybe it's because of this line?
|
Yes, |
This modification is a result from [issue#34](RuleBasedIntegration#34 (comment)); the additional `IntWithStepsOfTeXForm` by [@wuyudi](https://github.com/wuyudi) and `IntTraditional` by [@asdasd1dsadsa](https://github.com/asdasd1dsadsa) are integrated (with some change) as accepted values (resp., `TeXForm` and `TraditionalForm`) for the `RubiPrintInformation` option to the `Steps` function. The corresponding `::usage` message is modified as well. `MakeBox` formatting for `Subst` is added as suggested by [@asdasd1dsadsa](https://github.com/asdasd1dsadsa), with minor modification. `SyntaxInformation` is added for `Int` and `Steps`; this covers the [pull-request#43](RuleBasedIntegration#43 (comment)).
I made a PR (pull-request#44) for this thread. Modifications were made to the suggestions above, and I do hope this is not offensive to the original contributors. |
This is what now I do :
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 is it possible to add a command to automatically get code like
to make it easier for following steps? For example , using MaTeX to get nice formula.
The text was updated successfully, but these errors were encountered: