Docusaurus: Math Jax integration

Created on 2 Dec 2019  路  14Comments  路  Source: facebook/docusaurus

馃摎 Documentation

(Hi, I am writing mathematical equations using Latex, but not rendered properly. I would like to know the way I can write math in the markdown blog or page files and will be displayed on my web pages. )

Have you read the Contributing Guidelines on issues?

(yes)

documentation needs triage

All 14 comments

@drnazmulalam

export const Math = ({ code }) => (
  <img
    src={`https://math.now.sh?from=${encodeURIComponent(code)}`}
    style={{ height: "100%", verticalAlign: "middle" }}
  />
);
<Math code="\LaTeX" />

You鈥檒l have to find a markdown plugin for this. This is out of scope of docusaurus imo.

If you are on v1, you can use katex https://github.com/Khan/KaTeX

They have remarkable-katex plugin which lets u write latex on markdown

@endiliey and how about for v2?

In v2 you can add your own plugins to do this, so definitely not in v2.

Hi @yangshun , (comment updated)
I managed to work with remark-math + rehype-katex. But I didn't find a solution with mathjax. Any hint on this?

@Ir1d Could you please highlight where you managed to keep those plugin list in v2 docusaurus?

@Ir1d I get this error

./docs/doc2.md
Error: Expected usable value, not `/oi-wiki-ng/node_modules/remark-math/index.js`
    at Array.forEach (<anonymous>)
 @ ./.docusaurus/registry.js 1:3120-3161 1:3015-3098
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js./docs/doc3.md
Error: Expected usable value, not `/oi-wiki-ng/node_modules/remark-math/index.js`
    at Array.forEach (<anonymous>)
 @ ./.docusaurus/registry.js 1:3301-3342 1:3198-3279
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js./docs/mdx.md
Error: Expected usable value, not `/oi-wiki-ng/node_modules/remark-math/index.js`
    at Array.forEach (<anonymous>)
 @ ./.docusaurus/registry.js 1:3478-3518 1:3378-3457
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js./docs/xd/doc1.md
Error: Expected usable value, not `/oi-wiki-ng/node_modules/remark-math/index.js`
    at Array.forEach (<anonymous>)
 @ ./.docusaurus/registry.js 1:3672-3716 1:3559-3647
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js

@sivakon Im not developing that branch any more. And I'm not familiar with this error msg

@sivakon
solved it by writing the code below.

const remarkMath = require("remark-math");
module.exports = {
...
  presets: [
    [
      "@docusaurus/preset-classic",
      {
        docs: {
          remarkPlugins: [
            remarkMath,
          ],
...

@hhk7734 where did you put this and which version did you try this on?

thanks. got it working :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chandankumar4 picture chandankumar4  路  3Comments

ericnakagawa picture ericnakagawa  路  3Comments

endiliey picture endiliey  路  3Comments

azu picture azu  路  3Comments

nebrelbug picture nebrelbug  路  3Comments