# Software for scientific texts

## 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.

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.

#### Limited Scope

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).

Figure 1: Open/LibreOffice is WYSIWYG-based but also allows equivalent text input.

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.

Figure 2: LyX's formula editor is almost exclusively WYSIWYG, but you can also view the LaTeX source text in a lower window.

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.

Figure 3: The LyX formula editor lets you enter LaTeX code for a special symbol.

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).

Figure 4: Kile recognizes the TeX syntax and automatically displays it. You enter the formula as text, and the program immediately shows it.

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.

Figure 5: KLaTeXFormula creates an image of the completed formula from LaTeX code. You put together the LaTeX code with selections; however, functions and operations are not yet integrated.

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.

Figure 6: EqualX lets you easily enter LaTeX code or assemble a formula with predefined elements.

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.

Figure 7: Formulator lets you assemble expressions by using object buttons in the menu, with the upper right part of the window showing the corresponding MathML code.

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

x^2+p*x+q=0 dlrarrow x_{1,2}=-{p over 2} plusminus sqrt{{p^2} over 4 -q}

Listing 2

x^2+p*x+q=0\Leftrightarrow x_{1,2}=-\frac{p}{2}\pm\sqrt{\frac{p^2}{4}-q}

Listing 3

01 <math display = ,block'>
02  <mrow>
03  <msup>
04   <mi>x</mi>
05   <mn>2</mn>
06  </msup>
07  <mo>&plus;</mo>
08  <mi>p</mi>
09  <mo>&lowast;</mo>
10  <mi>x</mi>
11  <mo>&plus;</mo>
12 <mi>q</mi>
13  <mo>=</mo>
14  <mn>0</mn>
15  <mo lspace='3px' rspace='3px'>&hArr;</mo>
16  <msub>
17   <mi>x</mi>
18   <mn>1,2</mn>
19 </msub>
20  <mo>=</mo>
21  <mo>&minus;</mo>
22  <mfrac>
23   <mi>p</mi>
24   <mn>2</mn>
25 </mfrac>
26  <mo lspace='2px' rspace='2px'>&PlusMinus;</      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>&minus;</mo>
37    <mi>q</mi>
38   </msqrt>
39   </apply>
40 </mrow>
41[/itex]

#### Chemical Formulas

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:

1. Click the five-membered ring.
2. Click the drawing surface to set up the molecular structure.
3. Select the hydrogen atom to be assigned.
4. Select the binding element.
5. Click the structure to create the H binding.
6. Select oxygen as the atom.
7. Select the atom as the assigned element.
8. Click the structure to add oxygen.
9. Select the binding to set its strength.

10.Click the binding that should appear as a double bond.

Figure 8: Simple clicking creates the furan molecular structure in 10 steps.

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.

Figure 9: The isoleucine molecule is already available from the GChemPaint library to add to the work surface.

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.

Express-Checkout as PDF

Pages: 7

Price \$0.99
(incl. VAT)