AnkiDroid + Latex

1,697 views
Skip to first unread message

Kyla Pinnock

unread,
Jan 20, 2014, 1:43:29 PM1/20/14
to anki-a...@googlegroups.com
Hi,

I'm currently running the latest version of Android (4.4.2) and have been having problems getting Latex to show up on my mobile device.

It looks perfect when I use latex on the desktop app, but when I try to review the cards on my phone all I see is a blank white square.

Any help would be appreciated.

SN: Is it possible to have latex render on Ankiweb as well?

Flavio Lerda

unread,
Jan 20, 2014, 5:38:49 PM1/20/14
to anki-a...@googlegroups.com
Hello,

LaTeX is not currently rendered on AnkiDroid (adding support for LaTeX itself would be a major undertaking).
However, images should be created (automatically) on the desktop and then used on AnkiDroid. This seems
like a case where somehow the logic that matches the two does not work correctly.

If you can export your deck (or even just one of the cards that does not work), I can look at the reason for
this (and possible provide a solution and/or a workaround).

Flavio
--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android...@googlegroups.com.
To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/4568b3f9-8331-4701-a909-dd5832de302b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alyk

unread,
Jan 20, 2014, 5:53:04 PM1/20/14
to anki-a...@googlegroups.com
Hey Flavio,

Thanks for the quick response. I'm not sure if I'm following your procedures correctly, but I exported the deck and uploaded it here. I'm not sure how to export one card which is why I just did the entire deck. What i'm seeing now is that only a couple of the cards do not work on Droid, where as others do.

The deck is mostly based on Physics formulas with some definitions. It's hard to check which cards do not work, but one that i've noted doesn't is listed below: 
Formula: Heat Energy (Q)

Alyk

unread,
Jan 20, 2014, 5:54:54 PM1/20/14
to anki-a...@googlegroups.com

Flavio Lerda

unread,
Jan 20, 2014, 6:03:22 PM1/20/14
to anki-a...@googlegroups.com
Thanks. Testing it now and I will let you know!
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/89d68c22-6d6e-485b-a6d4-8e3c2cd304f8%40googlegroups.com.

Nicolas Raoul

unread,
Jan 20, 2014, 8:43:57 PM1/20/14
to anki-android
By the way here is the enhancement request for native LaTeX rendering:
http://code.google.com/p/ankidroid/issues/detail?id=1298
Developers who use LaTeX might find it worth to have a look at MathJax.
Cheers!
Nicolas Raoul
> https://groups.google.com/d/msgid/anki-android/6650501517750294922%40gmail297201516.

Flavio Lerda

unread,
Jan 21, 2014, 4:24:24 PM1/21/14
to anki-android
I checked some of your cards and the LaTeX is actually invalid, which is probably why things do not work.

For example, the one you mentioned:
  Front: Formula: Heat Energy (Q)
  Back: [latex] $ Q = mc \Delta T $ [/latex]
should instead be:
  Back: $ Q = mc \Delta T $
Putting both is incorrect.

A few other I have noticed have a missing $, e.g.:
  From: Formula: Resistance (with Resistivity)
  Back: $ R = \rho \frac{L}{A}
should be:
  Back: $ R = \rho \frac{L}{A} $
instead.

This seemed at first inconsistent with what the documentation for the desktop app says,
but the reason is that your template is:

  <div style='font-family: Arial; font-size: 30px;'>[latex]{{Back}}[/latex]</div>

which means that the back is already within the [latex] ... [/latex], so it is

invalid to put it within the back field itself again, because that would expand to:

  [latex][latex]$ Q = mc \Delta T $[/latex][/latex]

and you are not allowed to nest LaTeX expressions.


The desktop client tries its best to show something, but AnkiWeb and AnkiDroid do not accept these invalid entries.

Basically you need to go through your deck and make sure:
1. '$' are matching;
2. there is no [latex] nor [/latex] in your back fields.

I hope this helps.
Flavio
>> email to anki-android+unsubscribe@googlegroups.com.

>> To post to this group, send email to anki-a...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/anki-android/89d68c22-6d6e-485b-a6d4-8e3c2cd304f8%40googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to the Google Groups
> "AnkiDroid" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to anki-android+unsubscribe@googlegroups.com.

> To post to this group, send email to anki-a...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/anki-android/6650501517750294922%40gmail297201516.
>
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android+unsubscribe@googlegroups.com.

To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/CACKRH2Aac4vtHceaGt2Chy3w1HS6XxzQrs3hHGOp2Gs-7aQ4jQ%40mail.gmail.com.

Alyk

