-
To use maths inline, we have to use:
Following this article https://adityatelange.github.io/hugo-PaperMod/posts/math-typesetting/. Is there anyway we can use single dollars such as If so, how? I'm rather new to this and I can't find anything from mindlessly digging around :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes. You don't actually need the You can use The following works just fine: {{< math.inline >}}
{{ if or .Page.Params.math .Site.Params.math }}
<!-- KaTeX -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
{{ end }}
{{</ math.inline >}}
### Examples
Inline math: \\(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\\)
Block math:
$$
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
$$
The reason the inline shortcodes are used here is because the math partial is not included in the hugo-PaperMod theme. If wanted, I could create a PR to include it so you don't need inline shortcodes at all (which is preferred). |
Beta Was this translation helpful? Give feedback.
-
I used the approach taken in here and I could successfully use inline math with Hugo. |
Beta Was this translation helpful? Give feedback.
Yes. You don't actually need the
{{< math.inline >}}
lines around the KaTeX. Those are to tell Hugo to parse what's inside it as an HTML Hugo template rather than as Markdown (that's why the conditional statements work). So they are required around the lines which include the KaTeX scripts, but not around the actual KaTeX markup.You can use
\\( ... \\)
for inline KaTeX. You have to use two backslashes due to the way backslashes are treated during Markdown processingThe following works just fine: