{"id":2565,"library":"latex2mathml","title":"Pure Python library for LaTeX to MathML conversion","description":"latex2mathml is a pure Python library for converting LaTeX math expressions to MathML. It supports a wide range of LaTeX commands and environments. The current version is 3.79.0 and it maintains an active release cadence, with recent updates.","status":"active","version":"3.79.0","language":"en","source_language":"en","source_url":"https://github.com/roniemartinez/latex2mathml","tags":["latex","mathml","conversion","math"],"install":[{"cmd":"pip install latex2mathml","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false}],"imports":[{"note":"The direct import from the top-level 'latex2mathml' package for the 'convert' function was used in older versions (e.g., 1.x) but is now found within the 'converter' submodule.","wrong":"import latex2mathml; latex2mathml.convert(latex_input)","symbol":"convert","correct":"from latex2mathml.converter import convert"}],"quickstart":{"code":"from latex2mathml.converter import convert\n\nlatex_input = r'E = mc^2'\nmathml_output = convert(latex_input)\nprint(mathml_output)","lang":"python","description":"Convert a simple LaTeX math string to MathML."},"warnings":[{"fix":"Update imports to `from latex2mathml.converter import convert`.","message":"The primary `convert` function moved from the top-level `latex2mathml` module to `latex2mathml.converter`. Direct import `from latex2mathml import convert` will fail.","severity":"breaking","affected_versions":"< 3.0.0 (exact version of change not specified, but observed in difference between v1.1.1 and current usage)"},{"fix":"Simplify LaTeX input where possible or consult the project's documentation/examples for supported syntax if encountering conversion issues.","message":"The library has limitations in supported LaTeX commands, particularly for complex structures. Examples of often unsupported features include newlines (`\\\\`) outside of matrix/align environments, alignment characters (`&`) outside matrix/align environments, and complicated sub/superscripts (`<mmultiscripts>`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the MathML output carefully for `align` environments and consider alternative LaTeX structures if rendering issues occur.","message":"The `\\begin{align}` environment is experimentally supported and may produce non-recommended or poorly formatted MathML output, as it is internally implemented using a matrix environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Provide appropriate CSS to specify MathML-compatible fonts (e.g., `STIX-Two-Math`) for web display if targeting browsers with known rendering issues.","message":"MathML rendering is highly dependent on the browser and its installed fonts. Chromium-based browsers, in particular, may display MathML incorrectly without specific CSS font configurations (e.g., using STIX fonts). This is a browser limitation, not a library issue.","severity":"gotcha","affected_versions":"All versions (client-side rendering)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}