DADiSP Worksheet Functions > Function Categories > Annotation > TEX

 

TEX

Purpose:

Support for a subset of TeX math and Greek symbol formatting.

Remarks:

DADiSP supports a subset of TeX math and Greek symbol formatting commands for graphical annotation. For example:

 

 

W1: 1..100;text(10,80,"e^{j\omegat} = \cos(\omegat) + j\sin(\omegat)")

 

 

 

places the expression for Euler's Formula in W1. TeX commands can be used in text functions, plot labels and units including LABEL, SETXLABEL, SETYLABEL, or TEXT.

 

The \ (backslash) character introduces a TeX character or command and {} are used to delimit TeX expressions and specify TeX function arguments.

 

TeX statements can be optionally delimited with the $ character. This is known as the TeX inline form. For example:

 

 

W1: 1..100;text(10,80,"$e^{j\omegat} = \cos(\omegat) + j\sin(\omegat)$")

 

 

Text between the $ is assumed to be valid TeX expressions and the font is automatically set to italics. Additional math expression formatting is also performed for inline TeX expressions.

 

TeX processing can be enabled or disabled with the TEX_PROCESSING configuration parameter. For example,

 

setconfig("TEX_PROCESSING", 0)

 

disables TeX processing,

 

setconfig("TEX_PROCESSING", 1)

 

enables TeX processing and

 

setconfig("TEX_PROCESSING", 2)

 

enables TeX processing for inline expressions only.

 

 

The following sections summarize the current TeX support. Each of the examples are in inline form and placed in a blank Window created by the formula:

 

  {0};lines;scalesoff

 

 

Greek Letters

 

Greek letters are specified with the \ followed by the name of the letter.

 

\alpha

α

\sigma

σ

\beta

β

\varsigma

ς

\gamma

γ

\tau

τ

\delta

δ

\upsilon

υ

\epsilon

ε

\phi

Φ

\zeta

ζ

\varphi

φ

\eta

η

\chi

χ

\vartheta

ϑ

\psi

ψ

\iota

ι

\varpi

ϖ

\kappa

κ

\rho

ρ

\lambda

λ

\theta

θ

\mu

μ

\pi

π

\nu

ν

\omega

ω

\xi

ξ

 

 

\o

ο

 

 

 

 

The first letter of each expression can be capitalized to obtain the upper case letter:

 

\Alpha

Α

\Xi

Ξ

\Beta

Β

\O

Ο

\Gamma

Γ

\Sigma

Σ

\Delta

Δ

\Tau

Τ

\Epsilon

Ε

\Upsilon

Υ

\Zeta

Ζ

\Phi

Φ

\Eta

Η

\Chi

Χ

\Iota

Ι

\Psi

Ψ

\Kappa

Κ

\Rho

Ρ

\Lambda

Λ

\Theta

Τ

\Mu

Μ

\Pi

Π

\Nu

Ν

\Omega

Ω

 

Examples:

text(0.3, 0.3, "$\alpha$ and $\Omega$");

text(0.3, 0.0, "$\nu = c / \lambda$");

text(0.3, -0.3, "$y(t) = \cos(2\pift + \theta)$");

 

 

 

Symbols

 

Symbols are specified with the \ followed by the symbol name. Below is a non-exhaustive list of supported symbols. Other TeX symbols may also be available.

 

 

\leftrightarrow

\Leftrightarrow

\hookleftarrow

\diamondsuit

\rightarrow

\Rightarrow

\backslash

\

\copyright

©

\downarrow

\Downarrow

\heartsuit

\leftarrow

\Leftarrow

\spadesuit

\clubsuit

\subseteq

\Diamond

\partial

\uparrow

\Uparrow

\Upsilon

ϒ

\approx

\bullet

"

\exists

\forall

\langle

<

\lbrace

{

\lfloor

\oslash

ø

\otimes

\propto

\rangle

>

\rbrace

}

\rfloor

\subset

\supset

\aleph

\angle

\cdot

·

\circ

º

\cong

\equiv

\gets

\infty

\land

\lceil

\ldots

...

\lnot

¬

\nabla

\not=

\notin

\oplus

\owns

\prep

