taylormitchell / ankify_roam

A command-line tool which brings flashcards created in Roam to Anki.
MIT License
36 stars 6 forks source link

Import math from Roam #24

Open gavento opened 3 years ago

gavento commented 3 years ago

This is not a bug report but rather a report on how to get math formula import from Roam to Anki work.

  1. Get Markdown and KaTeX Support plugin
  2. Add the additional scripts from "KaTeX and Markdown Basic" (resp. Cloze) note types to your "Roam Basic" (resp. Cloze) note types. This needs to be done both for "Front" and "Back" separately.
  3. Within note type custom HTML, change the delimiters settings to consider $$ delimiter as inline:
            delimiters:  [
                {left: "\\[", right: "\\]", display: true},
                {left: "$$", right: "$$", display: false},
                {left: "$", right: "$", display: false}
            ],

    This change needs to be done in both "Front" and "Back" and both "Basic" and "Cloze".

Note: Without 3., all the math imported from roam is rendered as displayed math (every math formula on its own line) since Roam uses $$...$$ as math delimiters. This is against LaTeX conventions but ah well ... The \[x^2\] delimiters are added here to allow displayed math in your Anki style (although Roam does not have displayed math).

This works for me in AnkiDroid, on AnkiWeb and in the Linux client, no other customization of my Roam, ankify-roam, or Anki was not required.

Here's an example of the result: image

taylormitchell commented 3 years ago

Woah, thanks @gavento! I've been wanting to add support for this myself but figured it would be a lot of work so didn't get around to it. I'll give this a shot myself then maybe add this explainer to the docs

msf999 commented 1 year ago

Thanks for this! Any idea how to hide the ankify tag while using this? Once the KaTeX scripts are added to Roam's card types I can't hide the ankify tag..