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

Handling of backslash in plain fields #4

Open tomtom opened 7 years ago

tomtom commented 7 years ago

When I import plain fields, \% gets imported verbatim. I'd have to just use %, which causes problems when typesetting the tex file via latex.

Are users supposed to use (1) \% or (2) % in plain fields? If 1, the import algorthm should remove the backslash. If 2, the manual should give some guidelines how users can typeset the tex file.

It would be nice, if the manual included some sort of template with all environments and commands defined so that the file can be imported and typeset via latex. (Or if the export included definitions for such environments and commands.)

Anyway, many thanks for this great addon.

Regards

TentativeConvert commented 7 years ago

To be honest, I'm positively surprised the add-on does anything even half-sensible with % used in a field. And I'm not quite sure what it ideally should do.

My initial impuls would be that users should expect (2), i.e. just %, to be imported as % in plain fields. If I understand correctly, this is indeed how the add-on currently behaves. To get things displayed correctly when running pdf-latex on your file, you could try to (re)define the \xplain fields such that the contents are wrapped in a latex verbatim environment. Something like:

\newcommand{\xplain}[1]{\begin{verbatim}#1\end{verbatim}}

(I haven't tested this.)

If you're mainly interested in importing "plain text", then you're probably better off without this add-on. In that case, it should be easier to type-set notes in a csv-file and use Anki's built-in importer. Anki's internal format is HTML, and type-setting plain text in LaTeX in order to later convert it to HTML seems a very round-about routine.