Forgot password?
 Create new account
View 394|Reply 1

将 LaTeX 矩阵导入 Mathematica

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2021-11-10 17:25:56 |Read mode
Last edited by hbghlyj at 2021-11-10 21:13:00
  1. toMatrix=Function[str,str/. {ExpressionCell -> Identity, TraditionalForm -> Identity,SqrtBox->Function[x,StringJoin["\\sqrt{", x, "}"]], FormBox ->
  2. Function[{x, y},
  3.   StringJoin["\\frac{", ToString[x], "}{", ToString[IntegerPart[y]],
  4.    "}"]],BoxData->Function[x,ToExpression[StringJoin[x],TeXForm]], TextCell -> Identity, RawBoxes -> Function[x, If[StringQ[x], ToExpression[x], x]], Cell -> Function[{x, y}, x]}]
Copy the Code
加入User Mathematica initialization file(位置C:\ProgramData\Mathematica\Kernel\init.m)每次启动可以预加载
每次先选择"粘贴排板表达式"然后调用上面的函数.
示例
Screenshot 2021-11-10 123730.png

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2021-11-10 20:47:41
Last edited by hbghlyj at 2021-11-10 21:24:00
  1. $\frac{1}{3}\left(\begin{array}{ccc}2 & 2 & -1 \\ 2 & -1 & 2 \\ -1 & 2 & \frac{2}{3}\end{array}\right)$
Copy the Code
像这种,分子为整数的,可以正确转换.
转换不好的情况:
  1. $\frac{1}{3}\left(\begin{array}{ccc}2 & 2 & -1 \\ 2 & -1 & 2 \\ -1 & 2 & \frac{2}{a}\end{array}\right)$
Copy the Code
分母会丢失..
  1. $\frac{1}{2}\left(\begin{array}{ccc}\sqrt{2} & \sqrt{2} & 0 \\ 1 & -1 & \sqrt{2} \\ 1 & -1 & -\sqrt{2}\end{array}\right)$
Copy the Code
根号丢失,除了右下角的根号..

手机版Mobile version|Leisure Math Forum

2025-4-20 22:08 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list