10
$\begingroup$

I would like to formulate a question in a notebook for my students using $\LaTeX$ (or $MathML$) to typeset functions and matrices. I specifically want a language other than Mathematica as students will have to replicate the output using Mathematica.

Is there a way of using $\LaTeX$ in text?

Is it also possible to generate $\LaTeX$ output when setting up a notebook in a text editor?

I have found solutions for using $\LaTeX$ in Mathematica commands but this does not work in text.

$\endgroup$

closed as unclear what you're asking by Jens, LCarvalho, MarcoB, Nasser, yohbs Jul 16 '17 at 1:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Take a look at MaTeX from our friend Szabolcs. It may help. $\endgroup$ – MarcoB Jul 10 '17 at 14:34
  • 2
    $\begingroup$ Load MaTeX, then (for instance): << MaTeX ` then MaTeX@HoldForm[Sum[1/k^3, {k, 1, \[Infinity]}]] $\endgroup$ – David G. Stork Jul 10 '17 at 15:22
  • 1
    $\begingroup$ If you just want to state a problem mathematically in a Text cell that students will answer by using entering expressions in a Input cell, Mma notebooks already offer extensive math formatting capabilities in text cells. (Or, did you want something else?) $\endgroup$ – Alan Jul 10 '17 at 15:36
  • 1
    $\begingroup$ Are you looking for LaTeX or are you looking for mathematical typesetting? If the latter, check these: reference.wolfram.com/language/tutorial/… wolfram.com/language/fast-introduction-for-math-students/en/… $\endgroup$ – Szabolcs Jul 10 '17 at 16:09
  • $\begingroup$ What do you mean by "Mathematica text" and what do you mean by setting up a notebook in a text editor? Do your students have Mathematica or do you want them to not use Mathematica? $\endgroup$ – Jens Jul 10 '17 at 17:17
8
$\begingroup$

Question not clear. But to insert Latex Matrix (or any other latex output, such as equations etc..) in textcell using the notebook, here is an example. If OP does not want to use the notebook at all, then this is not possible and will delete this.

Load Matex to render the Latex. Start text cell. Insert the latex in the textcell from the rendered output. Here is an example

enter image description here

Code:

<<MaTeX`
matrix = Table[i + j, {i, 1, 3}, {j, 1, 4}];
matrixAsLatex = MaTeX@TeXForm[matrix]

However, I would not do it this way if I were you. I use Mathematica all the time to generate Latex, but I output direct Latex to a file which later compile using lulatex directly. I use this method to generate hundreds of PDF files and reports all from Mathematica. (I do not use Export Latex at all either). But to do this, you need to know little Latex and make heavy use of TeXFrom as well when needed. Will try to post an example of how this method works if needed, but you asked for using textcell.

An option between using texcell and full method I use is to render the whole thing as String in the notebook. Here is an exammple

ClearAll[y,x];
<<MaTeX`
matrix=Table[i+j,{i,1,3},{j,1,4}];
matrixAsLatex=MaTeX@TeXForm[matrix];
equation = y'[x]==x;
sol=y[x]/.DSolve[equation,y[x],x];

ANd now type

string="\\text{My Matrix in Latex is} "<>ToString@TeXForm[matrix]<>
       " \\text{which looks nice and my equation is } \\fbox{"
       <>ToString@TeXForm[equation]<>"}\\text{ which Mathematica can 
       solve giving the answer}"<>ToString@TeXForm@sol;

MaTeX[string,Magnification->1.3]

Which gives

Mathematica graphics

Or you can use Row instead, as in

string=Row[{"My Matrix in Latex is ",
           MaTeX@TeXForm[matrix],
           "which looks nice and my equation is ",
           MaTeX@TeXForm[equation],
           " which Mathematica can solve giving the answer "
           ,MaTeX@TeXForm@sol}]

Mathematica graphics

The method I use, does not do the above, but sends all output to file. So it is basically as if one is writing plain Latex, but sending output to file, and using Mathematica to do the computation and convert results to Latex as needed.

$\endgroup$
  • $\begingroup$ super-cool demo. $\endgroup$ – user1066 Jul 10 '17 at 20:27
  • $\begingroup$ Do you think this is a duplicate of How to use LaTeX for typesetting labels and titles in Mathematica? I don't want to be too hasty because I don't understand the question, but it looks very similar to me. $\endgroup$ – Jens Jul 10 '17 at 22:10
  • 1
    $\begingroup$ @Jens I really do not know. OP asked for Latex in textcell (using text editor?) There are number of Other Latex related questions on this site as well. But if you think it is duplicate, feel free to close it. I still do not understand fully what the OP is asking for actually :) $\endgroup$ – Nasser Jul 10 '17 at 22:20
  • $\begingroup$ Thank you for all the answers. I don't feel this is a duplicate as I want to typeset math in a text cell, not a command. I also want to generate the text outside Mathematica. I hope this and my comment above clarifies my problem. $\endgroup$ – user49947 Jul 11 '17 at 7:40
  • 1
    $\begingroup$ @user49947 I am sorry, I still have no idea what you want to do. TextCell is by definition a construct inside a notebook. It works only in a notebook. I did not use Maple TA, so I do not know how it works. As far as I know, only Mathematica can author notebooks. I do not think there is software which can create Mathematica notebooks that will run inside Mathematica which is not generated by Mathematica itself. I still do not know why you do not want to use Mathematica to generate the Latex. $\endgroup$ – Nasser Jul 12 '17 at 1:28

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