unread,
Jan 22, 2014, 7:50:47 PM1/22/14
to anki-a...@googlegroups.com
Hey Flavio, thanks for checking my cards. I recently placed [latex] [\latex] in the card templates so I guess I forgot to re-edit those.

Let me just try to understand, to render the equations we need both the [latex] [\latex] command as well as the $ $? Is there a way to insert the $ $ into the template as well, or would that interfere with non-equation based cards?

Also, how did you go about checking the cards? Did you just use the browse option from anki or was it something else? Wondering if there is a faster way to check which cards have invalid latex commands.

Thanks again for your help!

Flavio Lerda

unread,
Jan 23, 2014, 4:59:48 AM1/23/14
to anki-a...@googlegroups.com
Hello,

I have been using the desktop note browser to find and fix these.

I did the following searches:
  deck:Physics back:*latex*
to find the notes the mention latex.

And:
  deck:Physics  back:*$* -back:*$*$*
to find the notes with at least one $ sign but not two of them.

You could also try something like:
  deck:Physics  back:*$*$*$*-back:*$*$*$*$*
to find the notes that have at least three $ signs but not four of them (and so forth).

This covers most of the errors I think, at least this type of errors.

Yes, the $ sign is necessary (it makes LaTeX treat the content between $ signs as a formula).
Without the $ signs, LaTeX will format the text, but not as a formula. LaTeX is not a system to
write formulas, is a system to write documents; it is just so happens that it also has a powerful
way to write formulas, since it is targeted at scientific documents.

I have not tried putting the $ signs in the template, but it should work, except for the fact that
some of your answers are not formulas, e.g.:
  Front: Question: What is temperature directly proportional to?
  Back: Average KE of the molecules
Generally, it is quite wasteful to format text using LaTeX, as it actually generates an image for
each of them, more time to sync, more space on your device, you cannot cut and paste easily
from them, etc.

Also note: some of your answers that are indeed formulas, are missing the $ signs, so they
are not formatted as such.

I hope this helps,
Flavio

--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android...@googlegroups.com.
To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/ca877562-f343-4e3d-aca0-1e3901a0a88d%40googlegroups.com.

Alyk

unread,
Jan 27, 2014, 9:40:36 PM1/27/14
to anki-a...@googlegroups.com
Hey Flavio, I'm back again.

So i reviewed the cards and made sure the latex was correct. Unfortunately I'm still having some problems. On AnkiDroid I'm getting a white box where the latex equation should be. I've attached a picture (1st attachment).

I went back to check the card and everything seems okay on my end. I've also attached a picture of the card layout and what I have written for the latex. (2nd attachment). That same flashcard is giving me the empty box on my phone. Any suggestions?

On Monday, January 20, 2014 1:43:29 PM UTC-5, Alyk wrote:
Screenshot_2014-01-27-21-16-29~2.jpg
Anki SS.png

Tim

unread,
Jan 29, 2014, 12:25:55 AM1/29/14
to anki-a...@googlegroups.com
Do you have media sync enabled on both Anki and AnkiDroid? 

Alyk

unread,
Jan 29, 2014, 12:31:13 AM1/29/14
to anki-a...@googlegroups.com

Well on the desktop version in Preferences>Network "Synchronize audio and images too" is checked and on AnkiDroid Fetch media on sync is also checked.

Flavio Lerda

unread,
Jan 29, 2014, 4:42:50 AM1/29/14
to anki-a...@googlegroups.com
I think the reason is that the LaTeX code is split on two lines.
There is a fix for that in the next major release (2.1) but for now the workaround would be to just put it all on one line (LaTeX already does that during rendering anyway).
--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android...@googlegroups.com.
To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/58d2a426-067f-45ac-b8db-396dbb265639%40googlegroups.com.

Alyk

unread,
Jan 31, 2014, 7:27:37 PM1/31/14
to anki-a...@googlegroups.com
I'm not sure what you mean by "split on two lines". Can you elaborate?

Flavio Lerda

unread,
Feb 4, 2014, 2:51:01 AM2/4/14
to anki-a...@googlegroups.com
Looking at the screenshot you attached, the "Back" field contains:

$ \omega = 2\pi f $
Units: rads/sec

which is on two lines.

Put it instead of one line:

$ \omega = 2\pi f $ Units: rads/sec

LaTeX just ignores newlines anyway (as you can see in the picture's "Back Preview") but there was a bug where AnkiDroid did not. The bug should be fixed in 2.1, but for now, that should solve your problem.

I hope this helps,
Flavio

Reply all
Reply to author
Forward
0 new messages