LaTeX inline rendering now also broken in DT 4.2

After the rendering of inline LaTeX equations became broken in DEVONthink To Go 4.0.3 (and still is in the latest version 4.0.4), the new update of the DEVONthink desktop app to version 4.2 from this week has now also broken both inline and block LaTeX equations. This was not an issue before and must therefore have been introduced by the most recent update.

This is what it currently looks like:

For comparison, the same raw Markdown and LaTeX in Obsidian:

Of course, I do not want to presume to “play programmer”. However, perhaps the issue in both DEVONthink and DEVONthink To Go is related to how MathJax is integrated. With the default integration, LaTeX equations delimited by $ and $$ are not rendered. This only becomes possible with a small extension:

<script type="text/javascript"
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML">
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [['$','$'], ['\\(','\\)']],
      processEscapes: true},
      jax: ["input/TeX","input/MathML","input/AsciiMath","output/CommonHTML"],
      extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathMenu.js","MathZoom.js","AssistiveMML.js", "[Contrib]/a11y/accessibility-menu.js"],
      TeX: {
      extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"],
      equationNumbers: {
      autoNumber: "AMS"
      }
    }
  });
</script>

Since LaTeX formulas using $ and $$ did not cause any problems in previous versions of DEVONthink and DEVONthink To Go, perhaps something was changed or overridden in the recent updates?

1 Like

See my reply in the other thread. If you‘re interested in testing this, just send me a PM.

1 Like

Meanwhile, while the DT Team is working on a fix for this issue, I found this interim solution just last night:

  1. Deactivate DT’s own MathJax support in the settings
  2. Create a new text file called, e.g., DT_java.js (you can simply use textedit for this) and insert and save the following content:
window.MathJax = {
  tex2jax: {
    inlineMath: [['$','$'], ['\\(','\\)']],
    processEscapes: true
  },
  jax: ["input/TeX","input/MathML","input/AsciiMath","output/CommonHTML"],
  extensions: [
    "tex2jax.js",
    "mml2jax.js",
    "asciimath2jax.js",
    "MathMenu.js",
    "MathZoom.js",
    "AssistiveMML.js",
    "[Contrib]/a11y/accessibility-menu.js"
  ],
  TeX: {
    extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"],
    equationNumbers: {
      autoNumber: "AMS"
    }
  }
};

var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML";
document.head.appendChild(script);
  1. Back in DT’s settings, choose this newly created file in the “JavaScript” section (it’s in tab “Files” ⟶ “Markdown”)

This bypasses the current broken rendering and the inline LaTeX display using “$” works again when there is more than one LaTeX command on a single line:

This worked for mit in DT Pro 4.2.2. Unfortunately, this solution does not work on DTTG; I tried with different variation and mathjax version.

But beware of “smart” quotes when you do that. Imo, a bespoke editor is always a better option for programming tasks.

And another caveat: this approach works only when you’re online. An alternative would be to download the mathjax file locally and load that instead of the CDN one

1 Like

Do you think your solution could be used to also load XyJax (so one can draw commutative diagrams in style)? GitHub - sonoisa/XyJax-v3: Xy-pic extension for MathJax version 3 · GitHub

1 Like

Oh kool, I didn’t know about that! It seems to work out of the box when pasting it into a Markdown file directly:


# XyJax

<script>
  MathJax = {
    loader: {
      load: ['[custom]/xypic.js'],
      paths: {custom: 'https://cdn.jsdelivr.net/gh/sonoisa/XyJax-v3@3.0.1/build/'}
    },
    tex: {
      packages: {'[+]': ['xypic']}
    }
  };
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.1.4/es5/tex-chtml-full.js"></script>
<!-- <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.1.4/es5/tex-svg-full.js"></script> -->


$$\begin{xy}
\xymatrix {
U \ar@/_/[ddr]_y \ar@{.>}[dr]|{\langle x,y \rangle} \ar@/^/[drr]^x \\
 & X \times_Z Y \ar[d]^q \ar[r]_p & X \ar[d]_f \\
 & Y \ar[r]^g & Z
}
\end{xy}$$

So I would say, it could work when placing it into DT‘ Java script file/field.

1 Like