On Mon, Aug 19, 2013 at 11:30:29PM -0700, Pavel Sanda wrote: > Sebastian Kranz wrote: > > I wanted to ask if perhaps, it could be possible to add a Lyx command that > > allows to copy selected Lyx text containing math and text as Latex code. To > > be more precise, when I paste copied Lyx text in a text editor it shall be > > correct Latex code including $ signs. Currently, the dollar signs $ for > > math are not copied, e.g. when copying the following text: "text $x=5$", I > > can only paste it as "text x=5". I know that one can open the latex source > > window in Lyx, and copy code from there but that is rather inconvenient. > > Hi Sebastian, > > are you aware of math-extern LFUN? > Pushing math code to maxima and back (done through TeX wrapping IIRC) > works already and adding support for 'solve' could be few lines of > code in MathExtern.cpp.
What kind of support? AFAIK it already works. Have a look at the attached document. The trick here is to use a delimiter inset instead of simply (...). BTW, it seems that the shortcut for the parentheses inset Alt-M+( doesn't work anymore for me. -- Enrico
#LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass article \language english \inputencoding auto \fontscheme times \graphics default \paperfontsize default \spacing single \papersize Default \paperpackage a4 \use_geometry 1 \use_amsmath 0 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \leftmargin 1in \topmargin 1in \rightmargin 1in \bottommargin 1in \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle default \layout Title Maxima + Lyx - an example document \layout Standard The fun begins - there is apparently a way to send commands to Maxima from Lyx. It's somewhat different from the TeXmacs functionality, but does seem to be functional at least on a basic level. Let's start with a basic example. First, type Alt-m m or Alt-m d to get a mathematical input, and enter a basic Maxima expression (we will use Alt-m d here): \layout Standard \begin_inset Formula \[ integrate\left(\frac{x}{1+x^{3}}+1,x\right)\] \end_inset \layout Standard Now, the fun part. There should be a menu entry Maxima under Edit \begin_inset Formula $\rightarrow$ \end_inset Math \begin_inset Formula $\rightarrow$ \end_inset Use Computer Algebra System. Note the Math submenu will only be active if your cursor is located in the expression you want to evaluate. If we select Maxima we get the following result: \layout Standard \begin_inset Formula \begin{eqnarray*} integrate\left(\frac{x}{1+x^{3}}+1,x\right) & = & \frac{\log\left(x^{2}-x+1\right)}{6}+\frac{\arctan\left(\frac{2\, x-1}{\sqrt{3}}\right)}{\sqrt{3}}-\frac{\log\left(x+1\right)}{3}+x\end{eqnarray*} \end_inset \layout Standard Note also that Lyx is able to translate the formatted input into something Maxima can understand. So far this ability is unique to this interface. It even extends to basic operators - for example, if we want to evaluate a formatted input of the form: \begin_inset Formula \[ \int\left(\sin\left(x\right)+\frac{1}{1+x^{2}}\right)dx\] \end_inset Lyx and Maxima can make sense of it: \layout Standard \begin_inset Formula \begin{eqnarray*} \int\left(\sin\left(x\right)+\frac{1}{1+x^{2}}\right)dx & = & \arctan x-\cos x\end{eqnarray*} \end_inset The previous case also works perfectly. Parenthesis seem to be optional: \layout Standard \begin_inset Formula \begin{eqnarray*} \int\frac{x}{1+x^{3}}+1\, dx & = & \frac{\log\left(x^{2}-x+1\right)}{6}+\frac{\arctan\left(\frac{2\, x-1}{\sqrt{3}}\right)}{\sqrt{3}}-\frac{\log\left(x+1\right)}{3}+x\end{eqnarray*} \end_inset \layout Standard Or, in another example, if we want to evaluate \begin_inset Formula $\sum_{i=1}^{\infty}\left(\frac{1}{3}\right)^{i}$ \end_inset : \begin_inset Formula \begin{eqnarray*} \sum_{i=1}^{\infty}\left(\frac{1}{3}\right)^{i} & = & \frac{1}{2}\end{eqnarray*} \end_inset It seems to handle rather complex outputs cleanly as well: \layout Standard \begin_inset Formula \begin{eqnarray*} powerseries\left(\log\left(\frac{\sin\left(x\right)}{x}\right),x,0\right) & = & \frac{\sum_{I_{1}=1}^{\infty}{\frac{\left(-1\right)^{I_{1}}\,2^{2\, I_{1}}\, BERN\left(2\, I_{1}\right)\, x^{2\, I_{1}}}{I_{1}\,\left(2\, I_{1}\right)!}}}{2}\end{eqnarray*} \end_inset \layout Standard Unfortunately, plotting is not integrated as yet. \the_end