\prime

\prod

\rceil

\surd

\times

x

\wedge

\Box

\cap

\cup

\div

÷

\geq

\int

\leq

\lor

\mid

\neg

\neq

\sum

\vee

\ge

\im

\Im

\in

\le

\ne

\ni

\pm

±

\re

\Re

\to

\ul

_

\wp

Examples:

text(0.3,  0.3, "$f(x \to \infty) \approx 0$");

text(0.3,  0.0, "$\nabla \times E = -\partialB/\partialt$");

text(0.3, -0.3, "$\angleH(\omega) = 2\cdot\pi$");

text(0.3, -0.6, "$\forall x \in X, \quad \exists y \leq \epsilon$");

 

 

 

Superscript and Subscript

 

The ^ (caret) introduces a superscript character and the _ (underscore) introduces a subscript character. Use {} to mark an entire expression as a superscript or subscript.

 

 

^

superscript

_

subscript

 

 

Examples:

text(0.3,  0.3, "$E = mc^2$");

text(0.3,  0.0, "$P(x) = a_0 + a_1x + a_2x^2 + a_3x^3$");

text(0.3, -0.3, "$\alpha^{\lambda_0 + \lambda_1}$");

text(0.3, -0.6, "$f(n) = n^5 + 4n^2 + 2 |_{n=17}$");

 

 

 

Operators

 

An operator is a function displayed in normal text. Examples of operators include trigonometric functions, logarithms and exponentials. The  \ character introduces the operator. Any text expression can be displayed as an operator with \operatorname{expression}.

 

Examples:

text(0.3,  0.3, "$\cos(2\theta) = \cos^2\theta - \sin^2\theta$");

text(0.3,  0.0, "$\lim_{x \to \infty} \exp(-x) = 0$");

text(0.3, -0.3, "$\log_2(1024)=10$");

text(0.3, -0.6, "$\operatorname{b}(S)\leq\alpha\operatorname{c}(S)$");

 

 

 

Fractions

 

The \frac keyword introduces a fraction and \tfrac produces a fraction in a smaller font size. The numerator and denominator expressions are enclosed in {}. The fraction is drawn vertically, with a single horizontal line separating the numerator and denominator.

 

\frac{num}{den}

num / den

 

The \nfrac keyword introduces a fraction without a dividing line.

Examples:

text(0.3,  0.6, "$\frac{1}{2}$ $\tfrac{1}{2}$");

text(0.3,  0.3, "$\frac{a^2 + b^2}{a^2 - b^2}$");

text(0.3, -0.2, "$\frac{\frac{1}{x} + \frac{1}{y}}{x+y}$");

text(0.3, -0.6, "$\Phi_x(\omega) \equiv \frac{|X(e^{j\omega})|^2}{\pi}$");

 

 

 

Square Roots

 

The \sqrt keyword introduces the square root of an expression. An optional radical is enclosed in []. The expression is enclosed in {}.

 

Examples:

text(0.3,  0.6, "$\sqrt{\pi}$");

text(0.3,  0.3, "$r = \sqrt{x^2 + y^2}$");

text(0.3,  0.0, "$\sqrt[3]{\frac{a}{b}}$");

text(0.3, -0.4, "$f(x) = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$");

 

 

 

Summation, Integrals and Limits

 

The \sum, \prod and \int keywords introduce summations, products and integrals with limits specified by _ (underscore) and ^ (caret).

 

The \smallint, \tinyint, \smallsum and \tinysum keywords introduce smaller summations and integrals.

 

The \iint, \iiint, \oint, \oiint and \oiiint keywords introduce double, triple and closed loop integrals

 

Examples:

text(0.3,  0.6, "$e = \sum_{n=0}^{\infty}\frac{1}{n!}$");

text(0.3,  0.2, "$\int_0^\infty e^{-x}dx$");

text(0.3, -0.2, "$\int_0^\infty \frac{\sin(t)}{t}dt = \frac{\pi}{2}$");

text(0.3, -0.6, "$X[k] = \sum_{n=0}^{N-1}x[n]e^{\frac{-2\pi j k n}{N}}$");

 

Examples:

