How to write equations in html?

HtmlEquation

Html Problem Overview


I want to write some complex mathematical equation in my web page. Is there any plugin or anything for this?

Html Solutions


Solution 1 - Html

Try mathjax http://www.mathjax.org/ . I personally find it very good.

Solution 2 - Html

For complex equations, MathJax is the current practical solution. MathML is a more structural approach in principle, but browser support is rather limited and often of questionable quality.

However, complexity is relative. To some people, E = mc² or ∂/∂t + v ⋅ ∇ might be complex, and such constructs can be written fairly well using just HTML with some help from CSS; see my page Math in HTML (and CSS).

Solution 3 - Html

If you don't want to implement any JavaScript in your HTML, you can use CodeCogs' equation editor tool (http://www.codecogs.com/latex/about.php).

It's really easy to use. All you do is use the button interface to write your equation and an HTML image link is immediately generated. When you run your HTML the image will be generated on CodeCogs' servers and implemented in your site. It's a very comfortable tool.

Solution 4 - Html

Quick example using mathjax:

Load the cdn: (make sure to specify a ?config= option as it doesn't come included in the recommended cdn link - default works just fine):

<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=default'></script>

Then, inside your html simply wrap the equation inside $$ {equation here} $$

e.g. $$ {J(\theta) =\frac{1}{2m} [\sum^m_{i=1}(h_\theta(x^{(i)}) - y^{(i)})2 + \lambda\sum^n_{j=1}\theta^2_j} $$

And it should show up as an equation just fine on the page.

Solution 5 - Html

You could try this. Kind of out of date so not sure how it'll work:

http://www.w3.org/Math/

For Firefox, they have a pretty descriptive article on MathML

Solution 6 - Html

I know this is a bit late. But would like to mention about jqMath which I have personally found easier and much lightweight than MathJax.

Find the details here : https://mathscribe.com/author/jqmath.html

The files can be downloaded from https://mathscribe.com/downloads/mathscribe-win-0.4.6.zip

To use this,

  1. Unzip the downloaded file
  2. find the files jqmath-etc-0.4.6.min.js and jqmath-0.4.3.css, and include them in your html
  3. Make sure your html have <meta charset="utf-8"> in the <head> section.
  4. Also include jQuery before using these.

Now you can write mathematical equations and formulae in your html or web page.

Visit the above link to know more about how to write mathematical formulae using jqMath.

Solution 7 - Html

You can use KaTeX https://katex.org/. Just copy and paste the contents in head tag and paste it into your html file. inside body enter latex inside \(latex code here\). You can view it on GitHub It is faster than MathJax. I refered from javascript Katex not renderingYou can view it on Github. it works well with major browser below is a example code with autorendering option.

<!DOCTYPE html>
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
<html>
  <head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-D+9gmBxUQogRLqvARvNLmA9hS2x//eK1FhVb9PiU86gmcrBrJAQT8okdJ4LMp2uv" crossorigin="anonymous">

    <!-- The loading of KaTeX is deferred to speed up page rendering -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-483A6DwYfKeDa0Q52fJmxFXkcPCFfnXMoXblOkJ4JcA8zATN6Tm78UNL72AKk+0O" crossorigin="anonymous"></script>

    <!-- To automatically render math in text elements, include the auto-render extension: -->
    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-yACMu8JWxKzSp/C1YV86pzGiQ/l1YUfE8oPuahJQxzehAjEt2GiQuy/BIvl9KyeF" crossorigin="anonymous"
        onload="renderMathInElement(document.body);"></script>
  </head>
  <body>
      <p>\(x^2 = \sqrt{y}\)</p><br>
      <p style="color:blue;font-size:25px;">\(\frac {-b\pm\sqrt{b^2 - 4ac}}{2a}\)</P>
  </body>
</html>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionanan_xonView Question on Stackoverflow
Solution 1 - Htmlmathematician1975View Answer on Stackoverflow
Solution 2 - HtmlJukka K. KorpelaView Answer on Stackoverflow
Solution 3 - HtmldeckeleView Answer on Stackoverflow
Solution 4 - HtmlJared WilberView Answer on Stackoverflow
Solution 5 - HtmlaugView Answer on Stackoverflow
Solution 6 - HtmlJishadView Answer on Stackoverflow
Solution 7 - Htmluser9775757View Answer on Stackoverflow