Tex Equation Editor

This dialog is activated by selecting the Add Equation... command from the Graph menu. It can be used in order to add LaTeX formatted equations to a 2D plot layer.

Text Tab

Figure 5-217. The Tex Equation Editor: using a rendering web service.

The markup equations are rendered using one of the following third party tools: CodeCogs, a web service which requires a working internet connection, a locally installed LaTeX compiler or a built-in LateX parser, JKQTMathText.

The parsing web service, as well as the JKQTMathText parser, support only a limited subset of LaTeX instructions. Please note that JKQTMathText accepts multi-line equations, see the example bellow:

$\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x)\right]$\\
$\mathrm{i}\hbar\frac{\partial}{\partial t}\Psi(x)$

Figure 5-218. The Tex Equation Editor: using the built-in LaTeX parser.

The generation method using a local compiler allows for compilation of complete LaTeX documents and not just of equation markup, so that you can fully customize the image output in terms of font size, text color and background color.

Figure 5-219. The Tex Equation Editor: compilation of complete LaTeX documents.

When using a locally installed LaTeX compiler there's no need to enter document/equation environment commands since QtiPlot automatically creates a temporary file which contains either the following hard-coded preamble:

\PassOptionsToPackage{usenames, dvipsnames}{xcolor}

or a custom preamble that is read from a user defined file path (since one might want to use particular LaTeX packages). The preamble can be edited using the controls from the LaTeX Preamble tab.

The paths for both the LaTeX compiler and the custom preamble file can be set via the File Locations tab of the Preferences dialog.

After the preamble, the following code is appended to the temporary .tex file:

$text in the editor window$

The colorName can be any of the 19 predefined colors available in LaTeX: black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow. It is also possible to use the 68 standard colors known to dvips, since the automatically added preamble includes the xcolor package.

The Font list box can be used in order to select a size different of the default option (Normal, which corresponds to the LaTeX \normalsize command). In this case QtiPlot automatically adds a font size instruction to the temporary .tex file. The sizes available in the Font list box are: Tiny (\tiny), Small (\small), Normal (\normalsize), large (\large), Large (\Large), LARGE (\LARGE), huge (\huge) and Huge (\Huge).

The font sizes in points corresponding to the above size instructions can be customized in the preamble file using, for example, the code bellow:


The Format list box can be used in order to select the format of the output image resulting after the compilation process. The default option is DVI -> SVG (dvisvgm process). When selected, the DVI file created by the local LaTeX compiler is converted to a SVG temporary image using the dvisvgm tool, which needs to be installed on your computer in the same folder as the LaTeX compiler. This option has the great advantage that the equations are rendered as vectorial images, resulting in a very good quality of the images you obtain when exporting 2D graphics.

Since the results provided by this method are not always perfect, a complementary method is provided: DVI -> PNG (dvipng process), which uses dvipng in order to create a PNG output image. This option has the draw-back of a bad image quality (rasterization) when exporting the 2D graphics to a vectorial image format file.

The third method available, PDF -> SVG (pdflatex + dvisvgm process), is the one that seems to provide the best rendering results. It uses the pdflatex compiler, which must be installed on your computer in the same folder as the default LaTeX compiler, in order to create a temporary PDF file. This file is afterwards converted to SVG, using dvisvgm, and is finaly rendered to screen as a vectorial image.

The Preview check box can be used in order to enable or disable the visualisation of the rendered equation inside this dialog.

Frame Tab

This tab is used to define the shape, color, line style and thickness for the frame of an equation object. By default, an equation has a black rectangle frame, the Shape being set to Rectangle.

The changes can be applied to the selected equation, to all equations in the plot layer, to all equation in the active window or to all equation objects from all plot windows, depending on the selection in the Apply to... box.

It is also possible to define the current frame options as a default style for the frame of all future equations by pressing the Set As Default button.

Geometry Tab

The Geometry tab is used to specify the position and the dimensions of the equation object. The coordinates can be set as a function of the scale values displayed on the left (Y) and bottom (X) axes, or in pixels, by choosing the desired method from the Unit pull-down list. Pixel coordinates are relative to the top-left corner of the layer which contains the equation.

LaTeX Preamble Tab

This tab can be used to define a custom LaTeX preamble or to edit the one automatically generated by QtiPlot. It is available only when the LaTeX parser selected in the Text tab is a locally installed LaTeX compiler.

If a custom LaTeX preamble file is defined in the File Locations tab of the user preferences dialog, the path to that file is displayed in the File line, which is read-only, and its content is displayed in the text editor bellow. Otherwise the File line is empty and the hard-coded LaTeX preamble used by QtiPlot is displayed in the text editor panel. In the compilation process QtiPlot uses the text from this editor panel as preamble. If the editor is empty, QtiPlot uses the hard-coded preamble bellow:

\PassOptionsToPackage{usenames, dvipsnames}{xcolor}

The default LaTeX preamble file can be changed using the Open File... button. By pressing the Save As... button, a file dialog pops-up and the content of the text editor panel can be saved to a custom location, which automatically becomes the default LaTeX preamble file. The Clear button removes the path to the LaTeX preamble file from the user preferences. It does not clear the text editor.

Figure 5-220. The Tex Equation Editor: LaTeX preamble tab.