Re: Mathematica and LyX - Graphics and equations

*To*: mathgroup at smc.vnet.net*Subject*: [mg95749] Re: Mathematica and LyX - Graphics and equations*From*: JUN <noeckel at gmail.com>*Date*: Mon, 26 Jan 2009 05:01:49 -0500 (EST)*References*: <glj8bm$dln$1@smc.vnet.net>

> >3) And finally could someone please provide detailed instructions of > >how to setup LyX to interact directly with the Mathematica kernel so > >I can have some semi live math environment. May be that way the > >equations will come in the right form > > Given what LyX is, I doubt this is easily doable if at all. The last remark needs fact-checking. It actually works - within limits. It's a fun feature, but I don't really use it much. What you have to do to make it work depends on your platform. On Mac OS X, I first created a little script /usr/local/bin/math containing the following two lines: #!/bin/sh /Applications/Mathematica.app/Contents/MacOS/MathKernel "$@" The purpose of this is simply to make the command "math" appear in the path visible to LyX, and point to the Mathematica Kernel (so obviously this is Mac specific, and I don't know the PC equivalent). Then whenever you have a calculation that you want to do in LyX, do the following: * Open a math environment. * Type the Mathematica expression you want to evaluate (e.g.: Sin[.2]) * Highlight the expression * While you are still in that math box, go to Edit > Math > Use Computer Algebra System > Mathematica * Magically, an equals sign and the result of the evaluation will appear in the LyX math box. In general, in particular when graphics is involved, I would just work with the Mathematica Notebook and the LyX editor side by side, and copy/paste between the two. In LyX 1.6, you can paste graphics into LyX from the clipboard. Equations in Mathematica's TeXForm can be pasted directly into LyX math environments. In the other direction, you can copy LaTeX from LyX into Mathematica as follows: * enter the desired math expression in LyX (e.g., \sin\alpha) * select all the _contents_ of the math box, but not the math box object itself (i.e., stop highlighting when you reach the end of the math inset). * Copy * Paste literally into a Mathematica Cell, perhaps wrapped by something like ToExpression["\sin\alpha", TeXForm] (where the pasted text goes between the quotation marks) * The result can then be used in Mathematica Labels etc. Although LyX has a non-LaTeX internal file format, everything it does goes through LaTeX, and in particular all its equations can be understood by other LaTeX-aware programs. One may still ask why anyone would you use LyX instead of Mathematica to write equations. I think this has already been addressed, and it may really be a matter of taste - but it's worth pointing out that LyX has unlimited Undo and version control (there's more, but I better stop here). As for the customization of the LyX output, it's true that this isn't trivial if you don't know much LaTeX. The LyX-users mailing list would be a place to start, they are very helpful... Jens

**Follow-Ups**:**Re: Re: Mathematica and LyX - Graphics and equations***From:*TL <latev@shaw.ca>

**Re: Destructuring arguments to pure functions?**

**Re: Remove In/out names in Kernel / text session**

**Re: Mathematica and LyX - Graphics and equations**

**Re: Re: Mathematica and LyX - Graphics and equations**