text(0.3,  0.6, "$\smallint_0^\infty xdx$");

text(0.3,  0.2, "$\tinyint_0^\infty xdx$");

text(0.3, -0.2, "$\iint_S uvdudv$");

text(0.3, -0.6, "$\oint_U udu$");

 

 

 

Groupings

 

The \left, \middle and \right keywords are used with delimiters to provide automatically sized groupings. The {} delimiters are specified with \{ and \} and an empty delimiter is specified with a . (period).

 

Examples:

text(0.3,  0.6, "$\left(\frac{x^2}{y^3}\right)$");

text(0.3,  0.2, "$P\left[A=2\middle|\frac{A^2}{B}>4\right]$");

text(0.3, -0.2, "$\left\{\frac{x^2}{y^3}\right\}$");

text(0.3, -0.6, "$\left.\frac{x^3}{3}\right|_0^1$");

 

 

 

Spacing

 

Inline TeX expressions are spaced automatically and whitespace is normally ignored, however a number of keywords provide manual spacing. The \quad keyword inserts a space equal to the current font size and \qquad inserts twice the space. The \ followed by a space (\ ) also inserts a space. In addition, the following keywords provide finer spacing control:

 

\,

small space

 3/18 quad

\:

medium space

 4/18 quad

\;

large space

 5/18 quad

\!

negative space

-3/18 quad

 

Multiple spacing commands can be used in sequence to yield more or less space as desired.

Examples:

text(0.3,  0.7, "$ab$");

text(0.3,  0.5, "$a\quadb$");

text(0.3,  0.3, "$a\,b$");

text(0.3,  0.1, "$a\:b$");

text(0.3, -0.1, "$a\!b$");

text(0.3, -0.4, "$\int y\: dx$");

text(0.3, -0.7, "$u = \tfrac{1}{\sqrt{2}}(x+y) \qquad x = \tfrac{1}{\sqrt{2}}(u+v)$");

 

 

 

Accents

 

Accent keywords precede the letter to accent. Certain accents also support shortcut forms:

 

\acute a

\'a

 

\bar a

\=a

 

\breve a

 

 

\dddot a

 

\ddot a

\"a

\dot a

\.a

\grave a

