vue-katex is a lightweight Vue plugin designed to integrate KaTeX, a fast math typesetting library, into Vue applications. The current stable version is 0.5.0, which notably adds support for KaTeX 0.12.0. The project's release cadence appears to be driven by updates to its peer dependency, KaTeX, ensuring compatibility with newer versions of the typesetting library. Key differentiators include its dual approach to usage, offering both a `v-katex` directive for inline or display-mode rendering and a `<katex-element>` component for more structured integration. It also supports KaTeX's auto-render functionality, simplifying the display of math expressions embedded directly in HTML. This package streamlines the process of rendering complex mathematical formulas within Vue ecosystems.
npm install vue-katexVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the setup of `vue-katex` by registering it globally with `Vue.use()`, including the necessary stylesheet. It then showcases both the `v-katex` directive for rendering inline and display math with options, including `auto-render` functionality, and the `<katex-element>` component for declarative TeX expression rendering.
Check `vue-katex` releases for specific KaTeX version compatibility and install the appropriate `katex` version (e.g., `npm i katex@^0.12.0`).
Explicitly import the stylesheet in your entry point: `import 'katex/dist/katex.min.css';` or include it via an HTML `<link>` tag.
Use double backslashes for all TeX commands (e.g., `'\\frac{a_i}{1+x}'` instead of `'\frac{a_i}{1+x}'`).Be aware of the merging behavior when defining global and local options. For full control, provide complete option objects locally or manage global options carefully.
Double-check your TeX expression for syntax errors and ensure all backslashes are escaped (e.g., `v-katex="'\\frac{a}{b}'"`).Ensure you have called `Vue.use(VueKatex)` in your application's entry point after importing `Vue` and `VueKatex`.
Import `katex/dist/katex.min.css` in your main JavaScript file or include it via a `<link>` tag in your `index.html`.