Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:20:57+00:00 2026-06-18T02:20:57+00:00

I have emacs org-generated HTML that contains dvipng’d equations by default. That’s ok, I

  • 0

I have emacs org-generated HTML that contains dvipng’d equations by default. That’s ok, I want to provide a good fallback for those who disabled their JS. The generated pictures and resulting <img> tags have complete LaTeX source in their alt attribute. I have also tweaked the code to apply a specific class to all such images so it becomes a simpler matter in JS end, which isn’t my forté.

The MathJax documentation lists a couple of different configurations and a way to customize a configuration by myself; I don’t see a selector function or anything to apply Mathjax to suit my needs. I know I can write own DOM-munging JS and then call Mathjax afterwards but surely Mathjax bends to this kind of functionality by itself?

This is an example from the generated HTML.

<img class="dvipng" src="upload/blog_ff4e604.png"
     alt="$\frac{1}{2\pi{}i}\int_C\frac{f'(z)}{f(z)}{\rm d}z = N_0(f)$">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:20:58+00:00Added an answer on June 18, 2026 at 2:20 am

    MathJax doesn’t include this directly, but you could do the following:

    <script type="text/x-mathjax-config">
    MathJax.Extension.myImg2jax = {
      version: "1.0",
      PreProcess: function (element) {
        var images = element.getElementsByTagName("img");
        for (var i = images.length - 1; i >= 0; i--) {
          var img = images[i];
          if (img.className === "dvipng") {
            var script = document.createElement("script"); script.type = "math/tex";
            var match = img.alt.match(/^(\$\$?)(.*)\1/);
            if (match[1] === "$$") {script.type += ";mode=display"}
            MathJax.HTML.setScript(script,match[2]);
            img.parentNode.replaceChild(script,img);
          }
        }
      }
    };
    MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.myImg2jax]);
    </script>
    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
    

    which defines a new preprocessor that looks for your images and extracts the math from the ALT tags. This assumes you use $...$ for in-line math and $$...$$ for displayed math.

    This code removed the image when it converts it to the MathJax <script> tag. It would be possible to move the image to a preview span where it will show up until MathJax processes the TeX code. That is a bit more sophisticated, but could be done with a little more work. I’ll leave that to the interested reader. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an org-mode document that I want to convert to open Document format.
I have used emacs for erlang programming. According to http://emacswiki.org/emacs/CompileCommand , I have configure
I have the following defun's in my .emacs.d: ;;; http://emacswiki.org/emacs/ParenthesisMatching (defun goto-match-paren (arg) Go
Does emacs have support for big numbers that don't fit in integers? If it
I want to have two Emacs windows on the screen: one for Dired and
I would like to have an .emacs setting so that tabs are always formed
I am trying to get http://www.emacswiki.org/emacs/PrettyGreek working for emacs 21.3.1 on Windows. I have
I want to give emacs' org-mode a try. What is the shortest path for
I've recently moved from vim to Emacs because I want to use org-mode .
I have emacs + egg working correctly when accessing repos/dirs/files that are in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.