
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
react-latex-next
Advanced tools
Render LaTeX beautifully in React apps!
It renders all fragments of LaTeX (between delimiters) in a given text, similar to KaTeX's auto-render.
See the demo.
yarn add react-latex-next
npm install --save react-latex-next
import 'katex/dist/katex.min.css';
import Latex from 'react-latex-next';
function Example() {
return (
<Latex>We give illustrations for the {1 + 2} processes $e^+e^-$, gluon-gluon and $\\gamma\\gamma \\to W t\\bar b$.</Latex>
);
}
Note: katex
CSS needs to be included in your final bundle. Above example is using import
to load css
but depending on how the code & styles are built and bundled, it may be different for your case.
List of delimiters to look for math you can configure it via delimiters
prop: <Latex delimiters={[...]}>
{
left: "A string which starts the math expression (i.e. the left delimiter)"
right: "A string which ends the math expression (i.e. the right delimiter)"
display: "A boolean of whether the math in the expression should be rendered in display mode or not"
}
[
{ left: '$$', right: '$$', display: true },
{ left: '\\(', right: '\\)', display: false },
{ left: '$', right: '$', display: false },
{ left: '\\[', right: '\\]', display: true },
]
It renders by default non-strict which means it falls back to raw text (without delimiters) in case of error. You can enable strict mode like below, which will throw the error instead.
<Latex strict>{textWithSomeBrokenLatex}</Latex>
A collection of custom macros. Each macro is a property with a name like \name
(written \\name
in JavaScript) which maps to a string that describes the expansion of the macro.
macros
object is also used to persists macros defined in LaTeX
via \gdef
, refer to the KaTeX docs for more details (and security implications)
<Latex macros={{ "\\f": "#1f(#2)" }}>{'$\\f\\relax{x} = x$ is rendered using macros'}</Latex>
MIT © harunurhan
FAQs
Render LaTeX in React apps
The npm package react-latex-next receives a total of 0 weekly downloads. As such, react-latex-next popularity was classified as not popular.
We found that react-latex-next demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.