question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to render latex in markdown?

See original GitHub issue

Description

I would like to render latex from the markdowns that gets pulled into gridsome

Steps to reproduce

I have been looking for plugins / components to use to be able to use latex expressions in blog posts.

this markdown

### Naive approach to guess until we get a good fit
guessing the beta parameters linear equation

$ y = m \times \mathbf{x} + b

Expected result

The latex should be rendered as html image

Actual result

image

Environment

Libs:

Browser:

  • Chrome (desktop)

  • Node version: 10

  • Platform: Mac

Related issues: https://github.com/gridsome/gridsome-starter-blog/issues/22 https://github.com/gridsome/gridsome/issues/238

Solution in vuepress: https://github.com/vuejs/vuepress/issues/113

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
shahinrostamicommented, Jun 27, 2019

@fullpwemium @hjvedvik hmm 🤔 I tried @gridsome/transformer-remark 0.3.2 and also got the same error:

 error  in ./src/pages/Index.vue?vue&type=custom&index=0&blockType=page-query

Module build failed (from ./node_modules/gridsome/lib/webpack/loaders/page-query.js):
Error: Cannot query field "description" on type "Post".

GraphQL request (29:9)
28:         timeToRead
29:         description
            ^
30:         ...on Post {

Hello, I’m not affiliated with Gridsome so I can’t give an answer with any certainty or authority, but I have a solution for you. As @hjvedvik already suggested, some packages in your project likely need updating. I think if you’re on an old @gridsome/transformer-remark you are likely on older versions of other packages too (including gridsome itself). Here is a set of packages which I’ve confirmed to work:

from packages.json

  "dependencies": {
    "@gridsome/cli": "^0.2.1",
    "@gridsome/source-filesystem": "^0.5.0",
    "@gridsome/transformer-remark": "^0.3.2",
    "gridsome": "^0.6.5",
    "remark-html-katex": "^1.2.0",
    "remark-math": "^1.0.6",
    "vue-katex": "^0.2.0"
  }

from gridsome.config.js

  transformers: {
    remark: {
      plugins:
        ['remark-math'],
        ['remark-html-katex']]
    }
  }

from the template, e.g. BlogPost.vue

// inside <script>
import 'katex/dist/katex.min.css';

from the markdown blog post

$$
f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi
$$

I hope this helps - will be interested to hear how it goes

2reactions
soaibsaficommented, Oct 10, 2020

I have implemented latex using gridsome-remark-katex at my site You can have a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Markdown and LaTeX introduction - Ashkan Mirzaee
We can use LaTeX to write mathematical equations in Markdown. To write inline LaTeX formula use a single $ before and after the...
Read more >
How to use LaTeX in Markdown - Fabrizio Musacchio
Many Markdown processors are capable to interpret LaTeX's math mode commands in order to display a broad variaty of mathematical expressions.
Read more >
How can I mix LaTeX in with Markdown? [closed]
Save this answer. Show activity on this post. And the Latex is rendered in pieces using tex-mode's preview-latex.
Read more >
Render mathematical expressions in Markdown
You can now use LaTeX style syntax to render math expressions within Markdown inline (using $ delimiters) or in blocks (using $$ delimiters) ......
Read more >
Markdown and LaTeX - Juan Shishido
Directly insert mathematical expressions using LaTeX's syntax into your document. Then, use pandoc to render the formatted text and output a PDF.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found