In case it is helpful to anyone, I am posting below a recent conversation working out some issues with an installation of the SageTeX module previously discussed on this thread:

Dear mr McCoffee, I was very excited when I discovered your module for integrating Sage with LyX. But I'm afraid I need a little bit more help to make it work. I managed to setup the one-step conversion in LyX, however, when I apply it to your file example.lyx all sage-blocks display as double questionmarks in the .pdf file. Can you point me to a more detailed tutorial on how to use this LyX module? Here is what I did: downloaded example.lyx, setup.sh, compile-pdf-sage.sh, sage.module and preferences to the desktop edited setup.sh to reflect non-standard paths on my system (~/.lyx2 and /opt/sage-5.2) ran setup.sh (sudo bash setup.sh) I checked that compile-pdf-sage.sh is copied to the sage directory, the preferences file to ~/lyx2 and sage.module to the layouts folder in ~/lyx2. I also copied sagetex.sty to /home/dd/texmf, my user texmf folder. I noticed the following error in the console from which I started LyX2: insets/InsetLayout.cpp (191): Flex insets must have names of the form `Flex:<name>'. This one has the name `sagecommand' I hope you can help me out, yours sincerely Dirk Danckaert Hi Dirk, I'm currently running LyX 2.0.0 with Sage 4.8 on Ubuntu 11.10. Since my Sage version is old (for complicated reasons), it's possible something has changed in SageTeX, but let's try some other things before I install another Sage. I get the same message you do about the insets, along with some other LyX complaints, and they are not causing me problems (yet), so that may not be something to worry about. Since you're on Ubuntu, one possible source of trouble (which happened to me when I changed machines) is that, if you're using TeXLive, the potentially mis-matched version of SageTeX that it includes can stick around and pre-empt the correct one (even if you've followed the instructions --- http://www.sagemath.org/doc/installation/sagetex.html --- to install the one from your Sage distribution into LaTeX. Try making sure it's gone by doing something like sudo rm -r /usr/share/texmf-texlive/tex/latex/sagetex sudo texhash - Thomas Hi Thomas, I have corrected at least one error while checking things out again. Seems the copying of sagetex.sty had not been done as it should. However, still no joy. I did the two sudo-commands, with no error-messages. I loaded example.lyx and tried a .pdf-export (I chose /File/Export/PDF (pdflatex+sagetex). As a result I got the error message An error occurred while running: compile-pdf-sage.sh "example.sagetex.sage" I tried to make sense of that but I couldn't: compile-pdf-sage.sh must be located in the SAGE-directory, isn't it? So how does it find the .sagetex.sage-file? I tried to locate example.sagetex.sage (I thought this is an intermediate file produced by LyX) in the directory that contained example.lyx (a folder on my desktop) but it wasn't there. Is there perhaps a simpler test that I could perform, e.g. just calculate 1+1 in LyX? Dirk Hi Dirk, In order to figure out what's going on, please try running LyX from a terminal window and running the export again --- then the error messages from the call to compile-pdf-sage.sh will be visible in the terminal. I believe you edited the setup.sh script included with the module to point to your Sage installation at /opt/sage-5.2. The script normally puts compile-pdf-sage.sh in this same directory and adds that directory to the execution path. However, it doesn't make that change to the execution path permanent --- when you start a new shell, it won't be there --- so in retrospect, it's probably a better idea to move or link compile-pdf-sage.sh to somewhere like /usr/local/bin where it can always be found. You can always do `echo $PATH' to make sure it's somewhere findable. (The reason I did it this way was that, in the Sage installations I had used before, it was normally necessary to permanently add the Sage directory to the execution path anyway, so it didn't occur to me this would be a problem.) In the LyX that I'm running, it does all its LaTeX file operations in an auto-generated temporary directory with a name like `/tmp/lyx_tmpdir.J23736/lyx_tmpbuf2' (to avoid cluttering your file system). This is where I would expect `example.sagetex.sage' to appear. It might be helpful to see the files it generates in this directory to make sure things are working right --- but whenever we make any changes, clear out the old files so we know what's new. If you want, you can replace the Sage insets in example.lyx with a single simpler one, but I doubt it will help much --- once we get Sage doing its job, the whole thing should run very fast. - Thomas Hi Thomas, First I have to thank you for your time and patience. But I think I'm making progress. As you assumed, the system couldn't find compile-pdf-sage.sh, and I learned a lesson in using the terminal. (I'm an ex-windows user, and hence I acquired some bad habits I guess.) I then moved compile-pdf-sage.sh to /usr/local/bin and - on second try - had a complaint about permissions. I then change-modded the permissions on compile-pdf-sage.sh to 777, and this time the script was executed. However, now it is TeX which is complaining. This is the message on which the script hangs (I stop it with some <Ctrl-C>'s, or just by waiting long enough).dd@Dokux:~$ lyx2 insets/InsetLayout.cpp (191): Flex insets must have names of the form `Flex:<name>'. This one has the name `sagecommand' Ignoring LyXType declaration. LyX: Unknown InsetLayout tag [around line 2 of file current token: 'custom' context: ''] LyX: Unknown InsetLayout tag [around line 12 of file current token: 'OptionalArgs' context: ''] LyX: Unknown InsetLayout tag [around line 13 of file current token: '0' context: ''] LyX: Unknown InsetLayout tag [around line 13 of file /tmp/lyx_tmpdir.TJ2300/convert_layout.kn2300 current token: 'OptionalArgs' context: ''] LyX: Unknown InsetLayout tag [around line 14 of file /tmp/lyx_tmpdir.TJ2300/convert_layout.kn2300 current token: '0' context: ''] Running: pdflatex "example.tex" > /dev/null This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) entering extended mode (./example.tex LaTeX2e <2009/09/24> Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1 9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian , estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded. Running: pdflatex "example.tex" > /dev/null This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) entering extended mode (./example.tex LaTeX2e <2009/09/24> Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1 9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian , estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded. Running: compile-pdf-sage.sh "example.sagetex.sage" This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) entering extended mode (./example.sagetex.sage LaTeX2e <2009/09/24> Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1 9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian , estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded. ! You can't use `macro parameter character #' in vertical mode. l.1 # # -*- encoding: utf-8 -*- It seems a bit strange that pdfTeX should process the file three times. Maybe I should have left the comment lines in the script? Here's the compile-pdf-sage.sh script that I am running: #!/bin/bash sagefile=$1 texfile=${sagefile%.sagetex.sage}.tex # for one-step conversion, uncomment lines below and corresponding line in ~/.lyx/preferences texfile=$1 sagefile=${texfile%.tex}.sagetex.sage pdflatex $texfile sage $sagefile pdflatex $texfile exit 0 I found the lyx temporary directory too. I see now that TeX is trying to tex example.sagetex.sage, which is meant to be processed by sage of course. If you should need them I can send you the tex-logs too, or I can try to analyse them myself if you can tell what to look for. Dirk Hi Dirk, Yes, for now you should leave the three lines commented out in compile-pdf-sage.sh as they were originally. The module was designed to support two different modes of doing the conversion: (a) a two-step mode, the default; and (b) a one-step mode. If you uncomment the lines in compile-pdf-sage.sh, it tries to use the one-step mode, but in order for this to work at all, you also need to uncomment the corresponding LyX preferences line included in the `preferences' file. Looking at the `preferences' file, you'll see that in the two-step mode, we tell LyX that it can convert "sagetex" to "sage" using pdflatex, and can convert "sage" to "pdf10" using compile-pdf-sage.sh. LyX figures out that in order to convert "sagetex" to "pdf10", it should do both of these in order. In this mode, it will run compile-pdf-sage.sh on a Sage file, so the original lines in compile-pdf-sage.sh must remain commented out for this to work. The advantage of the two-step mode is that any errors generated on the first run of pdflatex will show up in LyX, so you can easily see if there's a LaTeX problem in your document. In the one-step mode, the preferences file tells LyX that to convert "sagetex" to "pdf10", it can just use compile-pdf-sage.sh directly. So LyX runs compile-pdf-sage.sh on a TeX file, and those lines need to be uncommented. The compile-pdf-sage.sh script then does all three steps itself: (1) run pdflatex on the TeX file, (2) run sage on the Sage file, and (3) run pdflatex on the TeX file again to incorporate the results from Sage. Leave the original stuff commented out for now so we can use the default two-step mode. Thomas Hi Thomas, It works! Works like a charm! Thank you very much: it don't think I would have managed to get it working on my own. The possibility to define a graph from within LyX will be very useful to me. I see that LyX generates a .pdf, in the same directory as the .lyx source file. That's perfectly workable, but can I set things up so that I have the .pdf automatically opened, as when using normal LyX? I thought the 2-step mode would require two actions from the user, each time you wanted to process a LyX-file. I understand now that it is only the software that does two steps. So what are the advantages of using the one-step process? Dirk Hi Dirk, That's great! I hope it's useful to you --- if you make or think of any improvements, do let me know so we can make them available. I am not actively using it myself at the moment, so I have not made any updates since the initial version. It's odd that your PDF file doesn't open automatically, which it does for me. When I select View >> View (Other Formats) >> PDF (pdflatex+sagetex) from the LyX menu on my system, the PDF opens automatically in evince. The lines of the LyX preferences file included with the module contain the following: \Format pdf10 pdf "PDF (pdflatex+sagetex)" g xdg-open "" "document,vector,menu=export" \viewer_alternatives pdf10 xdg-open \viewer_alternatives pdf10 okular \viewer_alternatives pdf10 evince \viewer_alternatives pdf10 xpdf The first line gives the name "pdf10" to the output format we get from choosing that option from the View menu (LyX uses the other "\converter" lines in file to work out a conversion path to yield that format). The other lines above tell it what commands to try for opening the resulting file (xdg-open just keeps track of default applications for opening various file types, like you have probably experienced on Windows). If for some reason you don't have any of these PDF viewers, or your xdg-open doesn't point to any suitable viewer, your file might not open. Otherwise, I'm not sure ... but I think you could always hack it by adding something like the following at the end of comple-pdf-sage.sh before the exit code: pdffile=${texfile%.tex}.pdf evince $pdffile (By the way, the current shell script doesn't play nice with file names containing spaces ... you can fix this by putting quotation marks around anything beginning with `$'.) I can't think of a good reason to use the one-step mode instead of the two-step mode, but I seem to recall I kept it because it was implemented by the person who started work on this module (Murat Yildizoglu). It's conceivable it could be marginally faster since LyX wouldn't pay attention to any LaTeX messages, but I doubt that's significant. The main way to gain speed is to only run pdflatex (and not Sage) if the Sage computations have not changed, by using the regular pdflatex option from the View menu in LyX --- this is why the module leaves that option as the default view method. Until I get around to writing a better README file, would you mind if I append the transcript of our exchange to the lyx-users thread about the module? In case others run into any similar problems ... Cheers, Thomas Hi Thomas, one improvement I can suggest right away: just eliminate that one-step process. If its performance gain is indeed minimal, I see no reason to keep it. I for one was confused as to its purpose. The reason the PDF did not open automatically was because I used the File >> Export menu, in stead of the View menu. When I choose View >> etc., the PDF does open automatically. I'm a bit puzzled why the new format 'PDF (pdflatex + sagetex)' doesn't show up under the toolbar button 'View other formats'. I always used this toolbar in stead of the View menu, and I just didn't think of it (I mean: the menu). Of course you can post our exchange to the lyx-forum. I think the combination of LyX - hands down the best text processor I ever worked with - and Sage opens vast possibilities. It really should get more publicity. It seems like a good idea to learn a bit more about the workings of LyX. Perhaps you can point me to a good source of information about, e.g., the format and purpose of the various entries in the lyx options file? Is it dangerous to edit it by hand? (there's a warning not to do so) Could I e.g. just clear it and build it anew from inside LyX? Thanks again, Thomas, you have been most helpful. Hi Dirk, one improvement I can suggest right away: just eliminate that one-step process. If its performance gain is indeed minimal, I see no reason to keep it. I for one was confused as to its purpose. I agree the annotations about it were confusing ... when I get a chance to update, I will change this. The reason the PDF did not open automatically was because I used the File >> Export menu, in stead of the View menu. When I choose View >> etc., the PDF does open automatically. I'm a bit puzzled why the new format 'PDF (pdflatex + sagetex)' doesn't show up under the toolbar button 'View other formats'. I always used this toolbar in stead of the View menu, and I just didn't think of it (I mean: the menu). Never noticed that before ... I've filed it as a bug: http://www.lyx.org/trac/ticket/8550 Of course you can post our exchange to the lyx-forum. I think the combination of LyX - hands down the best text processor I ever worked with - and Sage opens vast possibilities. It really should get more publicity. In the past I have made extensive use of Mathematica, whose "notebook" documents provide a tightly integrated literate programming environment. However, since my main interest in literate programming has been for reproducible research, this platform had some severe limitations (openness, availability to everyone, sophisticated document features for paper-writing, and extensibility of the underlying computation system). I am currently using LyX and Sage for my Ph.D. thesis, and feel like I've finally found the right set of tools (though of course there's always more to do). It seems like a good idea to learn a bit more about the workings of LyX. Perhaps you can point me to a good source of information about, e.g., the format and purpose of the various entries in the lyx options file? Is it dangerous to edit it by hand? (there's a warning not to do so) Could I e.g. just clear it and build it anew from inside LyX? I never found a good guide to all of this, though just now I came across this page that might be a good place to start: http://www.oak-tree.us/2010/07/13/custom-lyx-modules/ . There's some information in the Customization manual (Section 5: Installing New Document Classes, Layouts, and Templates), but not enough to explain the whole module system. I started from a version of this module already built by Murat (you can see our discussion here: http://www.mail-archive.com/lyx-users@lists.lyx.org/msg91798.html ), so I gradually just figured out how to tweak things to get them to work. Everything that we added to the LyX preferences file for purposes of this module can be changed from within LyX under Tools >> Preferences. If you go there, you'll see the changes we made already appear in the GUI. Thanks again, Thomas, you have been most helpful. My pleasure --- thanks for trying it out! On Mon, Apr 2, 2012 at 12:31 PM, Thomas Coffee <thomasmcof...@gmail.com> wrote: > The attachments on this thread have been posted to the wiki (thanks > Christian): > > http://wiki.lyx.org/Layouts/Modules/#toc7 > http://wiki.lyx.org/uploads/Modules/Sage > > Note that if you customize the sage.module file, you can load the > changes immediately by entering "layout-reload" in the minibuffer. > > As Murat has done: I hereby grant permission to license my > contributions to the sage module for LyX under the GNU General Public > License, version 2 or later. > > - Thomas > > > On Sun, Apr 1, 2012 at 12:03 PM, Murat Yildizoglu <myi...@gmail.com> wrote: >> Good idea, thanks a lot for the suggestion Xu. Here is my statement (I put >> the devel list as CC) : >> >> I hereby grant permission to license my contributions to the SAGE module for >> LyX under the GNU >> General Public Licence, version 2 or later. >> >> Murat Yildizoglu >> >> >> 2012/3/31 Xu Wang <xuwang...@gmail.com> >>> >>> Dear Thomas >>> >>> Excellent news! Thank you for your continued work. I have not taken a fine >>> look at this yet, but I also use Ubuntu so it looks like it might be useful. >>> >>> I'm not sure but I think for your contributions to be used you have to >>> give permission explicitly. Look at this email: >>> >>> http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg161963.html >>> You can send something like that to the development list, lyx-devel >>> >>> And it could be a good idea for Murat to do the same. >>> >>> I'm not sure though. >>> >>> In any case, thank you for your continued work. I am appreciative. Xu >>> >>> >>> >>> On Sat, Mar 31, 2012 at 3:08 AM, Thomas Coffee <thomasmcof...@gmail.com> >>> wrote: >>>> >>>> Hi Murat and Xu, >>>> >>>> I found your thread in the archives and did some further work on the >>>> LyX-SageTeX module that Murat posted previously. >>>> >>>> I fixed a few things that did not work for me in the version described >>>> earlier, and expanded the module specification to provide some >>>> additional conveniences for including literate Sage code in LyX >>>> documents. There's still much room for development and customization. >>>> >>>> The attachments comprise a set of files and a shell script "setup.sh" >>>> that should largely automate the configuration process on GNU/Linux >>>> systems. >>>> >>>> *** Help needed: >>>> >>>> For other interested users, I'd like to upload this to >>>> http://wiki.lyx.org/Layouts/Modules, but I get browser errors for >>>> links anywhere under the upload path wiki.lyx.org/ipfm. The page >>>> http://wiki.lyx.org/Site/AboutUploading also tells me I will need >>>> someone to tell me the upload password. Can anyone assist? >>>> >>>> Thanks, >>>> Thomas >>>> >>>> >>>> > Hi Xu, >>>> > >>>> > Thank you for your appreciation. I cannot advance anymore without any >>>> > help >>>> > from Lyx gurus. >>>> > I think I have extracted all the information I can from the help docs. >>>> > If I >>>> > get any answer to my questions, I can construct a little bit smarter >>>> > module >>>> > but the one we have now is already usable. With some supplementary >>>> > tricks >>>> > from the sagetex documentation and through manual executions of the >>>> > latex-sage-latex chain, it is possible to make a lot of computations. >>>> > >>>> > I was also very agreeably surprised that this module can be used for >>>> > conversion to HTML from LyX, with figures and all. >>>> > >>>> > I attach to this message the module in its actual stage and some >>>> > instruction for making the conversion chain functional. I hope this >>>> > would >>>> > already help some of you. >>>> > >>>> > As soon as I have more information, I will try to complete the module >>>> > file. >>>> > >>>> > Best regards, >>>> > >>>> > Murat >>>> > >>>> > 2011/10/31 Xu Wang <xuwang...@gmail.com> >>>> > >>>> > > Dear Murat, >>>> > > >>>> > > This is great! I have been waiting for something like this for a long >>>> > > time. I also like the Sweave-like philosophy of this. It's more >>>> > > transparent >>>> > > and reproducible. >>>> > > >>>> > > I am looking forward to the final release with much excitement. >>>> > > >>>> > > Thank you for your work! >>>> > > >>>> > > Best, >>>> > > >>>> > > Xu >>>> > > >>>> > > >>>> > > On Mon, Oct 31, 2011 at 12:54 PM, Murat Yildizoglu >>>> > > <myi...@gmail.com>wrote: >>>> > > >>>> > >> Just another mail to correct a problem with the preceding Lyx file >>>> > >> (see >>>> > >> the new file attached, and the $ signs in ERT boxes, this is >>>> > >> connected with >>>> > >> the problem I describe below) and ask a question about insets again: >>>> > >> >>>> > >> What kind of Flex insets can be included in a math mode text? Is >>>> > >> this >>>> > >> possible at all? Especially in displayed equation where one would >>>> > >> like to >>>> > >> include results from SAge computations? >>>> > >> I cannot write the following in math mode in Lyx, putting the left >>>> > >> member >>>> > >> in a displayed equation and the right member in a sagecode inset >>>> > >> that would >>>> > >> be converted to the expression I give >>>> > >> (\sage{integral(x/(x^2+1),x,0,1)) >>>> > >> \dfrac{\partial^{4}y}{\partial >>>> > >> x^{4}}=\sage{integral(x/(x^2+1),x,0,1)} >>>> > >> >>>> > >> I meet two problems: >>>> > >> 1/ I cannot insert a Flex:sagecommand inset in a displayed equation, >>>> > >> Lyx >>>> > >> just goes to the next line before inserting it... >>>> > >> 2/ I cannot type the sagetex instruction (*sage{} ) by hand, >>>> > >> because >>>> > >> "x^2" in the right member must not be interpreted by LyX, since >>>> > >> Sage will >>>> > >> need it for its computation. >>>> > >> >>>> > >> I can of course type everything in an ERT, but this cannot be called >>>> > >> "integration" can it? ;-) >>>> > >> >>>> > >> I have reread again the help document on layouts and insets, and I >>>> > >> have >>>> > >> checked the files that come in the layout folder of LyX, but cannot >>>> > >> find >>>> > >> any answer to my question. >>>> > >> >>>> > >> Sorry for bothering you again with my problems... I hope that Sage >>>> > >> integration will interest other people... >>>> > >> >>>> > >> Murat >>>> > >> >>>> > >> I definitely need the help of a Lyx wizard who understands well the >>>> > >> insets and their integration in Lyx/Latex... >>>> > >> >>>> > >> >>>> > >> >>>> > >> 2011/10/31 Murat Yildizoglu <myi...@gmail.com> >>>> > >> >>>> > >>> Just to show you the kind of niceties that such an integration can >>>> > >>> bring, I send you two files. One is the Lyx source and the other >>>> > >>> one is the >>>> > >>> final PDF. >>>> > >>> In Lyx, I just click on the Preview button and wait a little bit >>>> > >>> to get >>>> > >>> the final PDF that I show here, with results of the computations >>>> > >>> done by >>>> > >>> Sage and converted back to Latex. >>>> > >>> >>>> > >>> The module isfar from perfect yet (this is the first module I am >>>> > >>> creating), a better integration between the Latex output by Sage, >>>> > >>> and the >>>> > >>> math mode in LyX would be implemented to have nice equations >>>> > >>> typeset with >>>> > >>> equation numbers and what not. You can also see that the output of >>>> > >>> the >>>> > >>> integral by Sage is not very beautiful... >>>> > >>> >>>> > >>> I will continue to work on this module, but it is already useful >>>> > >>> for me >>>> > >>> and eliminates some regrets I feel ;-), since I have dropped >>>> > >>> Scientific >>>> > >>> Workplace in favor of LyX. >>>> > >>> >>>> > >>> I hope that you will like this new possibilities. >>>> > >>> >>>> > >>> Best regards, >>>> > >>> >>>> > >>> Murat >>>> > >>> >>>> > >>> PS. Sage lives in: http://www.sagemath.org >>>> > >>> >>>> > >>> >>>> > >>> -- >>>> > >>> Prof. Murat Yildizoglu >>>> > >>> >>>> > >>> Université Montesquieu Bordeaux IV >>>> > >>> GREThA (UMR CNRS 5113) >>>> > >>> Avenue Léon Duguit >>>> > >>> 33608 Pessac cedex >>>> > >>> France >>>> > >>> >>>> > >>> yi...@u-bordeaux4.fr >>>> > >>> >>>> > >>> http://yildizoglu.info >>>> > >>> >>>> > >>> http://www.twitter.com/yildizoglu >>>> > >>> >>>> > >>> >>>> > >> >>>> > >> >>>> > >> -- >>>> > >> Prof. Murat Yildizoglu >>>> > >> >>>> > >> Université Montesquieu Bordeaux IV >>>> > >> GREThA (UMR CNRS 5113) >>>> > >> Avenue Léon Duguit >>>> > >> 33608 Pessac cedex >>>> > >> France >>>> > >> >>>> > >> yi...@u-bordeaux4.fr >>>> > >> >>>> > >> http://yildizoglu.info >>>> > >> >>>> > >> http://www.twitter.com/yildizoglu >>>> > >> >>>> > >> >>>> > > >>>> > >>>> > >>>> > -- >>>> > Prof. Murat Yildizoglu >>>> > >>>> > Université Montesquieu Bordeaux IV >>>> > GREThA (UMR CNRS 5113) >>>> > Avenue Léon Duguit >>>> > 33608 Pessac cedex >>>> > France >>>> > >>>> > yi...@u-bordeaux4.fr >>>> > >>>> > h <http://myildi.e-jemed.org/>ttp://yildizoglu.info >>>> > >>>> > http://www.twitter.com/yildizoglu >>>> > >>>> > The Sage module allows the use of the open source Sage mathematical >>>> > platform >>>> > for computations in Lyx (with results inserted in the final PDF file), >>>> > in a >>>> > somewhat similar way for R-project with the Sweave module. >>>> > >>>> > To be able to use it, you must have Sage installed on your computer and >>>> > the >>>> > "sage" command must be in the path. >>>> > See : http://www.sagemath.org/ >>>> > >>>> > Sage speaks Latex and can interact with it through the sagetex.sty >>>> > package. >>>> > >>>> > See: http://www.sagemath.org/doc/tutorial/sagetex.html#sec-sagetex >>>> > >>>> > INSTALLATION >>>> > >>>> > 0/ You must have a working Sage system on your computer and the sage >>>> > command >>>> > must be on the PATH (open a console and type sage and RETURN key to >>>> > check it >>>> > this is the case). >>>> > >>>> > 1/Add the sage.module in the layouts folder of your local LyX >>>> > configuration >>>> > (depends on the system). Start LyX and reconfigure it. >>>> > You can now add the Sage module to a new document. This module provides >>>> > - the environments: sageblock and sagesilent >>>> > - the commands: \sage (to be used in-line) and \sageplot (as an >>>> > environment, >>>> > can be included in a Figure float) >>>> > and it needs the sagetex.sty package to be available in your local Tex >>>> > installation. >>>> > Justfollow the instructions given in the documentation of this package, >>>> > for >>>> > example >>>> > >>>> > >>>> > >>>> > 2/ Add the following sections elements in the preferences file that >>>> > lives in >>>> > your personal lyx config folder (depends on the system) >>>> > >>>> > # FORMATS SECTION ########################## >>>> > # >>>> > >>>> > \format "pdf10" "pdf" "PDF" "" >>>> > "\"/Applications/_Editiontextes/Skim.app/Contents/MacOS/Skim\"" "" >>>> > "document,vector,menu=export" >>>> > \format "sage" "sage" "Sage" "" "" "" "document" >>>> > \default_view_format pdf10 >>>> > >>>> > # >>>> > # CONVERTERS SECTION ########################## >>>> > # >>>> > >>>> > >>>> > \converter "latex" "sage" "latex" "latex" >>>> > \converter "sage" "pdf10" "compile-pdf-sage.sh $$b" "" >>>> > >>>> > 3/ You need a bash file for automatically running the .sage file and >>>> > get the >>>> > results in the final pdf file >>>> > >>>> > This compile-pdf-sage.sh should be on your path, with the following >>>> > content: >>>> > #!/bin/sh >>>> > >>>> > /Applications/_Recherche/Sage-4.7-OSX-64bit-10.6.app/Contents/Resources/sage/sage >>>> > $1.sage >>>> > pdflatex $1.tex >>>> > exit 0 >>>> > >>>> > Otherwise, >>>> > You can just convert your Lyx document to Sage and then go to the >>>> > temporary >>>> > folder and execute manually >>>> > >>>> > (pdf)latex mysagedoc.tex -> generates mysagedoc.sage >>>> > sage mysagedoc.sage >>>> > (pdf)latex mysagedoc.tex >>>> > >>>> > Remaining problems and questions: >>>> > 1/ How to setup options for environments? Example: >>>> > \sageplot[width=12cm]{plot(sin(x), 0, pi), axes=True} -> Bug fix by >>>> > Richard >>>> > 2/ How to insert Flex insets in math mode, in displayed equations? >>>> > $\dfrac{\partial^{4}y}{\partial >>>> > x^{4}}=\sage{integral(x/(x^2+1),x,0,1)}$ >>>> > x^2 must not be interpreted by LyX in the second part of the equality, >>>> > since >>>> > Sage will need it for its computation. >>>> > 3/ \sage{} does not automatically switch to the math mode. These insets >>>> > must be >>>> > inserted between two $ sign put in ERT boxes. Then, the problem remains >>>> > for the >>>> > displayed equations where one would like to include Sage results. >>> >>> >> >> >> >> -- >> Prof. Murat Yildizoglu >> >> Université Montesquieu Bordeaux IV >> GREThA (UMR CNRS 5113) >> Avenue Léon Duguit >> 33608 Pessac cedex >> France >> >> Bureau : F-331 >> >> yi...@u-bordeaux4.fr >> >> http://yildizoglu.info >> >> http://www.twitter.com/yildizoglu >>