Collection of tools and stylesheet for scientific writting and learning (through Anki)
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:
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'.
Latin Modern
fonts from the Resources
folder on your system for the best experience.PacletInstall@"path/to/paclet"
in 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.**Knowledge
folder with mkdir ~/Dropbox/Knowledge
.
(You could make it anywhere, but would need to change the path in the paclet, sorry):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.Print to Console
it make notebooks more tidy by printing errors and logs to a seperate notebook.zotselect-mathematica.js
file in Zotero translators directory and set Export -> Default Format
to ZotSelect Mathematica
.Anki/MathematicaCloze.apkg
to Anki.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 cellsIn what follows you'll see an example employing the core capabilities.
Knowledge
folder and an empty notebook.TeXExporter
) to pdf directly. Press TeX
button from the toolbar and choose Quick PDF
. For more control go to More on TeXExporter
.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 command ExportToTeX[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:
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!