Dear Liviu,
thanks for your email. After Pavel's reply I took a look at that
function and the MathExtern.cpp code. I agree that an improved
MathExtern.cpp would probably the best solution. However, I have
basically no c++ skills, so I fear I am not well fitted to contribute
along that route.
I am still not sure about one thing though: Given that parsing Latex is
mainly heuristic, it may turn out that it is substantially easier to
develop an external Lyx-To-Maxima GUI written in some scripting language
like R or Python instead of extending the direct Lyx integration in C++.
It just seems to me that a try-and-error search for a good heurstic can
be performed much quicker in a scripting language. Furthermore, an error
in the GUI would not crash Lyx completetly, but just the GUI, which one
can restart without loosing Lyx data. Hence, one could be much more
relaxed in using a version that just works in 98% of cases. Having some
more Lyx commands, like "copy as Latex" would make such external GUI
easier to use, however. Anyway, I guess I will continue working a bit on
my "R" solution and if it some day is stable enough and adds a
worthwhile benefits to the current Lyx CAS abilities, I will write a
decent documentation so that others can try it out.
All the best,
Sebastian
Am 21.08.2013 08:06, schrieb Liviu Andronic:
Dear Sebastien,
As Pavel suggested LyX already has basic support for various Computer
Algebra Systems (CAS) - Maple, Maxima, Octave, Mathematica. Usually
you write some math, c-menu on the math inset and select your
favourite CAS.
The trouble with this support, and it has been discussed previously on
the list, is that it's heuristic in nature and that it may not always
work reliably since LaTeX has no mathematically consistent internal
representation of the symbolic expressions, and we need to guess what
LaTeX means when passing it to Maxima. But look for better
explanations in the archive. Maybe if someone looked into making the
parser more robust we would get more reliable support for such fancy
operations.
Regards,
Liviu
On Mon, Aug 19, 2013 at 9:43 PM, Sebastian Kranz
<[email protected]> wrote:
Dear Developers,
first of all thanks for spending so much time into improving Lyx: it is
really great and helps me a lot in my academic daily live.
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.
Background:
I am currently developing a small GUI that shall help to use Lyx together
with the computer algebra system Maxima. (It is very preliminary and not yet
well tested. But if somebody is interested, here is the project page:
https://github.com/skranz/LyxMaxima). The program is not integrated in Lyx
but rather a separate GUI (programmed in R) that takes copied code from Lyx
sends it to Maxima, translates the result back to Latex and copies them into
the clipboard so that it can be pasted back into Lyx. One planned
functionality is that one can write in Lyx, Maxima code that is interwoven
with Lyx math fields. In Latex such code may look, e.g. as follows:
solve($x_{1}+y^{2}=0$,$x_{1}$)
where the expressions between $ $ are Lyx inline math fields. My program
would replace the Latex math in that expression by equivalent Maxima
expression and then evaluate the resulting Maxima command. To get the
correct code to the GUI, it would be really useful if I could copy such Lyx
code in its true Latex representation, i.e. in a representation that keeps
the $ around math. Beyond that particular application, such a
"Copy-Selection-as-Latex" feature may be generally useful for users who use
Lyx in combination with some other program that uses some Latex source code.
Best wishes,
Sebastian
--
Prof. Dr. Sebastian Kranz
Professorship for Sustainable Regulatory Economics
Institute for Economics, Department of Mathematics and Economics
Ulm University
89069 Ulm, Germany
Email: [email protected]
Web: http://www.uni-ulm.de/mawi/mawi-wiwi/mitarbeiter/skranz.html
http://www.wiwi.uni-bonn.de/kranz/
Phone: +49 (0)731/ 50 23691
Fax: +49 (0)731/ 50 23737