\`a

\hat a

\^a

\tilde a

\~a

\vec a

 

 

\overline {abc}

 

Examples:

text(0.3,  0.6, "$\hat\sigma_{\beta_0}=\hat\sigma_{\epsilon} \sqrt{\frac{1}{n} + \frac{\bar{x}^2}{\sum(x_i-\bar x)^2}}$");

text(0.3,  0.0, "$Z = \frac{\overline{BMI}-\mu}{\sqrt{\frac{\sigma^2}{N}}}$");

text(0.3, -0.6, "$\mathbf{\vec{a}}\mathbf{F}_\bot = -m \omega^2 R \bold{\hat{e}}_r= -\omega^2 \mathbf{m}$");

 

 

 

Unicode and Arbitrary Characters

 

The \char and \symbol keywords insert a single character represented by a character code in decimal, hex, octal or character format.

 

\char77

decimal

 M

\char"4D

hex

 M

\char'115

octal

 M

\char'\M

character

 M

 

The character code can also be placed in {}, so \char{"4D} and \char"4D are equivalent and both produce the character M. The \char keyword renders the character with the inline font while \symbol renders the character with the symbol font. Unicode character codes are supported.

Examples:

text(0.3,  0.5, "$\char65$");

text(0.4,  0.5, '$\char"41$');

text(0.5,  0.5, "$\char'101$");

text(0.6,  0.5, '$\char{"41}$');

text(0.3,  0.1, "$\char12371\char12435\char12395\char12385\char12399$");

text(0.5,  0.1, "$\char24744\char22909$");

text(0.3, -0.1, "$\char1055\char1088\char1080\char1074\char1077\char1090$");

text(0.5, -0.1, "$\char1501\char1493\char1500\char1513$");

text(0.3, -0.3, "$\char1575\char1576\char1581\char1585\char1605$");

text(0.5, -0.3, "$\char3626\char3623\char3633\char3626\char3604\char3637$");

text(0.3, -0.5, "$\char1330\char1377\char1408\char1381\char1410\;\char1345\char1381\char1382$");

text(0.5, -0.5, "$\char4306\char4304\char4315\char4304\char4320\char4335\char4317\char4305\char4304$");

text(0.4, -0.7, "$Hello\ from\ \TeX$");

 

 

 

Evaluation

 

The \eval keyword evaluates an expression in {} and returns the result as text. Any valid DADiSP expression can be evaluated though not all valid expressions can be converted to text.

 

Examples:

W1 := 1..100;

text(w1,  5.0, 100.0, "$\sum_{n=1}^{\eval{length}}x[n]=\eval{sum}$");

text(w1,  5.0,  70.0, "$\bar{x}=\frac{1}{\eval{length}}\sum_{n=1}^{\eval{length}}x[n]=\eval{mean}$");

text(w1, 35.0,  15.0, "$\sqrt{\frac{1}{\eval{length}-1}\sum_{i=1}^{\eval{length}}(x_i-\bar{x})^2}=\eval{stdev}$");

text(w1,  3.0, -15.0, "The value of $\pi^{\frac{1}{3}} = \sqrt[3]{\eval{pi}} = \eval{pi^(1/3)}$ approximately");

 

 

 

More Examples

 

Although only a subset of TeX formatting is supported, a wide variety of mathematical expressions and equations can be rendered. Below are additional examples of TeX formatted annotations.

 

Examples:

text(0.3,  0.6, "$\left[-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V \right]\Psi=i\hbar\frac{\partial}{\partialt}\Psi$");

text(0.3,  0.2, "$e = \lim_{n \to \infty}\left(1 + \frac{1}{n}\right)^n = \sum_{n=0}^\infty\frac{1}{n!}$");

text(0.3, -0.2, "$\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^xe^{-t^2}dt$");

text(0.3, -0.6, "$\phi_n(\kappa)=0.033C_n^2\kappa^{-11/3},\quad\frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}$");

 

 

 

Font Modification

 

Font modifiers alter the color, angle, typeface and size of the current TeX string or sub-string. Modifier arguments are enclosed in {}. The modifier can be applied to a sub-string by enclosing the sub-string in {}.

 

 

\fontangle{angle}

Text angle

\textcolor{color}

Text foreground color

\colorbox{color}

Text background color

\fontname{name}

Font type name

\fontsize{size}

Font size in pixels if > 0, else size in points

\color{color}

Text foreground color

\tex{mode}

Inline TeX processing, 0:disabled 1:enabled

\mathbf

Bold, non-italic font

\mathit

Italics font

\mathrm

Normal font

\mathtt

Courier font

\bf

Bold font

\it

Italics font

\rm

Normal font

\tt

Courier font

 

Examples:

 

text(0.1,  0.8, "This is $\it{italics}$ and this is $\bf{bold}$")

text(0.1,  0.4, "This is $\color{lred}{red}$ and $\color{green}{green}$.")

text(0.1,  0.0, "This is $\fontsize{32}{big}$ and $\fontsize{12}{small}$.")

text(0.1, -0.4, "$\colorbox{yellow}{F(\sigma) = e^{\frac{\sigma^2}{2\pi}}}$")

text(0.1, -0.8, "Raw Units: $\tex{0}V^2\tex{1}$, TeX Units: $V^2$")

 

 

image\texmodpic.gif

 

 

Configuration Parameters

 

Several configuration parameters control the details of TeX string processing. These parameters can be set permanently in the dadisp.cnf configuration file or set dynamically with the SETCONF function.

 

 

Parameter Name

Function

Default

tex_processing

Enable or disable TeX processing

1: enabled

tex_super_factor

Relative supercript size

0.75: 75% character height

tex_sub_factor

Relative subscript size

0.75: 75% character height

tex_symbolfont

Font for Greek letters and symbols

"Symbol"

tex_courierfont

Font for \tt command

"Courier New"

tex_inline_font

Font for $ $ inline text

2: italics

See Also:

LABEL

SETXLABEL, SETYLABEL

TEXT

 

References:

Donald E. Knuth

The TeXbook

Addison Wesley, 1986.

 

The TeX Users Group: www.tug.org