.. highlightlang:: us .. index:: LaTeX .. index:: Edit=>Insert LaTeX Formula .. _edit-insert-formula: Edit=>Insert LaTeX Formula -------------------------- (`TeX `_ is a typesetting system designed and mostly written by `Donald E. Knuth `_.) This command inserts `LaTeX `_-formulas into the active document page. A formula is typed in text form as follows: .. code-block:: none $$\int_{0}^{\infty} x^2 e^{-x^2} dx = \frac{\sqrt{\pi}}{4}$$ The created formula will be inserted into the document page as a high resolution bitmap (png) with 600 dpi. .. math:: \int_{0}^{\infty} x^2 e^{-x^2} dx = \frac{\sqrt{\pi}}{4} To modify the formula, double-click the bitmap with the mouse. More documtation about Latex can be found here http://www.latex-project.org/. Installation ^^^^^^^^^^^^ .. highlightlang:: none Check if :command:`latex.exe` and :command:`dvipng.exe` are installed on your computer or if they are available on your network:: c:\> dvipng -version This is dvipng 1.9 Copyright 2002-2006 Jan-Ake Larsson dvipng 1.9 kpathsea version 3.3.2 Copyright (C) 2002-2005 Jan-Ake Larsson. There is NO warranty. You may redistribute this software under the terms of the GNU General Public License. For more information about these matters, see the files named COPYING and dvipng.c. c:\> latex -version MiKTeX-pdfTeX 2.7.3235 (1.40.9) (MiKTeX 2.7) Copyright (C) 1982 D. E. Knuth, (C) 1996-2006 Han The Thanh TeX is a trademark of the American Mathematical Society. .. highlightlang:: us If Latex is not installed it is recommended to in install the free Latex distribution MiKTeX (http://www.miktex.org) from Christian Schenk. The setup program can be find here: http://www.miktex.org/2.9/setup. ``dvipng.exe`` is included. There also a portable edition of MikTeX available (http://miktex.org/portable/about). It can be used from a USB stick without administrator privilieges. The path to the installation can be set in the UniPlot command window :ref:`viewcommand-window`). The following commands sets path, where ``j:`` is the drive letter of your USB stick:: * WriteProfileString("Settings", "latex-path", "j:\\miktex\\bin"); Check the set-up:: * _latex_find() j:\miktex\bin\latex.exe j:\miktex\bin\dvipng.exe UniPlot saves temporary files in the user directory of UniPlot. If the path name contains spaces it may cause problems with some TeX distributions. In this case you can specify the name of new existing directory without spaces with the following command:: * WriteProfileString("settings", "latex_temp_path", "c:/temp"); Example ^^^^^^^^^ .. code-block:: none \begin{pmatrix} 4 & 7 \\ 2 & 5 \end{pmatrix} \cdot \begin{pmatrix} x_{1} \\ x_{2} \end{pmatrix} = \begin{pmatrix} 1 \\ 4 \end{pmatrix} .. math:: \begin{pmatrix} 4 & 7 \\ 2 & 5 \end{pmatrix} \cdot \begin{pmatrix} x_{1} \\ x_{2} \end{pmatrix} = \begin{pmatrix} 1 \\ 4 \end{pmatrix} .. code-block:: none You can also write normal text with Latex and include a formula like the following $\sum^{n}_{k=0}\frac{k}{2}$ into the text. You can also write normal text with Latex and include a formula like the following :math:`\sum^{n}_{k=0}\frac{k}{2}` into the text. Notes ^^^^^ * The interface to Latex is written in UniScript. You find the source code in the file :file:`script\\drawing\\latex.ic`. * If you insert or modify a formula for the first time it can take some minutes until the formula is displayed, because `MiKTeX `_ will download packages used in the formula. * Fomulas in Wikipaedia (see for example `FFT `_) are written in Latex. The formulas in this manual are also created using Latex. The formulas in the UniPlot PDF manual (see http://www.uniplot.de/documents/en/download.html) are completely created with Latex. * In this version Latex cannot be used for axes tick labels, axes labels, table cells and dataset. To work around this limitation create a latex formula and replace the element with it. * The UniScript interface contains the following functions (documentation is missing in this version):: hLatex = latex_create() hLatex = latex_create(hLatex) hLatex = latex_create(ssText) ssText = latex_gettext(hLatex) bool = latex_settext(hLatex, ssText) bool = latex_get_rotate90(hImage) bool = latex_set_rotate90(hImage, bRot) bool = latex_check_install(bQuite) bool = latex_destroy(hLatex) * Before the formula is send to Latex the following header is inserted in front of the formula text:: \documentclass[12pt]{article} \usepackage[latin1]{inputenc} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} \usepackage{bm} \newcommand{\mx}[1]{\mathbf{\bm{#1}}} % Matrix command \newcommand{\vc}[1]{\mathbf{\bm{#1}}} % Vector command \newcommand{\T}{\text{T}} % Transpose \pagestyle{empty} \begin{document} The header can be modified using the :ref:`WriteProfileString` function. Example:: ssHeader = "[[ \documentclass[fleqn,12pt]{article} \usepackage[latin1]{inputenc} \usepackage{color} \usepackage{palatino} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} \usepackage{bm} \newcommand{\mx}[1]{\mathbf{\bm{#1}}} % Matrix command \newcommand{\vc}[1]{\mathbf{\bm{#1}}} % Vector command \newcommand{\T}{\text{T}} % Transpose \pagestyle{empty} \begin{document} ]]"; WriteProfileString("Settings", "latex-header", ssHeader) .. seealso:: :ref:`edit`, :ref:`editobject-propertiespicture`, :ref:`@f{latex}` :sub:`id-704693`