Latex Rendering Functions
[Functions]


Functions

list DrawLatex (scalar x, scalar y, scalar z, string Text, string Name)
 Renders a bitmap from latex code and displays it.
list DrawLatex (multivector P, string Text, string Name)
 Renders a bitmap from latex code and displays it.
void EnableRenderLatex (counter DoEnable)
 Enables or disables the rendering of LaTeX globally.
image GetLatexImg (string sLatex, string sName)
 Returns the image of a rendered latex text.
string Latex (any_type X)
 Creates a string with LaTeX code representing the content of the variable passed.
void SetLatexAlign (scalar X, scalar Y)
 Sets the alignment of a LaTeX bitmap relative to the point where it should be drawn.
void SetLatexMagStep (counter MagStep)
 Sets the LaTeX magnification step.

Detailed Description

Functions that allow you to render latex text as bitmaps, which may then be used as descriptive text or to annotate visualizations. Note that for these functions to work you need to have the following software installed,

  1. LaTeX,
  2. dvips,
  3. Ghostscript.

Under a Linux standard distribution all this software should already be installed. Under Windows you will need to install MikTex from www.miktex.org (or something comparable) and AFPL Ghostscript v8.13 or later from www.ghostscript.com. They both come with an installer for Windows and are easy to install.


Function Documentation

list DrawLatex scalar  x,
scalar  y,
scalar  z,
string  Text,
string  Name
 

Renders a bitmap from latex code and displays it.

Parameters:
x The x-coordinate of the drawing position origin.
y The y-coordinate of the drawing position origin.
z The z-coordinate of the drawing position origin.
Text The LaTeX text.
Name (optional) A name from which a filename is generated to store the rendered LaTeX bitmap.
Returns:
A list containing the actual extend of the rendered bitmap in current coordinates. This list contains six entries. The first three give the x, y and z coordinates of the bottom left corner of the bitmap, and the last three give the x, y and z coordinates of the top right corner of the bitmap. This can, for example, be used to draw two latex bitmaps next to each other.
Since:
v1.4
Attention:
This function needs the programs latex, dvips and ghostscript installed on the system in order to work.
For more details see Latex Text Rendering.

list DrawLatex multivector  P,
string  Text,
string  Name
 

Renders a bitmap from latex code and displays it.

Parameters:
P A vector giving the position of where to draw the LaTeX code.
Text The LaTeX text.
Name (optional) A name from which a filename is generated to store the rendered LaTeX bitmap.
Returns:
A list containing the actual extend of the rendered bitmap in current coordinates. This list contains six entries. The first three give the x, y and z coordinates of the bottom left corner of the bitmap, and the last three give the x, y and z coordinates of the top right corner of the bitmap. This can, for example, be used to draw two latex bitmaps next to each other.
Since:
v1.4
Attention:
This function needs the programs latex, dvips and convert in order to work.
See the other version of DrawLatex() for a detailed description.

void EnableRenderLatex counter  DoEnable  ) 
 

Enables or disables the rendering of LaTeX globally.

Parameters:
DoEnable A boolean flag. If it is 0 then LaTeX rendering is disabled and other enabled.
Since:
v1.4

image GetLatexImg string  sLatex,
string  sName
 

Returns the image of a rendered latex text.

Parameters:
sLatex The LaTeX text.
sName A unique name for this LaTeX text.
Returns:
The image of the rendered LaTeX text.
Since:
v2.2
This function uses the same functionality as DrawLatex(), but instead of drawing the rendered latex text immediately it returns an image object. If you want to use the image for texture mapping, you can achieve a nicer text visualization if you set the latex magnification step (SetLatexMagStep()) to a fairly high value (20 to 30), before calling this function. See Texture Mapping of LaTeX Text for more information and an example.

Note that the current color is used for the rendering of the latex text.

string Latex any_type  X  ) 
 

Creates a string with LaTeX code representing the content of the variable passed.

Parameters:
X Any kind of object.
Since:
v1.4
Attention:
So far only multivectors and matrices are transformed correctly into a string representation.
For example,
    ?M = Matrix(((1,2), (3,4)));
    ?Latex(M);

produces the following output,

    M = (| 1 2|, | 3 4|)
    \left(\begin{array}{cc}
    1 & 2\\
    3 & 4
    \end{array}\right)

void SetLatexAlign scalar  X,
scalar  Y
 

Sets the alignment of a LaTeX bitmap relative to the point where it should be drawn.

Parameters:
X The alignment along the x-direction.
Y The alignment along the y-direction.
Since:
v1.4
If X and Y are both zero (the default), then a rendered LaTeX bitmap is drawn with its bottom left corner at the position given in the DrawLatex() function. If X = 1 and Y = 0, then the bitmap is aligned with its bottom right corner. If X = 0 and Y = 1, then the bitmap is aligned with its top left corner. The parameters X and Y can also take on negative values. If you want to center a bitmap on the point given in DrawLatex(), set X = 0.5 and Y = 0.5.

void SetLatexMagStep counter  MagStep  ) 
 

Sets the LaTeX magnification step.

Parameters:
MagStep The magnification step. This has to be an integer in the range from -50 to +50.
Since:
v1.4
The formula used to evaluate the actual magnification $M$ from the magnification step $S$ is

\[ M = 1.2^{\frac{1}{2}\,S}. \]

These magnification steps are used instead of a completely variable magnification, since then the fonts do not have to be rendered in too many different resolutions. This formula is also the same as used by LaTeX itself.