Skip to main content

Math: Is Latex Formula

Check whether a text contains LaTeX math syntax and output a boolean.

The detector recognizes:

  • Display math $$...$$, including a bare or empty $$ left behind by an extraction pipeline
  • Inline $...$ containing math syntax ($x^2$, $a_b$) or a variable/number/simple equation ($n$, $ R $, $B = -0.3$, $1/8$, $ABS(B)$)
  • \(...\) and \[...\] delimiters
  • \begin{...} for common math environments (equation, align, matrix, cases, …, with or without *)
  • Standalone math commands such as \frac, \sqrt, \sum, \int, greek letters and common relation symbols

Currency-style dollars spanning prose (costs $5 and $10) are not treated as math. The inline-$...$ rules are shared with the Math::LatexToSVG function, so a text this gate accepts is exactly one LatexToSVG can render or normalize.

Example
Input: price is $x^2$ here
Output: true

Input: costs $5 and $10
Output: false

Input: the \frac{1}{2} value
Output: true

Parameters

This function has no parameters.

Input

Textrequired

The text to inspect for LaTeX math syntax.

Output

Boolean

true when the text contains LaTeX math syntax, false otherwise.