4
$\begingroup$

I see several questions about converting Mathematica content to LaTeX. But I didn't see any satisfying answers. I'm wondering if there is a utility that will convert Mathematica display formulae to LaTeX in a way that preserves the ordering and appearance of the original as displayed by the Mathematica Frontend.

I understand that there is no exact isomorphism between Mathematica and LaTeX. I also understand that Mathematica's primary role is the process mathematical expressions as mathematics, not textual content.

Nonetheless, in this world of MathJax rendering of LaTeX, and etc., it would be valuable to be able to convert to LaTex with minimal need for hand-correction.

The

Right-Click->copy as->LaTeX

feature of Mathematica is useful, but Mathematica processes the expression using the rules of standard algebra, which disregards the textual ordering of mathematical expressions. Much of the content I want to convert is complicated tensor analysis and multivariable calculus, etc. I have over a thousand pages of such content in Mathematica notebooks.

It would be nice if I could convert all of it with one command, but I'm realistic. If I could simply copy and paste my expressions into a text file, and process the file with some kind of conversion utility that would convert Mathematica to LaTeX, that would be great.

To give an example, I have a diadic equation that looks much like this in a Mathematica notebook:

$$\begin{bmatrix}a_{11}\hat{\mathfrak{i}}\hat{\mathfrak{i}}+a_{12}\hat{\mathfrak{i}}\hat{\mathfrak{j}}+a_{13}\hat{\mathfrak{i}}\hat{\mathfrak{k}}\\ +a_{21}\hat{\mathfrak{j}}\hat{\mathfrak{i}}+a_{22}\hat{\mathfrak{j}}\hat{\mathfrak{j}}+a_{23}\hat{\mathfrak{j}}\hat{\mathfrak{k}}\\ +a_{31}\hat{\mathfrak{k}}\hat{\mathfrak{i}}+a_{32}\hat{\mathfrak{k}}\hat{\mathfrak{j}}+a_{33}\hat{\mathfrak{k}}\hat{\mathfrak{k}} \end{bmatrix}=\hat{\mathfrak{i}}\mathfrak{B}_{1}+\hat{\mathfrak{j}}\mathfrak{B}_{2}+\hat{\mathfrak{k}}\mathfrak{B}_{3}$$

\[CapitalPhi]=[Subscript[a, 1\[InvisibleComma]1]Overscript[\[GothicI], ^]Overscript[\[GothicI], ^]+Subscript[a, 1\[InvisibleComma]2]Overscript[\[GothicI], ^]Overscript[\[GothicJ], ^]+Subscript[a, 1\[InvisibleComma]3]Overscript[\[GothicI], ^]Overscript[\[GothicK], ^]
+Subscript[a, 2\[InvisibleComma]1]Overscript[\[GothicJ], ^]Overscript[\[GothicI], ^]+Subscript[a, 2\[InvisibleComma]2]Overscript[\[GothicJ], ^]Overscript[\[GothicJ], ^]+Subscript[a, 2\[InvisibleComma]3]Overscript[\[GothicJ], ^]Overscript[\[GothicK], ^]
+Subscript[a, 3\[InvisibleComma]1]Overscript[\[GothicK], ^]Overscript[\[GothicI], ^]+Subscript[a, 3\[InvisibleComma]2]Overscript[\[GothicK], ^]Overscript[\[GothicJ], ^]+Subscript[a, 3\[InvisibleComma]3]Overscript[\[GothicK], ^]Overscript[\[GothicK], ^]

]=Subscript[\[GothicCapitalB], 1]Overscript[\[GothicI], ^]+Subscript[\[GothicCapitalB], 2]Overscript[\[GothicJ], ^]+Subscript[\[GothicCapitalB], 3]Overscript[\[GothicK], ^]

Copy as LaTeX produces this:

$$\Phi =\text{Identity}\left[\left( \begin{array}{c} \hat{\mathfrak{i}} \hat{\mathfrak{j}} a_{1,2}+\hat{\mathfrak{i}} \hat{\mathfrak{k}} a_{1,3}+\hat{\mathfrak{i}} \hat{\mathfrak{i}} a_{1,1} \\ \hat{\mathfrak{i}} \hat{\mathfrak{j}} \left(+a_{2,1}\right)+\hat{\mathfrak{j}} \hat{\mathfrak{k}} a_{2,3}+\hat{\mathfrak{j}} \hat{\mathfrak{j}} a_{2,2} \\ \hat{\mathfrak{i}} \hat{\mathfrak{k}} \left(+a_{3,1}\right)+\hat{\mathfrak{j}} \hat{\mathfrak{k}} a_{3,2}+\hat{\mathfrak{k}} \hat{\mathfrak{k}} a_{3,3} \\ \end{array} \right)\right]=\hat{\mathfrak{i}} \mathfrak{B}_1+\hat{\mathfrak{j}} \mathfrak{B}_2+\hat{\mathfrak{k}} \mathfrak{B}_3$$

Notice that the terms appear in different order from the original. In this context, ordering is significant. $\hat{\mathfrak{i}}\hat{\mathfrak{j}}\ne\hat{\mathfrak{j}}\hat{\mathfrak{i}}$

$\endgroup$
7
  • $\begingroup$ This is one entry in the matrix $\hat{\mathfrak{i}} \hat{\mathfrak{j}} a_{1,2}+\hat{\mathfrak{i}} \hat{\mathfrak{k}} a_{1,3}+\hat{\mathfrak{i}} \hat{\mathfrak{i}} a_{1,1}$."Subscript[a, 1[InvisibleComma]1]Overscript[[GothicI], ^]Overscript[[GothicI], ^]+Subscript[a, 1[InvisibleComma]2]Overscript[[GothicI], ^]Overscript[[GothicJ], ^]+Subscript[a, 1[InvisibleComma]3]Overscript[[GothicI], ^]Overscript[[GothicK], ^]" I am working with over a thousand pages of Matemetica content. I cannot go through and reproduce every expression by hand, just to convert it to LaTeX. $\endgroup$ Jan 18, 2018 at 16:55
  • $\begingroup$ Use HoldForm to preserve ordering. Copy b a, you get a b. Copy HoldForm[b a], you get b a. $\endgroup$
    – Szabolcs
    Jan 18, 2018 at 17:13
  • $\begingroup$ @Szabolcs How do I use that on an Inline Cell inside a Text Style Cell? $\endgroup$ Jan 18, 2018 at 17:24
  • 1
    $\begingroup$ Could you clarify the workflow you desire. Given a notebook with Text (including inline cells), Input, Output, etc. cells, what kind of output do you want? Is it a notebook, a text file, something else? $\endgroup$
    – Carl Woll
    Jan 18, 2018 at 18:23
  • 1
    $\begingroup$ Also, does the answer to (76860) help? $\endgroup$
    – Carl Woll
    Jan 18, 2018 at 19:13

0

Your Answer

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

Browse other questions tagged or ask your own question.