# Mathjax renders badly

**URL:** https://forums.ankiweb.net/t/mathjax-renders-badly/29329
**Category:** Help
**Created:** [April 13, 2023, 4:07am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329 "2023-04-13T04:07:20Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![guoliang.oon](https://avatars.discourse-cdn.com/v4/letter/g/df788c/32.png) [@guoliang.oon](https://forums.ankiweb.net/u/guoliang.oon)
#### Post date: [April 13, 2023, 4:07am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/1 "2023-04-13T04:07:20Z")

</div>

update: i notice this happens every single time whenever i review the second math card, and conversely it never happens on the first review (after i go back to Decks and start reviewing the same deck again (all my cards in that deck have mathjax))

on review:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/4/45e740cb32256727137e11941220b8f5e21bec9e.png)

preview is more reliable

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/4/4168f5f114cddf650a9d08b653a2da6fb061678f.png)

source:

```html
<div>Let <anki-mathjax>\mathbf{C}</anki-mathjax> be a small category and <anki-mathjax>J</anki-mathjax> a Grothendieck topology on C. A presheaf, as before, is simply a functor<br><anki-mathjax block="true">P: \mathbf{C}^{\mathrm{op}} \rightarrow \mathbf{S e t}</anki-mathjax><br>. If <anki-mathjax>P</anki-mathjax> is such a presheaf and the sieve <anki-mathjax>S</anki-mathjax> is a cover of an object <anki-mathjax>C</anki-mathjax> of <anki-mathjax>\mathbf{C}</anki-mathjax>, a <i><font color="#ff0000">matching family</font></i> for <anki-mathjax>S</anki-mathjax> of elements of <anki-mathjax>P</anki-mathjax> is a function which assigns to each element <anki-mathjax>f: D \rightarrow C</anki-mathjax> of <anki-mathjax>S</anki-mathjax> an element <anki-mathjax>x_f \in P(D)</anki-mathjax>, in such a way that<br><anki-mathjax block="true">{{c1::x_f \cdot g=x_{f g} }} \quad \text { for all } g: E \rightarrow D \text { in } \mathbf{C .}</anki-mathjax><br>An <i><font color="#ff0000">amalgamation</font></i> of such a matching family is a single element <anki-mathjax>x \in P(C)</anki-mathjax> with<br><anki-mathjax block="true">{{c2::x \cdot f=x_f}} \quad \text { for all } f \in S \text {. }</anki-mathjax><br>Then <anki-mathjax>P</anki-mathjax> is a sheaf (for <anki-mathjax>J</anki-mathjax> ) precisely then, when {{c3::every matching family for any cover of any object of <anki-mathjax>\mathbf{C}</anki-mathjax> has a unique amalgamation}}.<br><br></div>

```

Anki desktop for mac silicon  
Version ⁨2.1.61 (0c1eaf4c)⁩  
Python 3.9.15 Qt 6.3.2 PyQt 6.3.1

---

<div class="post-metadata">

### Author: ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)
#### Post date: [April 13, 2023, 4:55am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/2 "2023-04-13T04:55:26Z")

</div>

> [@Anki 2.1.56 Release Candidate](https://forums.ankiweb.net/t/anki-2-1-56-release-candidate/26001/29):
>
> Parts of MathJax equations are not rendering correctly. Here, the parentheses around “x” are missing Even worse, when I move to the next card, press “undo”, then study the card again, this time the MathJax equation does not appear. I thought this might be related to the JavaScript I was using to define LaTeX macros, but the problem persists after I remove the script from my template. Note that the equation is rendered correctly in the Card Type window. I have dis…

---

<div class="post-metadata">

### Author: ![guoliang.oon](https://avatars.discourse-cdn.com/v4/letter/g/df788c/32.png) [@guoliang.oon](https://forums.ankiweb.net/u/guoliang.oon)
#### Post date: [April 13, 2023, 5:08am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/3 "2023-04-13T05:08:03Z")

</div>

Ah thanks Damian, looks like the same issue. Didn’t know 2.1.61 was beta.

---

<div class="post-metadata">

### Author: ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)
#### Post date: [April 13, 2023, 5:19am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/4 "2023-04-13T05:19:43Z")

</div>

2.1.61 is a stable release. I suspect your issue is the one mentioned at the edit at the bottom of that post.

---

<div class="post-metadata">

### Author: ![guoliang.oon](https://avatars.discourse-cdn.com/v4/letter/g/df788c/32.png) [@guoliang.oon](https://forums.ankiweb.net/u/guoliang.oon)
#### Post date: [April 14, 2023, 2:49am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/5 "2023-04-14T02:49:30Z")

</div>

Ah ok.

That post said “scripts”, which I assume are addons? So I tried disabling all add ons and I get the same issue.

Interestingly, the same issue happens (only on reviewing mathjax cards after the first one) on the mobile Anki (version 2.0.92 (20092.3))

---

<div class="post-metadata">

### Author: ![guoliang.oon](https://avatars.discourse-cdn.com/v4/letter/g/df788c/32.png) [@guoliang.oon](https://forums.ankiweb.net/u/guoliang.oon)
#### Post date: [April 14, 2023, 3:08am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/6 "2023-04-14T03:08:43Z")

</div>

I tried downgrading every version all the way back to 2.1.54 which was the only one which did not have the issue.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/9/9bf76fdaa41037600449922d4de2a6a2b7552020.png)

I also noticed that it is the last version before the change in UI looks.

---

<div class="post-metadata">

### Author: ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)
#### Post date: [April 17, 2023, 2:50am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/7 "2023-04-17T02:50:43Z")

</div>

You are calling JavaScript in your card template to define custom MathJax macros. Calling getComponents() more than once causes MathJax to get confused, so as described in the link above, you must add a check to only call it once.

---

<div class="post-metadata">

### Author: ![guoliang.oon](https://avatars.discourse-cdn.com/v4/letter/g/df788c/32.png) [@guoliang.oon](https://forums.ankiweb.net/u/guoliang.oon)
#### Post date: [April 17, 2023, 5:01am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/8 "2023-04-17T05:01:11Z")

</div>

Oh!! Sorry I get it now. Didn’t realise the specifying the macros was part of executing JS.

That actually fixes the issue on the mobile version now! All good!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)
#### Post date: [May 17, 2023, 5:01am UTC](https://forums.ankiweb.net/t/mathjax-renders-badly/29329/9 "2023-05-17T05:01:45Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
