Anki-android: Vertical align LaTeX images properly

Created on 13 Mar 2016  路  9Comments  路  Source: ankidroid/Anki-Android

I have created add-on for Anki that saves depth information from LaTeX and then apply it to images when they are displayed. You can look it at AnkiWeb or just see it's code at GitHub Gist.
latex
Now, I want to port it to AnkiDroid so I would see beautifully aligned images on all my devices. However, I have some problems with porting because I'm not familiar with AnkiDroid code.
First, if you see my code in Gist, you will found that I have wrapped Anki methods with my own functions which modifies their output, but there is no such tool in AnkiDroid. I can just patch already existing methods like matshch/Anki-Android@762717329e4d886ca00714f234f58bf0e95181c6 but I'm not sure is it OK or we should create some other way to do this.
Other trouble is enabling of this patch. I think it should be some option in settings like done for FEN, but how to implement it? Enabling of FEN just installs hook... Other way is to not create options and to check depth info every time and just ignore lack of this files.
Maybe I should create a filter on result of required methods? Then, it will be easy to solve both problems. What do you think about it?

All 9 comments

AnkiDroid doesn't render latex expressions, it just displays the images created by desktop so I don't think you need to do anything....?

I need to apply style to displayed images, like done in matshch/Anki-Android@762717329e4d886ca00714f234f58bf0e95181c6

Maybe there's a way you could do it with javascript in your card template? AnkiDroid doesn't have a plugin architecture yet and we tend not to merge changes like this.

I know, it looks very ugly now.
Is there any way to save information from compilation process and use it from JavaScript later?

A better way might be to just have a special field in your model where you store the rendered latex expression, then in your plugin you store the html there if the field exists. That way you don't need any javascript or changes to AnkiDroid.

I see your point, but with several formulas (like in example) it will be more complex...
Thank you for help, I will change my plugin so I will not use LaTeX processing in AnkiDroid at all, it will be just HTML.

Actually maybe you still need the javascript to prevent the raw expression from showing... I'm not even sure how that'd work

Thanks, good luck!

I think that I should replace formulas with images in source at compile time. It isn't as straightforward as first realisation, but it will be independent from other clients without add-on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

snowtimeglass picture snowtimeglass  路  5Comments

mikehardy picture mikehardy  路  4Comments

Mornon picture Mornon  路  5Comments

infinyte7 picture infinyte7  路  4Comments

noamraph picture noamraph  路  3Comments