Vuepress: Support for inline math using KaTeX

Created on 17 Apr 2018  路  7Comments  路  Source: vuejs/vuepress

Solutions like Sphinx, GitBooks, and Dropbox Paper do this already.

feature request

Most helpful comment

You can use markdown-it-katex to use Katex.
_
Below is my way:

  • Install markdown-it-katex
yarn add markdown-it-katex
  • Modify your config.js in .vuepress
module.exports = {
  ...
  markdown: {
    config: md => {
      md.use(require("markdown-it-katex"));
    }
  }
};
  • Add Katex CSS into your theme or anywhere ( in exact markdown file you want to use Katex, in Layout.vue, ... )
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/github-markdown-css/2.2.1/github-markdown.css"/>

All 7 comments

PR welcome.

You can use markdown-it-katex to use Katex.
_
Below is my way:

  • Install markdown-it-katex
yarn add markdown-it-katex
  • Modify your config.js in .vuepress
module.exports = {
  ...
  markdown: {
    config: md => {
      md.use(require("markdown-it-katex"));
    }
  }
};
  • Add Katex CSS into your theme or anywhere ( in exact markdown file you want to use Katex, in Layout.vue, ... )
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/github-markdown-css/2.2.1/github-markdown.css"/>

Closing as this can be done in userland.

Thanks a lot! VuePress is awesome! Love it

Is anyone here still using latex equations in Vuepress?

markdown-it-katex is no longer maintained, so I've been trying @neilsustc/markdown-it-katex and markdown-it-texmath.

Both of these result in _excruciatingly_ slow dev server startups / refreshes, as in 30+ minutes. However, production builds seem to be fine.

I'm curious if anyone knows what might be causing these slow webpack-dev-server startups / refreshes and if there is a workaround or potential solution?

Thanks.

@songololo Hi there!

I wrote a new plugin vuepress-plugin-mathjax yesterday. Can you try it out to see if satisfies your needs?

@Shigma, wow, thanks, that really makes it easier.

In the meantime I had been using the markdown-it-mathjax to parse the markdown to mathjax supported syntax, and then loading the mathjax script in the head of the file. This was not ideal because mathjax wouldn't refresh when changing pages, so I had to use a module to force mathjax to refresh on page changes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shaodahong picture shaodahong  路  3Comments

ederchrono picture ederchrono  路  3Comments

ynnelson picture ynnelson  路  3Comments

herrbischoff picture herrbischoff  路  3Comments

ynnelson picture ynnelson  路  3Comments