Skip to content

Difficulty Implementing a Basic Example with LaTeX.js for New Users #157

@jondo89

Description

@jondo89

As a new user, I attempted to implement a basic example using LaTeX.js to render formatted text with headings, bold text, and mathematical formulas. Despite multiple attempts and referring to the documentation, the process turned out to be unexpectedly difficult due to unclear examples and potential API mismatches. Here are the details of my experience:

Observed Problems:
Non-Functional or Deprecated Methods:

Methods such as latexjs.render() and latexjs.Parser are referenced in various discussions and examples, but they either do not exist in the latest version or fail to work as described.
Errors Encountered:

latexjs.Parser is not a constructor
latexjs.render is not a function
Cannot read properties of undefined (reading 'setErrorFn')
These errors make it challenging to determine the correct approach to using the library.
Lack of Clear and Updated Documentation:

The official documentation and examples do not include a minimal working example for rendering LaTeX content in a basic HTML page.
Versioning and Compatibility Issues:

Different behaviors between versions are not well-documented, making it hard for new users to identify which version to use.

Add a simple example to the README demonstrating how to load the library, parse LaTeX, and display it in a webpage. For example:

<title>LaTeX.js Example</title> <script src="https://cdn.jsdelivr.net/npm/latex.js@0.11.1/dist/latex.min.js"></script>
<script> // LaTeX content const latexContent = ` \\section*{Example Heading} This is an example of \\textbf{bold text} and a formula: \\[ E = mc^2 \\]. `;
    // Render LaTeX to HTML
    try {
        const output = latexjs.parse(latexContent).toHTML();
        document.getElementById('latex-content').innerHTML = output;
    } catch (error) {
        console.error('Failed to render LaTeX content:', error);
    }
</script>
  1. Provide Error Handling Guide
    Include common errors like latexjs.Parser is not a constructor and how to resolve them.

  2. Highlight Deprecated Features
    Clarify in the documentation which methods or approaches are no longer supported.

  3. Version-Specific Examples
    Ensure examples in the documentation align with the current API, and maintain backward compatibility notes for users on older versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions