Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for inline math using KaTeX #113

Closed
ghost opened this issue Apr 17, 2018 · 13 comments
Closed

Support for inline math using KaTeX #113

ghost opened this issue Apr 17, 2018 · 13 comments
Labels
type: feature request Request to add a new feature

Comments

@ghost
Copy link

ghost commented Apr 17, 2018

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

@ulivz
Copy link
Member

ulivz commented Apr 18, 2018

PR welcome.

@yyx990803 yyx990803 added the type: feature request Request to add a new feature label Apr 18, 2018
@dacsang97
Copy link

dacsang97 commented Apr 19, 2018

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"/>

@yyx990803
Copy link
Member

Closing as this can be done in userland.

@higuoxing
Copy link

Thanks a lot! VuePress is awesome! Love it

@songololo
Copy link

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.

@shigma
Copy link
Collaborator

shigma commented Feb 24, 2019

@songololo Hi there!

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

@songololo
Copy link

@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.

@borttrob
Copy link

@dacsang97 Thanks for the manual. You saved my day.

I had to change the config.js block slightly to get it to work. (Kudos to https://github.com/mtobeiyf/vuepress-homepage)

  markdown: {
    extendMarkdown: md => {
      md.use(require("markdown-it-katex"));
    }
  },

Also in #289 some people proposed to add css to config.js to enable latex globally.

  head: [
    ['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' }]
  ],

sagelga added a commit to sagelga/documentation that referenced this issue Mar 8, 2021
- Supporting math blocks and in-line math via Katex
- Using vuejs/vuepress#113
@ernestchu
Copy link

maginapp/vuepress-plugin-katex works perfectly for me with the latest Katex support.

@mtoorop-ximedes
Copy link

For reference, I got it to work for Vuepress v1 by taking the following steps:

  • Adding markdown-it-katex as a dev package
yarn add -D markdown-it-katex
// Other settings in config.js not shown

module.exports = {
    head: [
        ['link', { rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css' }]
    ],

    extendMarkdown: md => {
        md.set({ breaks: true })
        md.use(require('markdown-it-katex'))
    }
}
  • Next to that add the katex stylesheet to the head part. (shown above)

Note: markdown-it-plantuml also started working when I removed the markdown:{} part. Only adding it as md.use(require('markdown-it-plantuml')) below to the katex entry was enough.

@iSkore
Copy link

iSkore commented Aug 26, 2021

Thank you @mtoorop-ximedes!

@makabaka1880
Copy link

Why won't it work for me?
https://github.com/makabaka1880/makabaka1880
I stored a snapshot of my project at the branch latex-snapshot

@makabaka1880
Copy link

Why won't it work for me? https://github.com/makabaka1880/makabaka1880 I stored a snapshot of my project at the branch latex-snapshot

in docs/README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Request to add a new feature
Projects
None yet
Development

No branches or pull requests