My roommate knows Mathematica. He draw 3-d graph for each term of (a+b)^3 = a^3 + 3a^2b + 3ab^2 + b^3
. He doesn't know LaTeX. I want to write his thesis document in LaTeX. So, If there is a tool that converts Mathematica code into LaTeX, that would be easier for me than write the same things in LaTeX from scratch.
-
2Related: tex.stackexchange.com/questions/84748 – Henri Menke Nov 6 '17 at 5:00
-
Why do you want to write his thesis? Mathematica can do quite a bit on its own. – Thorbjørn Ravn Andersen Nov 6 '17 at 16:43
-
@ThorbjørnRavnAndersen I don't know the quality, but he complain that he made a pdf from these image that produce low quality. – alhelal Nov 6 '17 at 17:04
-
@alhelal Perhaps he should ask that question too? Low quality images in PDF usually just indicate that the target was web and not print. Switching to TeX for that reason is like installing Linux because the printer is not working in Windows. – Thorbjørn Ravn Andersen Nov 6 '17 at 17:06
-
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – samcarter_is_at_topanswers.xyz Jul 23 '18 at 17:27
You can copy-and-paste LaTeX directly from a Mathematica notebook:
It is assumed the content is math-related, so non-math functions are set using \text
(requires amsmath
).
-
1+1. You may also want to mention the possibility of using either
\textsf
or\texttt
instead of just\text
for the stringPlot3D
. That would make it clearer, visually speaking, what's Mathematica code. – Mico Nov 6 '17 at 6:10
What do you mean by "Mathematica code"? Can you give an example of the desired conversion?
Apart from the convenient copy-paste method described by @Werner, there's TeXForm, which converts a Mathematica expression into math-mode LaTeX.
In[]:= TeXForm[Sin[x]^2]
Out[]//TeXForm=
\sin ^2(x)
If you want to convert a notebook to LaTeX, use File -> Save As... -> LaTeX Document.
In the past, I have been asked by people who did not know LaTeX if it is a good workflow to write your document as a Mathematica notebook, then simply save as LaTeX and compile it to PDF (as a means of getting better typesetting). I do not think this is a good idea. The LaTeX produced by Mathematica often has multiple issues. The LaTeX knowledge needed to correct these problems is already sufficient to write the LaTeX from scratch, so why not just do that?
Furthermore, when writing formulas in LaTeX, we specify what they should look like. When writing formulas in Mathematica, we specify what they mean, but the ultimately it is up to the system to format them in a certain way. This means that LaTeX auto-generated from Mathematica expressions will often benefit from additional manual editing.
To sum up:
Tell your roommate to take an hour to learn the basics of LaTeX. If the desired output is LaTeX, starting with a Mathematica notebook does not usually provide any benefits. I think that those LaTeX features that Mathematica can handle can really be learned in an hour or so (bold, italic, headings, equations).
However, if your goal is to convert an already written Mathematica document to LaTeX, and continue editing in LaTeX only, then go ahead and use Save As ... -> LaTeX Document.