Formula Master
Scientific documents are where open source tools show their greatest strengths. To save yourself a lot of trouble, however, you need to know how to combine formulas and data into your work. Linux provides the appropriate tools.
Scientific documents are where open source tools show their greatest strengths. To save yourself a lot of trouble, however, you need to know how to combine formulas and data into your work. Linux provides the appropriate tools.
Whether you're working on a thesis, post-doctoral article, or just school homework, you're going to need specialized office software that simplifies the input of formulas or for creating schematics. LaTeX has a good reputation in that area; but, despite its strengths, its complexity often prevents it from being the best choice.
A scientific document, apart from text, often includes mathematical equations, chemical formulas, and experimental schematics. Each component has its corresponding program – that, and the underlying software to edit the text. The underlying software is the core part of the modules responsible for writing scientific documents. I'll describe three different solutions that additionally allow application of math formulas.
The Open/LibreOffice duo is similar in concept to Microsoft Office and is, to a large extent, compatible with the latter, although it does have a few migration problems. The downside of creating a scientific document in Open/LibreOffice, or even in MS Office, is the instability that comes from the large number of files required. The upside of these kinds of programs is that you can build a document without concerning yourself with the file structure.
LyX, on the other hand, is a program that tries to steer a middle course between TeX and a WYSIWYG text editor (LyX actually calls itself "WYSISWYM" – What You See Is What You Mean). What you see on the screen is close to what you'll print out. With the LaTeX typesetting system, however, the end result is usually a bit different. If you want to see how things will look, it's best to use preview mode.
LyX files usually contain only text, and you can build in equations and formulas through links in the text. Thus, the files are typically small TeX files, and the software is very stable. LyX also lets you create a document with mouse clicks. This approach might require some troubleshooting skills, for example, if the software doesn't recognize certain forms because you set a specific class for the document. The structure is based on your specific purpose and is echoed in the format structure.
Finally, Kile makes up the trio of applications I'll cover. Kile is a plain-text editor that nevertheless works with TeX functions. You set the document structure by using entries in the menu. The result is ASCII text with the corresponding TeX macros. Unfortunately, the screen output won't reflect this clearly unless you have an exceptionally visual imagination.
Calculating the preview is standard work for TeX editors. In many cases, it occurs at least once per printed page. The advantage of this approach is a document that all TeX-based systems understand, so you're safe in regard to the software when creating a document with Kile.
All three programs can manage math formulas with no problem. Creating chemical formulas, however, is another story. Open/LibreOffice can handle diagrams of experimental setups reasonably well, but LyX and Kile provide no options in that department.
The formula editors for math symbols use either the WYSIWYG or text concept. The Open/LibreOffice editor uses WYSIWYG: You select the elements by clicking on them in the palette. The formula text then appears in the lower window, where you can enter it directly (Figure 1).
This method has the advantage that even inexperienced users can get the job done quickly. The Office suite authors, however, missed the chance of providing a learning path to the often irreplaceable TeX: The formula text syntax isn't compatible with that of LaTeX.
LyX provides an almost pure WYSIWYG concept (Figure 2). You typically assemble a math expression from the selection of formulas. At the same time, you can also open a text window with the corresponding LaTeX output by selecting View | View Source from the menu.
This view lets you enter elements of the expression directly as text (Figure 3), which is especially important if the item isn't available as a selection but is in the form of a LaTeX expression. In earlier LyX versions, this was especially true of the many real numbers (\mathbb R). Immediately after you enter an expression, you see the result in the window and the editor returns to WYSIWYG mode.
Kile developers gave their product a completely different twist. The program doesn't accept any macro entries, which also applies to math expressions. However, if you install KLatexFormula alongside Kile, you can see the result as a control right away. When you hover over the text section with the math expression, you'll see the corresponding formula (Figure 4).
Clicking a link below the window opens KLaTeXFormula (Figure 5). In the upper window, you see the LaTeX text; in the lower window, you see the rendered version. KLaTeXFormula allows you to assemble math expressions with a mouse click. Unfortunately, this process isn't as easy as LyX or Open/LibreOffice. After creating the expression, you can copy the text from the upper window into Kile and integrate it with the TeX document. KLaTexFormula also lets you save the rendered expression as an image in various formats. You can then use the image in other text-processing tools.
Surpassing KLaTexFormula in ease of use is EqualX. This program lets you assemble a math expression as easily as using text entry in the lower window and has a clearly arranged library of standard symbols from different scientific fields (Figure 6). You can save the result either as an image or TeX file.
EqualX creates a file when saving that contains the actual expression next to the rendered image so that you can change the expression easily – an essential factor with complex expressions. EqualX documentation is unfortunately sparse, and the current version 0.5.1 won't let you change the predefined libraries.
Formulator is another math expression editor that creates not only images but also MathML code if you wish. It's available in two versions: a paid version and a free version, which you can use in noncommercial environments. The program also allows entry of expressions as text, albeit in MathML syntax, as you can see in the upper right window of Figure 7.
Because TeX lacks an interface, Formulator is especially useful for those wanting to generate MathML code. However, MathML code is less used in printed documents than on the web. Comparing a test quadratic equation in the three formula languages from Open/LibreOffice (Listing 1), LaTeX (Listing 2), and MathML (Listing 3) shows that the code in Open/LibreOffice and LaTeX is much easier to decipher than in MathML.
Listing 1
Quadratic Expression in Open/LibreOffice
x^2+p*x+q=0 dlrarrow x_{1,2}=-{p over 2} plusminus sqrt{{p^2} over 4 -q}
Listing 2
Quadratic Expression in LaTeX
x^2+p*x+q=0\Leftrightarrow x_{1,2}=-\frac{p}{2}\pm\sqrt{\frac{p^2}{4}-q}
Listing 3
Quadratic Expression in MathML
01 <math display = ,block'> 02 <mrow> 03 <msup> 04 <mi>x</mi> 05 <mn>2</mn> 06 </msup> 07 <mo>+</mo> 08 <mi>p</mi> 09 <mo>∗</mo> 10 <mi>x</mi> 11 <mo>+</mo> 12 <mi>q</mi> 13 <mo>=</mo> 14 <mn>0</mn> 15 <mo lspace='3px' rspace='3px'>⇔</mo> 16 <msub> 17 <mi>x</mi> 18 <mn>1,2</mn> 19 </msub> 20 <mo>=</mo> 21 <mo>−</mo> 22 <mfrac> 23 <mi>p</mi> 24 <mn>2</mn> 25 </mfrac> 26 <mo lspace='2px' rspace='2px'>±</ mo> 27 <apply> 28 <msqrt> 29 <mfrac> 30 <msup> 31 <mi>p</mi> 32 <mn>2</mn> 33 </msup> 34 <mn>4</mn> 35 </mfrac> 36 <mo>−</mo> 37 <mi>q</mi> 38 </msqrt> 39 </apply> 40 </mrow> 41</math>
Writing simple math formulas is easy enough with the aforementioned editors; however, chemical structure formulas are another story. GChemPaint proves suitable here because of its ease of use and extensive library of molecular models. Figure 8 shows a furan structural model developed in 10 steps:
Select the binding to set its strength.
10.Click the binding that should appear as a double bond.
Having the software automatically create the molecular bonds is especially useful when adding atoms to the structure. That also applies to the valences of the added atoms. Plus and minus signs appear for atoms whose bonds aren't saturated. You can add complex molecules from the extensive library (Figure 9) and modify them as desired.
A number of standard chemical formats are available for saving your work, including ChemDraw files, Brookhaven molecular formats, MDL format, and GChemPaint's native format. If you want to use the images in a text document, you can export to PNG and SVG, among others.
Almost all articles on a science topics include schematics or circuit diagrams in addition to math or chemical formulas.
These schematics are best produced in vector graphics software that has the correct symbols. Open/LibreOffice, by the way, does have a program to create schematics but doesn't provide symbols.
In terms of symbols for electrical circuits, you can always reference the Wikipedia library [11], which has a library in SVG vector format that is ready to use and is suitable for Dia, Inkscape, and other programs.
Xfig unfortunately does not understand SVG files, but it does have its own comprehensive library.
In my tests, the task was to create a sketch of a simple circuit with voltage sources. All the symbols were available from the Wikipedia library except the ones for voltage and current meters. However, you can import these with the Draw module. Creating a symbol for the voltage meter and current is simple enough with onboard resources by drawing a circle with the appropriate letter inside it.
The program provides a tool for linking the symbols. By selecting it, you can add it to the circuit diagram at every connection point, and it will automatically create a right-angle polygon connector. Unfortunately, the symbols do not always connect the way you might like in the circuit and you may end up with gaps.
Unlike Draw, Dia already has an extensive library that you can add to. With Dia, you can create a schematic with a few mouse clicks. In Figure 10, you can see the symbols for voltage and current meters as SVG files that were imported into the circuit diagram library.
Also unlike Draw, Dia presents no problem connecting the symbols. The result is a clean schematic that you can easily add to any document by saving it as a Dia file or exporting it as an SVG or PNG file.
Inkscape, like Dia, belongs to the vector drawing programs that save files in SVG format, making it easy to import circuit symbols from the Wikipedia library.
If necessary, you can rotate the symbols into position and resize them. The lack of a library, however, makes Inkscape not very suitable only for this purpose, because the work is rather time-consuming.
Importing the elements we need into Xfig is no problem whatsoever. You can draw missing elements and copy them to the corresponding /usr/share/xfig/Libraries path so that they're available to the appropriate library. Xfig does not have a connecting tool, however.
As with Draw and Inkscape, you can manually use the polyline tool. Another drawback of Xfig is its completely outdated design that sets it apart from all other you may have encountered applications. It's not unusable, just unfamiliar.
You can create scientific documents with Open/LibreOffice, LyX, and Kile with all the necessary components and the results are of excellent quality, especially considering that they all export to PDF. However, only LyX and Kile write actual TeX documents. The choice of complementary programs then comes down to the choice of a text editor.
If you're set on using Open/LibreOffice, math formulas are possible through the math program delivered with it. The same goes for LyX with its own editor included in the application. Kile relies fully on generating math expressions in text. If you're looking for a graphics tool for learning, EqualX would make a good choice.There are really no alternatives to GChemPaint for chemical formulas.
Although the Open/LibreOffice modules provide good vector graphics programs, Dia is the prime choice for schematics. No other program makes it easier to create a diagram and convert it to an image file. A particularly valuable functionality is being able to expand the supplied libraries.
As to whether TeX-based software should be used in schools, note that pure TeX software involves a steep learning curve. LyX provides a user interface that resembles familiar office systems, but it's technically a TeX system. Therefore, it rates as an ideal entry point for students. The furthest removed from TeX, but still with good math formula editors, are the two office packages. They are likely the only realistic programs for schools – especially because they include tools for math typesetting and schematics.
Infos