Integrating Sage with LyX

I have been interested in the LaTeX typesetting system, but not in actually learning the extra syntax. And so I’ve been using a WYSIWYM GUI named ‘LyX‘. The .TEX-Files LyX exports are suitable to creating HTML Files, which in turn can contain typeset Math, by way of scripts, that provide MathJax code.

But then one compromise this has meant for me was, that I could either typeset Math which I had written myself, or that I could do Computer Algebra, the latter through the use of ‘wxMaxima’, which has its own system of exporting to HTML. But so far, I could not do both in one document.

Well, now that I have ‘SageMath’ and ‘SageTeX’ installed, I can do both within the same document. It’s possible to integrate SageTeX into LyX. The following is an article which explains how to do that, under the assumption that the user has both SageTeX and LyX installed:

https://wiki.lyx.org/Layouts/Modules#toc7

There is an important way in which I needed to modify the instructions however, to get the two working. First of all, there is a list of files to download – LyX does not support SageTeX out of the box – that the article above links to. Out of those files, ‘setup.sh’ is absolutely useless on a modern Linux computer. The following files from the repository above are essential:

  1. sage.module
  2. preferences
  3. compile-pdf-sage.sh
  4. example.lyx

The file ‘preferences’ needs to be edited, in that its last line needs to be uncommented.

The file ‘compile-pdf-sage.sh’ needs to be edited, in that the first two lines need to be commented out, and the next three lines which are commented by default, need to be uncommented. Then:

 


(As user:)

$ cp sage.module ~/.lyx/layouts
$ cat preferences >> ~/.lyx/preferences

(As root:)

# cp compile-pdf-sage.sh /usr/local/bin
# chmod a+x /usr/local/bin/compile-pdf-sage.sh


 

Then, within the GUI of LyX, one gives the command ‘Tools -> Reconfigure’. One shuts down and restarts LyX. Next, one opens ‘example.lyx’ to test the setup. The following is the document which I finally obtained (successfully), which was provided by the Web-site above (not written by me):

http://dirkmittler.homeip.net/sg_lyx_1.pdf

Enjoy,

Dirk

 

I now have LyX working properly, on my Linux tablet.

According to This Earlier Posting, I had installed “GNURoot (Debian)” and “XSDL” on an old tablet, that are both Android apps available from Google Play, and which do not use ‘root’. There were numerous Linux-applications which would run, and many more that do not. I had also installed numerous Linux-packages that can collectively be referred to as “LaTeX” on that tablet, which actually just means by itself, command-line programs. Yet, even when typesetting using ‘LaTeX’, it’s often more fun to use a GUI. And the Linux-application “LyX” is such a GUI.

So, I have the hypothetical ability to do serious document-work on that tablet, even though the tablet is only using an emulated mouse, and “Hacker’s Keyboard”, and the mentioned emulated X-server.

What I recently did, was to get LyX to work properly:

screenshot_2018-05-27-09-28-22

Continue reading I now have LyX working properly, on my Linux tablet.

tex4ht / mk4ht Broken (Problem Solved).

As of 05/26/2018 :

I have just been experimenting with a GUI front-end to LaTeX, that is called ‘LyX’, and it tries to be a WYSIWYG LaTeX Editor.

LyX tries to give editing capabilities for LaTeX documents, using an editor style similar to most word processors. Mind you, this task cannot always succeed 100%, because by its nature, LaTeX will encode the logical structure of a document-to-be-typeset, while conventional word processors try to control the appearance of documents.

And so one feature that LyX does have, is to import and export documents of various formats, most of which revolve around different LaTeX coding-styles, or around ‘rendering’ our LaTeX document to such formats as PDF or DVI, just because those two output-formats have arbitrarily emerged as standard publishing formats. DVI is really only interesting as a legacy Linux graphics format.

And so what some people will want to do, is convert documents from LaTeX either to OpenDocument format, or even to MS Word Format. These formats are initially visible in the Export Menu, if the user has command-line tools such as ‘mk4ht’ installed.

What can frustrate some people who are new to Linux, is that the command-line itself may be defective in some way, meaning that it malfunctions, and in my own experience, trying to get ‘mk4ht’ to work can be futile, when it does not work out-of-the-box. And then, trying to fiddle with the GUI of LyX is also to no avail, because the GUI can finally only work as well as the command-line, back-end that it has detected.

So instead of trying to repair ‘mk4ht’ – which, if it was working, could just as easily be tested from the command-line:


mk4ht oolatex somefile.tex

 

(Edited 05/27/2018 : )

I would propose that any readers of this blog, who have run into such a problem, and who are running Debian / Stretch, try instead, to install a Debian package called “pandoc”, as well as “pandoc-citeproc”. When LyX recognizes these programs as installed, they will become available as ways to export to or import from .DOCX as well as .ODT formats.

(Updated 09/26/2018, 21h50 … )

(As of 05/28/2018, 1h00 : )

Continue reading tex4ht / mk4ht Broken (Problem Solved).

The failings of low-end consumer software, to typeset Math as (HTML) MathML.

One of the features which HTML5 has, and which many Web-browsers support, is the ability to typeset Mathematical formulae, which is known as ‘MathML’. Actually, MathML is an extension of XML, which also happens to be supported when inserted into HTML.

The “WiKiPedia” uses some such solution, partially because they need their formulae to look as sharp as possible at any resolution, but also, because they’d only have so much capacity, to store many, many image-files. In fact, the WiKiPedia uses a number of lossless techniques, to store sharp images as well as formulae. ( :1 )

But from a personal perspective, I’d appreciate a GUI, which allows me to export MathML. It’s fine to learn the syntax and code the HTML by hand, but in my life, the number of syntax-variations I’d need to invest to learn, would be almost as great, as the total number of software-packages I have installed, since each software-package, potentially uses yet-another syntax.

What I find however, is that if our software is open-source, very little of it will actually export to MathML. It would be very nice if we could get our Linux-based LaTeX engines, to export to this format, in a way that specifically preserves Math well. But what I find is, even though I posses a powerful GUI to help me manage various LaTeX renderings, that GUI being named “Kile”, that GUI relies back on a simple command-line tool named ‘latex2html’. Whatever that command-line outputs, that’s what all of Kile will output, if we tell it to render LaTeX specifically to HTML. ‘latex2html’ in turn, depends on ‘netpbm’, which counts as very old, legacy software.

One reason ‘latex2html’ will fail us, is the fact that in general, its intent is to render LaTeX, but not Math in any specific way. And so, just to posses the .TEX Files, will not guarantee a Linux user, that his resulting HTML will be stellar. ‘latex2html’ will generally output PNG Images, and will embed those images in the HTML File, on the premise that aside from the rasterization, PNG Format is lossless. Further, if the LaTeX code was generated by “wxMaxima”, using its ‘pdfLaTeX’ export format, we end up with incorrectly-aligned syntax, just because that dialect of LaTeX has been optimized by wxMaxima, for use in generating .PDF Files next.

(Updated 05/27/2018 : )

Continue reading The failings of low-end consumer software, to typeset Math as (HTML) MathML.