TentativeConvert / LaTeX-Note-Importer-for-Anki

Add-on for the memory training program Anki, allowing to import and export notes written in LaTeX.
GNU Affero General Public License v3.0
32 stars 8 forks source link

The 2.1.50 version of anki seems don't need the [latex] and [\latex] label #12

Closed LeeLizuoLiu closed 1 year ago

LeeLizuoLiu commented 2 years ago

As title mentioned.

TentativeConvert commented 2 years ago

Thank you for your contribution. My understanding from https://docs.ankiweb.net/math.html is that Anki still uses the [latex] ... [/latex] command structure for full latex support. The newer versions alternatively support a combination of html and MathJax, where all basic text formatting is encoded in html and only mathematical formulas are encoded in latex and rendered using MathJax. For example, instead of

[latex]
  Let \(G^*\) be a \emph{group}.
[/latex]

one could now write:

Let \(G^*\) be a <i>group</i>.

But simply removing the [latex]-commands from the first version would break things. Thus, I believe your patch would break backward compatiblity.

Full support for the html-MathJax format would rather require creating a new kind of field in addition to plain and field, say html. Then either the importer would need to convert latex-commands within such fields into html (quite impossible in general), or users would need to format everything in these fields in html, so that the importer could import it verbatim (but then the tex file would no longer be compilable).

LeeLizuoLiu commented 2 years ago

OK. Thanks for your response. The reason that I submit this version is that the code with

[latex]
  Let \(G^*\) be a \emph{group}.
[/latex]

could change the color of font, which is different from the background, as shown in Figure. 2022-08-23-112420_1847x363_scrot

But once I remove the [latex], it works. It seems a workaround, though may cause further questions.

TentativeConvert commented 2 years ago

Yes, everything between [latex] and [/latex], including non-maths text, gets compiled into an image file, and then Anki displays that image. This indeed has many disadvantages, and I agree that the newer MathJax-format is superior for most use cases. But as I said, many existing decks that have been desigend for import with the LaTeXNoteImporter would simply break if imported without the [latex] ... [/latex] commands.

LeeLizuoLiu commented 1 year ago

OK, Thanks for your response. Is the [latex]...[/latex] added recently? Since I checked the notes created a year ago, there is no [latex]...[/latex] command.

LeeLizuoLiu commented 1 year ago

Further, the links from websites of Finn Christiansen are dead...

LeeLizuoLiu commented 1 year ago

OK, I just noitced I only need to replace the field by plain in my template.

snippet def "definition-Ank" b
\begin{note}
%%%%uuid
\begin{plain}
     `!p
import uuid
if not snip.c:
› snip.rv = uuid.uuid1()`
\end{plain}
%%%%Premise1
\begin{plain}
$1
\end{plain}
%%%%Consequence 1
\begin{plain}
$2
\end{plain}
%%%% Consequence 2
\begin{plain}
$3
\end{plain}
%%%% Consequence 3
\begin{plain}
$4
\end{plain}
%%%% Consequence 4
\begin{plain}
$5
\end{plain}
%%%% Consequence 5
\begin{plain}
$6
\end{plain}
%%%% Name
\begin{plain}
$7
\end{plain}
%%%% Context
\begin{plain}
$8
\end{plain}
%%%% Subcontext
\begin{plain}
$9
\end{plain}
\end{note}
$0
endsnippet