Rendering LaTeX formulas in Chat Messages

2 min read

Overview

This documentation provides guidelines on how to render LaTeX formulas in chat messages. The chat system supports Markdown, allowing users to include LaTeX formulas by following specific formatting rules.

Who is it for

This feature is designed for:

  • Mathematicians, scientists, and engineers who need to share complex equations.

  • Educators and students collaborating on mathematical or scientific problems.

  • Anyone who needs to communicate mathematical or technical content effectively in chat.

Benefits

  • Clarity: Share complex mathematical or scientific formulas in a readable format.

  • Efficiency: Quickly render formulas without needing external tools.

  • Collaboration: Enhance communication in technical discussions.

Use Cases

  • Educational Discussions: Teachers and students discussing mathematical problems.

  • Technical Collaboration: Engineers and scientists sharing equations during project discussions.

  • Documentation: Including formulas in chat for reference or explanation

Supported Latex formula syntax

We support LaTeX formulas in the following formats only:

  • Inline math: use \(...\)
    Example: The area is \( \pi r^2 \).

  • Block (display) math: use \[...\] on its own line
    Example:

    \[
      E = mc^2
    \]

Note: Other delimiters such as $...$ or $$...$$ are not supported.

Using with LLMs

If your LLM does not automatically produce the required delimiters, include an instruction in the system prompt such as:

“Render all LaTeX math using \(...\) for inline and \[...\] for block equations. Do not use $...$ or $$...$$.”

You can also reinforce this by adding:

  • “Prefer inline math for short, in-sentence expressions.”

  • “Use block math for standalone or multi-line equations.”

Step-by-Step Guide

To render LaTeX formulas in chat messages, you need to use the LaTeX shorthand syntax for equations. This involves wrapping the formula in escaped square brackets \[...\].

Key Points

  1. Use LaTeX shorthand syntax:

    • Wrap the formula in escaped square brackets \[...\].

  2. Ensure correct LaTeX syntax:

    • Follow standard LaTeX syntax rules within the brackets.

Examples

Here are some examples to illustrate how to format LaTeX formulas in chat messages:

Basic Formula

To include a basic formula, wrap it in escaped square brackets:

\[E = mc^2\]

This will render as:

Screenshot 2024-11-19 at 11.33.31.png

Complex Formula Example

For more complex formulas, ensure all LaTeX syntax is correctly used within the escaped square brackets:

The integral of a function is given by \[\int_{a}^{b} f(x) \, dx\].

This will render as:

Screenshot 2024-11-25 at 10.12.08.png

Tips & Tricks

  • Ensure that your LaTeX code is correctly formatted and follows the standard LaTeX syntax.

  • The shorthand syntax \[...\] is specifically for rendering LaTeX in our chat messages.

  • If you encounter any issues with rendering, double-check that the formula is correctly wrapped in escaped square brackets and that the LaTeX syntax is accurate.

Limitations

  • Syntax Errors: Incorrect LaTeX syntax will result in rendering issues.

  • Formatting Rules: Only formulas wrapped in \$$ ... \$$ will render.

  • Complexity: Extremely complex formulas may require additional testing to ensure proper display.

Last updated