npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@adheil_gupta/react-native-latex-renderer

v1.0.1

Published

A lightweight, auto-resizing LaTeX renderer for React Native using KaTeX.

Readme

React Native Latex Renderer

A lightweight, auto-resizing LaTeX renderer for React Native using KaTeX.

Features

  • Auto-resizing: Automatically adjusts height based on content.
  • KaTeX Support: Fast and reliable math rendering.
  • Customizable: Extensive styling options for container, text, and math elements.
  • TypeScript Support: Fully typed for better development experience.

Installation

npm install @adheil_gupta/react-native-latex-renderer

Usage

Pass content as a string with math equations wrapped with:

  • $ ... $ -> to display inline math
  • $$ ... $$ -> to display the equation on a new line

Simple Example

import { KaTeXAutoHeightWebView, createKaTeXHTML } from '@adheil_gupta/react-native-latex-renderer';
import { StyleSheet, View } from 'react-native';

const testing = `
  This is a test latex equation:
  $$
  I(\\lambda)
  =
  \\int_0^{\\infty} e^{-\\lambda x^2}\\cos(x)\\,dx
  \\sim
  \\sum_{k=0}^{\\infty}
  \\frac{(-1)^k (2k)!}{2^{2k+1} k!}
  \\lambda^{-k-\\tfrac12}
  $$
  End of test latex equation.
`;

export default function HomeScreen() {
  const src = createKaTeXHTML(
    testing,
    // HTML Container Styles
    {
      width: '80%',
      'padding': '15px',
      'font-size': '18px',
      'color': 'pink',      
      'background-color': 'purple',      
    },
    // LaTeX Specific Styles
    {
      border: '2px solid red',
      'color': 'lawngreen',
      'background-color': 'blue',      
    }
  );

  return (
    <View style={styles.container}>
      <KaTeXAutoHeightWebView
        source={src}
        onHeightChange={(height) => console.log('New height:', height)}
        containerStyle={{
          width: '100%',
          backgroundColor: 'yellow',
        }}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    paddingVertical: 100,
  },
});

Example Result

API Reference

createKaTeXHTML(content, containerStyles, latexStyles)

Generates the HTML source string for the WebView.

| Parameter | Type | Description | |---|---|---| | content | string | The text content containing LaTeX delimiters. | | containerStyles | object | Styles for the HTML container (font, padding, color, etc.). | | latexStyles | object | Styles specifically applied to KaTeX elements. |

KaTeXAutoHeightWebView

The main component that renders the LaTeX content.

| Prop | Type | Default | Description | |---|---|---|---| | source | string | - | The HTML string returned by createKaTeXHTML. | | onHeightChange | (height: number) => void | - | Callback fired when content height changes. | | minHeight | number | 50 | Minimum height of the WebView. | | containerStyle | object | - | Styles for the outer React Native View. | | ...props | WebViewProps | - | Any other props accepted by react-native-webview. |

Styling

You can style the component at three levels:

  1. React Native Container: Using the containerStyle prop on <KaTeXAutoHeightWebView />.
  2. HTML Content: Using the second argument of createKaTeXHTML. Supports standard CSS properties like font-size, color, padding, line-height.
  3. LaTeX Elements: Using the third argument of createKaTeXHTML. Styles applied directly to .katex elements.

Contributing

License

MIT