Warning this project is currently under overhaul.
Note: Currently keyboard shortcuts work on Mac only.
The project consists of Mathematica stylesheet and two subpackages:
- TeXExport (for exporting TeX files from notebooks)
- AnkiExport (for exporting Anki cloze cards from notebooks)
The aim of this project is to use the amazing capabilities of Mathematica to create universal notebooks which can be used not only for calculations, but also for:
- collecting knowledge in decently styled notebooks (through Science stylesheet)
- reviewing structured knowledge (through integrated AnkiExporter)
- fast-drafting scientific papers (through integrated TeXExporter)
The side effects of this project are that your knowledge collected in Anki is no longer 'loose'. It belongs to the notebook and is identified by them (through CellID), hence can be continuously updated by updating the notebook.
Moreover, each Anki card acquires context from the location in the notebook and each deck acquires context from the notebook location under the root (Knowledge
) directory.
On the other hand, thanks to Zotero integration the notebooks are linked with references ("fixing" the citation problem in Mathematica on Mac).
Some of the steps can be omitted, but will result in minor issues/ decrease in functionality. The most essential steps enumerated. However consider doing all the steps to go 'all-in'.
- General
- Install
Latin Modern
fonts from theResources
folder on your system for the best experience.
- Download the latest paclet
- Run
PacletInstall@"path/to/paclet"
in Mathematica. - Open Mathematica
SetOptions[$FrontEnd, CreateCellID -> True]
. Make sure you don't forget about this step - otherwise we won't be able to identify Anki notes with Mathematica cells.** - Create a root
Knowledge
folder withmkdir ~/Dropbox/Knowledge
. (You could make it anywhere, but would need to change the path in the paclet, sorry):
- Run
CurrentValue[$FrontEnd, "DefaultStyleDefinitions"] = "Science.nb";
this will not only set the default stylesheet, but also ensures that figures exported with the built in TeX Exporter will work properly. - In Mathematica, Preferences -> Messages set Kernel Messages to
Print to Console
it make notebooks more tidy by printing errors and logs to a seperate notebook.
- Install
- Zotero
- Put the
zotselect-mathematica.js
file in Zotero translators directory and setExport -> Default Format
toZotSelect Mathematica
.
- Put the
- Anki
- Import Anki cloze note type
Anki/MathematicaCloze.apkg
to Anki.
- Import Anki cloze note type
- (Optional) Run the command:
SetOptions[$FrontEnd, InputAliases -> Join[InputAliases /. Options[$FrontEnd, InputAliases], {"at" -> TemplateBox[{"\[SelectionPlaceholder]", "Automatic", "\[Placeholder]", "\[Placeholder]"}, "EvaluatedAt", DisplayFunction -> (SubsuperscriptBox[ RowBox[{#1, StyleBox["\[VerticalLine]", SpanMinSize -> 1.5, SpanSymmetric -> False]}], RowBox[{"\[MediumSpace]", #3}], RowBox[{"\[MediumSpace]", #4}]] &)]}]]
once. To add the notion of "values at limit" in formatted cells
In what follows you'll see an example employing the core capabilities.
- We start of with manually creating an example directory structure under
Knowledge
folder and an empty notebook.
- Like usual, type in your
- Title cell CMD+1
- Section cell CMD+2
- Text cell CMD+7 with a styled inline cells CTRL+9
- EquationNumbered cell CMD+6
- At this level of complexity the notebook can be compiled (through
TeXExporter
) to pdf directly. PressTeX
button from the toolbar and chooseQuick PDF
. For more control go toMore on TeXExporter
.
- Add a tag to equation with CMD+J and reference it in text by writing the name of the tag and pressing CTRL+E.
- Copy a Zotero reference with CMD+SHIFT+C and insert it by pressing CTRL+Z
-
To generate a TeX file (or PDF) with bib references you need to save the
.bib
file from Zotero (preferably with Better BibTeX) next to the notebook and use the explicit export commandExportToTeX[TeXBibFile -> "BibFileName"]
then open the.tex
file and compile the project. Now you can do this faster (and have control over all the options) by pressing TeX -> Custom from the toolbar. This will insert the full expression in the beginning of your notebook. -
As a final example export something to Anki. This is done by marking the cell content with a keyboard shortcut CMD+D and pressing the
Anki
button while the Anki app is open. After the export is done you can start reviewing your material.
Here we use a fancy cell style (you can use a regular text cell as well) by pressing CMD+4 and TAB repeatedly.
Anki highlights will be ignored when exporting to TeX.
The commands for Anki highlighting, Zotero referencing and referencing equations (also any other content!) are available in the Mathematica
Insert
menu.
The complete notebook together with exported example .tex file and .pdf file can be found in
Example
folder.
Drafting TeX documents often involves captioned figures.
You can create them very quickly by using the Figure
function.
Which will automatically use the variable name as CellTag for referencing the equation.
If you'd run Figure@Plot[x, {x, 1, 3}];
directly, Mathematica would invent a two word tag for you, like "DistalHemps", which you can also use for referencing.
Figures get automatically updated without destroying the caption. Even if the figure (and the caption) are away from the
Figure
function that generates it.
Example command to control the TeX export:
ExportToTeX[TeXExportToPDF -> False,
TeXEmbedRefrencesBeforeExport -> False,
TeXWriteTOC -> False,
TeXBibFile -> "BibFileName",
TeXWriteAuthors -> False,
TeXWriteDate -> False,
TeXWriteTitle -> False,
TeXCustomCommands -> "\\setlength\\parindent{0pt}",
TeXLanguage -> None,
TeXShowLabels -> False,
TeXSetMargin -> "0.7in",
TeXLineSpread -> "1.15",
TeXFitEquations -> True]
Here the
"BibFileName"
is the name of theBibFileName.bib
file which ought to be located in the same directory.
Try inserting Author
and Affiliation
cells under the title, and export using ExportToTeX[TeXWriteAuthors -> True]
Not all cells get exported to Anki currently supported include:
- Text
- EquationNumbered
- Equation
- Figure
- Item1, Item2, Item3
- Item1Numbered, Item2Numbered, Item3Numbered
- Example, Exercise, Solution
- Question, Remark, Comment, FunFact
- Theorem, Proof, Axiom, Definition, Lemma
Highlighting shortcut appears not to work when caps-lock is enabled. Someone might think that CMD+SHIFT+D will do the job and try to press it... and then BANG! You've just learned that it doesn't work, but instead splits the selected text into another cell - useful. Serendipity.
The project relies heavily on the stuff found on http://mathematica.stackexchange.com/ hence, I don't own the credit for many of the functions which I merely customized.
Special thanks to @KubaPod for all the help along the way!