Support Latex

According to the hugo official document of release v0.122.0, we already make the mathematics support as defalut if you use the default theme PaperMod.

If you want to use other themes, make sure that you have set the following config in config/hugo.yaml.

markup:
  goldmark:
    extensions:
      passthrough:
        delimiters:
          block:
          - - \[
            - \]
          - - $$
            - $$
          inline:
          - - \(
            - \)
          - - $
            - $
        enable: true
params:
  math: true

And create the layouts/partials/math.html file which content as follow:

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<script>
  MathJax = {
    tex: {
      displayMath: [['\\[', '\\]'], ['$$', '$$']],  // block
      inlineMath: [['\\(', '\\)'], ['$', '$']]      // inline
    }
  };
</script>

After that, add the following code in the layouts/_default/baseof.html of your customized theme.

<head>
  ...
  {{ if .Param "math" }}
    {{ partialCached "math.html" . }}
  {{ end }}
  ...
</head>

Now your static blog webstie can support the mathematics, for more information please see the hugo official document of release v0.122.0.

Here are some examples of block and inline formulas:

$$ \begin{array}{c} A={\left[ a_{ij}\right]_{m \times n}},B={\left[ b_{ij}\right]_{n \times s}} \\ c_{ij}= \sum \limits_{k=1}^{{n}}a_{ik}b_{kj} \\ C=AB=\left[ c_{ij}\right]_{m \times s} = \left[ \sum \limits_{k=1}^{n}a_{ik}b_{kj}\right]_{m \times s} \end{array} $$

This is a sample of inline formula: $\left(x-1\right)\left(x+3\right) $