Skip to content

Tools

Rendering Engines

The current mainstream LATEX formula rendering engines are MathJax and KaTeX, both of which can generate high-quality output on all modern browsers and platforms.

Their syntax is largely the same, with only minor differences. For usage, refer to their respective official websites for more detailed instructions.

Vatex

VaTex is a plugin for displaying KaTeX formulas in Vue, and its installation and usage are very simple.

Installation

sh
npm i vatex katex

Vue2 users need to additionally install the composition-api.

sh
npm i @vue/composition-api

Usage

  • Vue3

    • Register as a global component

      js
      import {createApp} from 'vue'
      import VueLatex from 'vatex'
      
      app
        .use(VueLatex)
        .mount('#app')

      Then use it in the Vue file:

      vue
      <vue-latex :expression="'\\frac{a_i}{1+x}'" display-mode/>
    • Import individually

      vue
      <template>
        <vue-latex :expression="'\\frac{a_i}{1+x}'" display-mode/>
      </template>
      <script lang="ts">
      import {defineComponent} from 'vue'
      import {VueLatex} from 'vatex'
      
      export default defineComponent({
        components: {
          VueLatex
        }
      })
      </script>
  • Vue2

    • Register as a global component
    js
    import Vue from 'vue';
    
    Vue.use(VueKatex);
    • Import individually
    vue
    <template>
      <vue-latex :expression="'\\frac{a_i}{1+x}'" display-mode/>
    </template>
    <script>
    import {VueLatex} from 'vatex'
    
    export default {
      name: 'App',
      components: {
        VueLatex
      }
    }
    </script>

Parameters

ParameterTypeDefaultDescription
expressionstringLaTeX expression.
displayModebooleanfalseDisplay mode, true uses div for horizontal centering, false uses span for inline.
fontsizenumber16Controls the font size of the LaTeX expression (px).
minRuleThicknessnumber0.04Line thickness for fraction lines, borders, etc. (em).
macrosobjectnullMacros, represented as an object.
strict[stirng, object, function]warnStrict mode: warn, error, ignore.
throwOnErrorbooleanfalseThrows an exception on error. True will throw an exception for expression errors, false will display the erroneous LaTeX expression in red.
errorColorstring#cc0000Color when LaTeX expression errors occur.