-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Support for inline math using LaTeX #289
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
Comments
You can customize by yourself. |
Latex has different syntax from Katex. Markdown-it-katex didn't work on latex. I tried many other markdown plugins, including markdown-it-latex, markdown-it-mathjax, amd markdown-it-texmath etc. No luck. When I was previewing markdown files in VS Code, I can see the above equation with a plug-in named 'markdown-math' installed. Why l can't do the same in Vuepress? My current solution is using https://www.codecogs.com/eqnedit.php to insert an equation image. Is there any better choice? How can I show latex equation in node JS? What package should I use? |
Katex is a library for TeX math rendering, not a new kind of TeX syntax. Following the guide in #113 , you'll get your inline math equation parsed and rendered correctly. For all the functions supported in Katex, you may check its official doc KaTeX/function-support It's enough for you to handle 99% of the cases like the cost function shown above. |
Seems that you didn't include the
# This is a markdown file
<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"/>
$J \left( \theta_0, \theta_1 \right) = \frac{1}{2m}\sum\limits_{i=1}^m \left( h_{\theta}(x^{(i)})-y^{(i)} \right)^{2}$
I have created a sample skeleton in vuepress-homepage which might be helpful for your configuration. The raw README.md file and the rendered page: Demo |
you are right. I missed the css. I didn't know that we can apply css in markdown file in this way. I copied default theme by run 'vuepress eject docs' finally, all worked. |
Add css in |
See: #113 (comment) Closing as this can be done in userland. |
configure module.exports = {
head: [
['link', { rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css' }]
],
... would be more elegant. |
yeah I like it. |
I actually couldn't find the info that its possible to add custom headers without ejecting the theme. This is great! Maybe this could go into the documentation! |
🙈 I missed that, sorry |
If anybody else is facing a similar problem and really wants to use MathJax rather than KaTeX (in order to support <script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script> Which can be acheived in VuePress, as described in the manual by adding the following to the head: [
['script',
{ type: '"text/javascript" async',
src: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'
}
]
], This wouldn't be worth adding to this issue, but the new community $$
\begin{aligned}
0 &= ax^2 +bx +c
\implies x &= \frac{- b \pm \sqrt{b^2- 4ac} }{2a}
\end{aligned}
$$ This method was suggestested but not detailed in #113 by songololo. |
@RyanGreenup I use your method to fix some syntax like |
I have quite lot of markdown files which contain many latex equations.
How can I get them show up properly in vuepress?
e.g.
$J \left( \theta_0, \theta_1 \right) = \frac{1}{2m}\sum\limits_{i=1}^m \left( h_{\theta}(x^{(i)})-y^{(i)} \right)^{2}$
The text was updated successfully, but these errors were encountered: