DrawFormula
Text, Formula layout, Vector graphics
Description
Draws a mathematical formula using the current font, text size, text color, glyph fallback settings, and vector rules
Syntax
Delphi
Function TPDFlib.DrawFormula(Left, Top: Double; Const Formula, AltText: WideString): Integer;ActiveX
Function PDFlib::DrawFormula(Left As Double, Top As Double, Formula As String, AltText As String) As LongDLL
int DLDrawFormula(int InstanceID, double Left, double Top, const wchar_t* Formula, const wchar_t* AltText);
int DLDrawFormulaA(int InstanceID, double Left, double Top, const char* Formula, const char* AltText);Parameters
| Left | Horizontal position of the formula bounding box |
|---|---|
| Top | Top edge of the formula bounding box |
| Formula | Formula source in the supported mathematical markup |
| AltText | Accessible spoken description used when automatic tagging opens a Formula structure element |
Return values
Returns 1 after drawing, or 0 when Formula is empty
Remarks
Spacing, boxes, and styles
Mathematical spaces \,, \:, and \; advance by 3, 4, and 5 eighteenth-em units, while \! moves back by 3 such units; \quad and \qquad reserve one and two ems without drawing space glyphs
Use \hspace{1em}, \kern-2pt, or \mkern{3mu} for explicit spacing; supported units are pt, em, ex, and mu, with one ex approximated as 0.45 em and one mu as 1/18 em, and each finite numeric magnitude limited to 10,000 units; unsupported or nonfinite dimensions contribute zero
\rule[-2pt]{12pt}{3pt} draws a rule with an optional baseline shift, width, and thickness; \raisebox{2pt}{x} shifts an expression and updates its vertical metrics, while \vcenter{expression} centers its vertical extent on the mathematical axis
\smash{expression} paints content without its vertical extent, and optional [t] or [b] suppresses only its ascent or descent; \mathllap, \mathclap, and \mathrlap paint leftward, centered, or rightward with zero advance, so smashed and overlapping content may intentionally extend beyond its reported layout box
\strut is an invisible zero-width vertical placeholder with 0.7 em ascent and 0.3 em descent; \displaystyle, \textstyle, \scriptstyle, and \scriptscriptstyle apply within the current group, with script sizes of 0.68 and 0.5 times the base font size
\dfrac and \dbinom force full-size operands, while \tfrac and \tbinom use compact text-style operands, including inside superscripts; \cfrac[l]{a}{b} and optional [r] provide full-size continued fractions with left- or right-aligned numerators, and the default numerator alignment is centered
Arrays and equations
\begin{array}{lcr}a&b&c\\long&long&long\end{array} aligns each column independently to the left, center, or right; vertical bars in the specification, such as {l|r}, add grid separators, with up to two bars at each boundary
aligned environments right-align the first, third, and subsequent expression columns and left-align each following relation column; smallmatrix uses smaller text and reduced gaps for inline matrices, and \subarray{l}{first\\second} provides compact multiline annotations with l, c, or r alignment
An optional dimension after a row separator, such as \\[3pt], adds nonnegative spacing after that row; matrix layout is bounded to 4,096 grid cells, and nested expression parsing is bounded to 64 levels
Scripts and operators
Consecutive apostrophes in f''_x become superscript primes and can coexist with subscripts; \prescript{14}{6}{C} places superscripts and subscripts to the left of a base, and \mathop{expression}\limits_{i}^{n} gives a custom operator centered limits
\not= or \not\in overlays a negation stroke without changing advance; \underleftarrow, \underrightarrow, and \underleftrightarrow add directional arrows below an expression
\left(a\middle|\frac{b}{c}\right) stretches middle delimiters to the enclosing group's height; group-scoped infix forms {a\over b}, {a\atop b}, and {n\choose k} produce ruled, unruled, and parenthesized fractions without consuming the following group
An unescaped % starts a source comment through the end of that line; \% remains visible, and \text{...} groups retain literal percentages
Additional layout commands include \boxed{expression}, invisible \phantom, \hphantom, and \vphantom placeholders, and \cancel, \bcancel, and \xcancel cancellation strokes
Use \overset{annotation}{base}, \underset{annotation}{base}, or \stackrel{annotation}{base} for centered annotations, and \substack{first\\second} for compact multiline limit text
Modular expressions accept \pmod{n}, \mod{n}, and binary \bmod; text in \text{...} and \operatorname{...} groups retains literal underscores and escaped punctuation rather than interpreting them as mathematical scripts, while \operatorname*{...} enables above-and-below limits
\genfrac{left}{right}{thickness}{style}{numerator}{denominator} supports optional delimiters, a nonnegative finite rule thickness in points or em units, and styles 0 through 3 for display, text, script, and smaller script sizing; an empty thickness selects the normal rule and 0pt omits it, while unsupported thickness values retain the normal rule
Explicit delimiter commands \big, \Big, \bigg, and \Bigg and their left, right, and middle variants reserve progressively larger delimiter geometry independently of neighboring content
Use \frac{a}{b} for fractions, x^{2} and x_{i} for scripts, \sqrt{x} or \sqrt[3]{x} for radicals, and commands such as \alpha, \Gamma, \times, \sum, and \infty for symbols
Groups can be nested and repeated measurement or drawing reuses the parsed layout while the font state remains unchanged
The DLL DLDrawFormulaA variant accepts text according to the configured ANSI mode