Contents

Writing Mathematical Formulas on Blogs

Educational blogs, especially those about mathematics or accounting, almost always need symbols, notation, formulas, and equations. The problem is that Blogger does not provide a built-in equation editor like Microsoft Word.

Because of that, mathematical formulas on blogs are usually written in LaTeX\LaTeX and then rendered by JavaScript libraries such as MathJax or KaTeX.

[

Writing mathematical formulas on a blog
Writing mathematical formulas on a blog
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwXhXh-29qqCCQvxftZ0xkRT7jAJsZE-X4IiAoC3Sry_JeDe-LX6VTDExozqLFCkHhix4xu8MuSEmCiQO4f8A7o4aMUzjy-l_cAyk-b1dh_kJHNCoQeWnoS_0OUWmkLl-rstyFoJ-pqaE/s2048/20210823_153204.jpg)

Instead of inserting formulas as screenshots, writing them directly with LaTeX\LaTeX produces cleaner output and follows mathematical formatting much better.

The workflow is simple:

  1. write the formula in LaTeX\LaTeX,
  2. paste that code into the blog article,
  3. let MathJax or KaTeX render it.

If you are not yet comfortable typing raw LaTeX\LaTeX, you can use CodeCogs as a helper. It provides a visual formula editor and generates the corresponding LaTeX\LaTeX code.

CodeCogs usually shows three main parts:

  1. a symbol toolbar,
  2. a LaTeX\LaTeX input box,
  3. a preview area.

Example:

\frac{x^2+1}{x-3}

Rendered result:

x2+1x3 \frac{x^2+1}{x-3}

When copying from CodeCogs, it is better to copy the raw LaTeX\LaTeX code instead of the image output. Then paste it into the blog in HTML mode or any editor mode that preserves backslashes correctly.

LaTeX CodeResult
a+ba+ba+b
c-dcdc-d
a\times ba×ba\times b
c\div dc÷dc\div d

Use ^ for exponents and _ for subscripts. If the exponent or subscript contains more than one character, wrap it in curly braces.

LaTeX CodeResult
a^baba^b
a^{bc}abca^{bc}
4x_a4xa4x_a
x_{max}^2+x_{min}^2=1xmax2+xmin2=1x_{max}^2+x_{min}^2=1

Use \frac for regular fractions and \dfrac for a larger display style.

LaTeX CodeResult
\frac{a}{b}ab\frac{a}{b}
\dfrac{c}{d}cd\dfrac{c}{d}
\frac{x-x_1^2}{a^2}xx12a2\frac{x-x_1^2}{a^2}
F=k\dfrac{Q_1Q_2}{R^2}F=kQ1Q2R2F=k\dfrac{Q_1Q_2}{R^2}
LaTeX CodeResult
y=\int (x+1)\ dxy=(x+1) dxy=\int (x+1)\ dx
y=\int_{0}^{\infty} f(x)\ dxy=0f(x) dxy=\int_{0}^{\infty} f(x)\ dx
\iint f(x,y)\ dx\ dyf(x,y) dx dy\iint f(x,y)\ dx\ dy
\oint\oint
LaTeX CodeResult
\dfrac{dy}{dx}dydx\dfrac{dy}{dx}
\dfrac{\partial z}{\partial x}zx\dfrac{\partial z}{\partial x}
LaTeX CodeResult
\sqrt{a}a\sqrt{a}
\sqrt[n]{a}an\sqrt[n]{a}
y=\sqrt{\dfrac{x}{x^2+2x+1}}y=xx2+2x+1y=\sqrt{\dfrac{x}{x^2+2x+1}}
a < ba<ba < b
a \le baba \le b
a > ba>ba > b
a \ge baba \ge b
LaTeX CodeResult
\sum_{i=1}^{n} x_ii=1nxi\sum_{i=1}^{n} x_i
\sum \limits_{i=1}^{n} x_ii=1nxi\sum \limits_{i=1}^{n} x_i
\prod_{i=1}^{n} x_ii=1nxi\prod_{i=1}^{n} x_i
\prod\limits_{i=1}^{n} x_ii=1nxi\prod\limits_{i=1}^{n} x_i
LaTeX CodeResult
\sin(x)sin(x)\sin(x)
\cos(x)cos(x)\cos(x)
\tan(x)tan(x)\tan(x)
\alpha^\circα\alpha^\circ

Example:

\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}

Result:

[abcd] \begin{bmatrix} a & b \\ c & d \end{bmatrix}

For multi-line equations, the align environment is very useful.

\begin{align}
y &= 2x+3 \\
y-3 &= 2x
\end{align}

Result:

y=2x+3y3=2x \begin{align} y &= 2x+3 \\ y-3 &= 2x \end{align}

If your blog does not yet have a math renderer, MathJax is one of the most common choices. The snippet below is a typical example used in older Blogger setups.

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [['$','$'], ['\\(','\\)']],
      displayMath: [['$$','$$'], ['\\[','\\]']]
    }
  });
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

For writing formulas:

  • inline math can use $ ... $ or \( ... \),
  • display math can use $$ ... $$ or \[ ... \].

KaTeX is usually lighter and faster. Example setup:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"></script>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    renderMathInElement(document.body, {
      delimiters: [
        {left: "$$", right: "$$", display: true},
        {left: "$", right: "$", display: false},
        {left: "\\(", right: "\\)", display: false},
        {left: "\\[", right: "\\]", display: true}
      ]
    });
  });
</script>

In practice:

  • MathJax is more flexible and highly compatible,
  • KaTeX is faster and lighter,
  • for most educational blogs, either one works well.

Some recommendations:

  1. use real LaTeX\LaTeX code instead of screenshots,
  2. test formulas in a draft before publishing,
  3. stay consistent with inline and display delimiters,
  4. avoid placing renderer scripts repeatedly inside article content,
  5. if your blog template already loads MathJax or KaTeX, the article only needs the formula code itself.

Writing mathematical formulas on a blog becomes straightforward once the workflow is clear: write the formula in LaTeX\LaTeX, paste it into the article, and let MathJax or KaTeX render it. This produces much cleaner results than using formula screenshots and makes mathematics articles easier to read.

Related Content