This Engineering Notebook post discusses recent experiments using Leo as a mathematical notebook.
My goal was to eliminate all friction from my mathematical workflow. This post tells how I did it. *References* PR #4253 <https://github.com/leo-editor/leo-editor/pull/4253> contains improvements to VR. The public math.leo <https://github.com/edreamleo/EKR-Math/blob/main/math.leo> outline contains recent experiments, including tests of all aspects of VR related to mathematics. *Using LaTeX and pdf* The Overleaf <https://www.overleaf.com>website was a great way to learn LaTeX, but it can't be the basis of my workflow. Cutting snippets from the website to math.leo quickly becomes intolerable. Overleaf renders LaTeX by generating an internal pdf file using pdflatex and then rendering that file. My first thought was to emulate that approach. However, that approach wasn't good enough. The PostScript contains the gruesome details. *Using mathjax* Another problem with pdf files became apparent only in retrospect. As stated here <https://docs.mathjax.org/en/latest/input/tex/differences.html>, TeX/LaTeX is a *print layout engine*. When using Overleaf, I spent considerable time configuring the page layout to look good on the Overleaf web page. But that work isn't necessary! Instead of futzing with page layout, mathjax renders only LaTeX math mode. To quote from the link above, "MathJax expects that you will use standard HTML tags to handle formatting the text of your page." This approach is exactly what we need in the VR pane. The PR renders @mathjax nodes (nodes containing @language mathjax) in the VR pane. Changes in p.b render automatically (and quickly) in the VR pane. mathjax has its quirks. There are subtle differences between mathjax and LaTeX. In particular, it appears best to use mathjax 2 rather than 3. *Summary* The general goal of eliminating friction produced a surprise. mathjax, not LaTeX, is a better fit for Leo. The PR creates a friction-free environment for doing mathematics in Leo. Edward P.S. Some details: *Problems using pdf files.* math.leo contains @button render-latex. This script assumes that c.p.b contains *LaTeX* code. The script: - Converts c.p.b to a pdf file whose name is a sanitized version of c.p.h. - Searches the outline for a corresponding @pdf node, creating the node if necessary. The body text of this node contains the full path to the generated pdf file. The PR adds support for @pdf nodes. Selecting the node will render the named pdf file. Alas, @pdf doesn't work well enough. Qt *does* render the pdf file, but there is no way to set a default magnification of the rendered text! This defect quickly becomes intolerable. Furthermore, using two separate nodes is way too clumsy. *About the QWebEngineView class* The revised VR plugin uses the QWebEngineView <https://doc.qt.io/qt-6/qwebengineview.html> class for all html-related nodes. This class is a wrapper around the Chromium <https://www.chromium.org/Home/> open-source browser. This browser should have enough firepower. Alas, Qt's support for pdf files uses a *hidden pdf plugin*. This plugin is *inaccessible* via any programming API. Hours of googling and experimentation failed to find any access points. *Interference from GE Force Experience* The VR3 plugin raises a bizarre warning on my machine. With the revised VR plugin, I got the same warning! This message originates from the GE Force Experience package, a part of the NVidia video driver. Somehow, instantiating the QWebEngineView class triggered a notification from the NVidia package! Turning off the notification eliminated the message. The NVidia package is obsolete, so I removed it. *Hangs on Exit* Earlier versions of the PR could hang when Leo shut down. As a workaround, the PR deletes all known objects related to the QWebEngineView class. Leo no longer hangs since I removed the GE Force experience package. In any case, the bug appears to have been caused outside of Leo and the VR plugin. EKR -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/leo-editor/febff5a1-bad7-477f-9d65-41052614edf4n%40googlegroups.com.
