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 Math Typesetting #36

Open
asolisc opened this issue Sep 17, 2020 · 1 comment
Open

Support for Math Typesetting #36

asolisc opened this issue Sep 17, 2020 · 1 comment

Comments

@asolisc
Copy link

asolisc commented Sep 17, 2020

Hi,

Does the template currently support Math Typesetting?

Thanks,
Alexis

@RoyiAvital
Copy link

I added MathJaX support using Shortcode.

In layouts/shortcodes/MathJaX.html:

{{ .Inner }}

In forty/layouts/partials/header.html:

...
{{ with .Site.Params.favicon }}
	<link rel="shortcut icon" type="image/x-icon" href="{{ . | absURL }}">
	<link rel="icon" type="image/x-icon" href="{{ . | absURL }}">
{{ end }}
	
{{ if .Page.Params.enableMathJaX }}
	{{ partial "MathJaX.html" . }}
{{ end }}
...

In layouts/partials/MathJax.html:

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
      processEscapes: true
    },
    "HTML-CSS": { fonts: ["TeX"] }
  });
</script>
<script type="text/javascript"
   src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_CHTML">
</script>

In the markdown file:

{{< MathJaX >}}
$$
\begin{vmatrix}a & b\\
c & d
\end{vmatrix}
$$
{{< /MathJaX >}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants