Anki-android: AnkiDroid doesn't show LaTeX svg images

Created on 18 Jun 2019  Â·  15Comments  Â·  Source: ankidroid/Anki-Android

Reproduction Steps

  1. Create a LaTeX card in Anki (while avoiding common boogie traps, like putting the latex delimiter latex in the card template.

  2. Set LaTeX rendering to svg (in Anki)

  3. Sync Anki
Expected Result

The LaTeX equation shows up in AnkiDroid

Actual Result

While the equation shows up in AnkiWeb and other svg images (written in html) show up on AnkiDroid, instead of the equation there is a '?' sign.

I can open the svg files synced to my Android device with svg viewers.

This is how the card looks on my phone:

WhatsApp Image 2019-06-18 at 08 19 11

Debug info

https://ankidroid.org/docs/help.html

Research

[ x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[ x] I have checked the manual and the FAQ and could not find a solution to my issue

[ x] I have searched for similar existing issues here and on the user forum

Most helpful comment

Hmm - if I recall correctly you have to view the card correctly on Anki Desktop to render it into your media collection, then sync that down for it to render on AnkiDroid? But I could be off.

I'm mostly replying to say that AnkiDroid just got Mathjax support to match Anki Desktop and the rest of the ecosystem. So if you're looking at equations, maybe switching to mathjax is possible? They are available in the alphas (which are about to beta - they're plenty stable) - https://github.com/ankidroid/Anki-Android/wiki/Installation#beta--alpha-releases

All 15 comments

Hmm - if I recall correctly you have to view the card correctly on Anki Desktop to render it into your media collection, then sync that down for it to render on AnkiDroid? But I could be off.

I'm mostly replying to say that AnkiDroid just got Mathjax support to match Anki Desktop and the rest of the ecosystem. So if you're looking at equations, maybe switching to mathjax is possible? They are available in the alphas (which are about to beta - they're plenty stable) - https://github.com/ankidroid/Anki-Android/wiki/Installation#beta--alpha-releases

See the Anki Desktop manual for how to use LaTeX correctly:
https://apps.ankiweb.net/docs/manual.html#latex-on-web/mobile

or, just switch to Mathjax to save yourself the headache

See the Anki Desktop manual for how to use LaTeX correctly:
https://apps.ankiweb.net/docs/manual.html#latex-on-web/mobile

or, just switch to Mathjax to save yourself the headache

I read the Anki Desktop manuals section on LaTeX on mobile, but it doesn't help me.
The images show on AnkiWeb, but not on AnkiDroid.
This issue shouldn't be closed yet, because the problem still persists.

Do the images show up when you review on AnkiWeb in Google Chrome on your Android device?

Yes, they do show up on AnkiWeb when reviewing on my Android device.

However, this is quite impractical because I have to be online to do so.

Hmm that's pretty unexpected. What version of Android are you using? Usually (at least on Android 4.4+), if it works in Chrome then it should work in AnkiDroid as well. Do you have any special characters in the filename or something slightly abnormal?

I would recommend you just switch over to using mathjax, rather than investing a lot of time into debugging this to be honest.

Can you please upload a small test deck apkg that we can use to reproduce the issue?

My phone is running on Android 7.0.

I created a test deck (which is zipped, because GitHub doesn't allow apkg files):

Anki_LaTeX_error.zip

This issue also appears to me.

Do the images show up when you review on AnkiWeb in Google Chrome _on your Android device_?

Yes, for both PNG and SVG images.

When I remove the V from "Create scalable images with dvisvgm" under LaTeX tab (which falls back to create images with dvipng), AnkiDroid shows LaTeX PNG images fine.

Following @timrae recommendation, I've setup MathJax support according to wiki Enabling MathJax rendering in AnkiDroid section.
After this setup, AnkiWeb (both mobile and desktop), Anki desktop and AnkiDroid display successfully SVG images of mathematical equations.

This solution seems to work fine, but it feels too manual instead of support SVG display of LaTeX.

Additionally, it looks like this solution doesn't work while being offline - correct me if I'm wrong here.

That mathjax workaround from the wiki is no longer needed in the latest alpha versions, it should just work. Going forwards, mathjax will most likely be the only supported method of rendering LaTeX equations.

I tested the attached deck and it worked fine:
Anki-screenshot

Although, I was able to reproduce on my phone (anki 2.8.4) before I upgraded it to 2.9alpha80, where the issued disappeared.
I'm not sure what exactly fixed this, but it seems this has been fixed in the latest pre-releases.

Thank you, it's possible svg support is v2.9 only, I don't remember exactly when it was merged

I see that you added MathJax.js library under your project assets - so it will work offline :)

Additionally, I recommend you to include MathJax.js library version in the file name in case that you don't automatically manage its versions.

Have you considered to use MathJaxView library, instead of maintaining MathJax JavaScript library support by yourself?

After this discussion, in the context of Anki database storage - I think it is essential for all Anki projects to work with MathJax, instead of LaTeX, because the former storage short text, while the latter stores concrete image files.

Does desktop Anki do it differently than how we did it here? We pulled in
exactly the same version of Mathjax that desktop Anki uses, and pulled it
in the same way, as far as I can tell.

On Tue, Jul 16, 2019, 3:41 AM Eido95 notifications@github.com wrote:

I see that you added MathJax.js library under your project assets - so it
will work offline :)

Additionally, I recommend you to include library version in file name in
case that you don't automatically manage its versions.

After this discussion, in the context of Anki database storage - I think
it is essential for all Anki projects to work with MathJax, instead of
LaTeX, because the former storage short text, while the latter stores
concrete image files.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/ankidroid/Anki-Android/issues/5332?email_source=notifications&email_token=AAAIWYM6Z44RNUEGYKLFVQLP7WCUDA5CNFSM4HY4VWVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2AER4I#issuecomment-511723761,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAIWYJHQZ3SM6AWTVP5CHTP7WCUDANCNFSM4HY4VWVA
.

Following a suggestion from timrae, I switched my cards to MathJax. They work fine now, although it was a hassle to port them all.

Thank you all for your help!

Was this page helpful?
0 / 5 - 0 ratings