Programmer .NET how to show LaTeX

this article describes several ways to display LaTeX documents in programs .NET. The information is useful primarily to programmers working in the field of education. All it is, tested on their own experience in the development of the Department of mathematics of one of Moscow's leading technical UNIVERSITIES.

Objective

Your software automatically created a lot of scientific documents in LaTeX (as most appropriate for these purposes text format), each document must quickly show the user as a draft. "Automatically" means that the user is not gaining a LaTeX document manually, he may not even know what it is. It is implied that once you have created a final version of the document, it will be either exported to LaTeX-e, or converted to a PDF means installed TeX and printed. Show drafts should be possible without using third-party programs and faster, and their correctness is guaranteed. The size of the documents does not exceed a few sheets of A4, the number of formulas moderate.

It would seem, if still at the end of the document will print, which is impossible without installation of TeX, what to emphasize independence from TeX-as? This is specifics of the software system, developed by the author.

Solutions

the
    the
  • In a forehead — to compile LaTeX to PDF something-like using TeX, and to show in external viewer
  • the
  • otherwise — to display LaTeX in the browser (ie WebBrowser component) using Integre techexplorer — ActiveX plugin for Internet Explorer
  • the
  • Even trickier to convert LaTeX MathML and show support in the standard browser (i.e. the corresponding component .NET)

What is the best way to choose?

It is possible to present a comparison of methods in the form of a table.

the the the the
Method Benefits Weaknesses
"head"
    the
  • Implementation is very simple — you need to run a La pdflatex, wait for the end of the compilation, and open the resulting document.
  • the
  • Optimum compatibility — LaTeX exactly will be shown as wanted, not as they could.
    the
  • Speed leaves much to be desired. While pdflatex will load your packages until you read the fonts is something else — it takes a long time. On very modern hardware, the compilation lasts 5-10 seconds (MikTeX).
  • an
  • Dependency TeX — you need to put it on every computer where you will use the program. This can be attributed to the dependence of the PDF viewer and the like. If the program professors use on home computers, you have to be very patient and to show detective skills.
Using Integre techexplorer
    the
  • High speed. techexplorer for the first time when you run takes a few seconds, but the initialization can be done during startup of the program itself.
  • the
  • independence from the TeX distribution.
    the
  • will Work so-so. techexplorer has a peculiar concept about LaTeX, for example, requires a Declaration of trigonometric functions using the \define\sin{\operatorname{sin}. All that techexplorer does not understand (actually a lot), it highlights in red.
  • the
  • Implementation is difficult. If techexplorer was better, it was possible to save a LaTeX document to disk and pass the file name in the WebBrowser.Navigate. However, we have to maintain two versions of the same document: "the normal LaTeX" for export and "understand techexplorer-om".
  • the
  • Dependence on techexplorer. However, it is much easier and faster (the msi can be included in the distribution of its own software), security restrictions ActiveX correct a single entry in the registry.
Using MathML
    the
  • High speed, if the document is small. Gecko (the Firefox engine, the only engine itself supports MathML) is experiencing some difficulties when displaying large documents, e.g. scientific articles with lots of formulas, but in our problem the requirements for this were not made.
  • the
  • Full independence from third-party software. Used GeckoFX, wrapper .NET for Gecko. Himself Gecko (xulrunner) you can distribute as part of their program.
    the
  • Compatibility. For many LaTeX constructs necessary to implement analogues to XHTML+MathML, which is not always trivial. Much to latex2mathml.
  • the
  • the complexity of the implementation follows from the previous one.
  • the
  • MathML formally supported by Gecko, but there are very unpleasant features. For example, a full repaint and braking when you change the size of the document.


Inserted below are examples of display LaTeX to PDF in techexplorer and MathML in Mozilla Firefox
the





The quality of the display, obviously the leader PDF, MathML/Firefox and techexplorer your mistakes.

Comparison table of speeds displayed:

the the the the
Method Time (in LaTeX, of 8.5 KB, 130 Strok 101 formula) Time (LaTeX, 1 KB, 30 lines, 11 formulas)
"head" 14 11
techexplorer 3 3
MathML 12 3


In the first case, the document is converted to PDF and then displayed in Adobe Reader. In the second were displayed directly in Internet Explorer. The third was converted to XHTML+MathML displayed in Firefox. Computer configuration: Windows 7 x86, Core 2 Duo T7500, 4GB DDR2. It is seen as slows down the display of MathML in Firefox on relatively large documents.

Subjectively, the first method is the most reliable but slow, the second fast and of poor quality, and the third uses a new technology, which until the end is not established.

As can be seen, each method has its advantages and disadvantages. Until recently, the author uses the techexplorer, but he's already 4 years does not develop, and potentially bring problems in the future. Unfortunately, the dampness latex2mathml to quickly achieve results, and is not a universal solution for all.

This article was provided an overview of the ways to solve the problem quickly display LaTeX in programs .NET. If you are interested in details, I will be glad to explain.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

mSearch: search + filter for MODX Revolution

Emulator data from GNSS receiver NMEA

The game Let's Twist: the Path into the unknown