LaTeX and Neovim for technical note-taking
ejmastnak.com
ejmastnak.com
Although its main selling point is as a program for flashcards with spaced repetition, it comes with pretty much all the features of a good note-taking app, like tags, easy to organize, synchronization across devices (you can set up your own server), good interface for searching through your notes (which are stored in an Sqlite db if that matters), and yes, LaTeX. Not only that, it's also highly extendable with third-party plugins, so if there are features that you miss chances are there's a plugin for it. In other words, you can use it perfectly fine just taking notes. However, where it really shines is in all of this in combination the spaced repetition algorithm, which is now on steroids with FSRS[1][2]. The downside is that for this to be effective for the things you want to memorize, you'll have to write your notes to be suitable for a flashcard, but if you do it consistently you'll soon notice that you can store most of your notes in your head. Needless to say, any student would benefit greatly from this. Now, if that's too much work, you can still just use the scheduling to have it remind you of your notes. Either way, even as someone who sometimes goes out of his way to shoehorn everything into Emacs, I can't see a reason not to use anki for note-taking.
Edit: I should probably mention that I primarily use Anki on my desktop. The smartphone app might not be as good, though I wouldn't know because I haven't given it a good try yet.
[1]https://github.com/open-spaced-repetition/fsrs4anki/blob/mai...
1. Write an article so good I can publish it and look it over myself later on online. I did this last year with https://andrew-quinn.me/fzf/, for example.
2. Create Anki cards out of the material. Use the builtin Card Browser or even https://datasette.io/ on the underlying SQLite database in a pinch to search for my notes any time I have to.
I find Anki’s UI so clunky for technical notes!
I totally agree with the idea of having it all vanish. I’m still building it out, but I’m working towards an ‘eject button’ where you can download all of your notes into a CSV and get out of dodge if you choose!
Pohtia also means to ponder in Finnish, not just Norwegian, fun fact!
And thank you for the encouragement!
And you can't create those cards for existing cards. You need more comprehensive notes (like your class notes) to create those cards.
I keep a journal for work related stuff and a wiki/personal knowledge base for everything (both work and personal). I use Anki to memorize things I believe may be useful to have readily available and I use my wiki as an extended "long-term memory", sort of.
Obviously, if you're in class, you can't really spend that long on a single note. So in class I would usually just take notes (in Anki) without thinking about it too much, then rewrite them when I got home.
When browsing the web, I'll usually take screenshots (not bookmarks! though there are benefits to those too) when I see something interesting if I don't feel like putting it into Anki immediately. Then once or twice a week I'll go through my screenshots folder and either make proper flashcards or one-sided notes (which sometimes just means dragging the screenshot to the add window and pressing "add") of the stuff in there.
When watching a tutorial, I'll pause often and take my time writing notes if I feel like it's important. Otherwise I'll just take screenshots and decide later what I'll do with it, like above.
When it comes to tags, I'm hesitant to recommend the following because it's probably not "objectively" the best practice, but I organize my notes mainly by decks, and I don't bother at all with tagging them. I just found that it was too much of a hassle having to tag every card with multiple tags.
The key is really about finding joy in making the cards. I agree that the "Add" window isn't the most joyful experience, but I can live with it. Oh and I'll sometimes play around with stable diffusion to generate images to help me remember some of the stuff. Of course this will make creating cards take even longer, but it certainly adds to the fun!
The pitfall to watch out for with Anki is that it can become very time-consuming and feel like a burden when you have too many reviews. This might be something everyone has to figure out for themselves by trial and error, but if you're just using it to take notes without trying to memorize them, it's not something to worry about.
While I don't know of any Youtube videos dealing with this very specific thing, I think The Anking[1] has some of the higher-quality videos when it comes to Anki in general.
Either way, I'd love to hear about other people's workflows.
It's interesting that this post (or rather, the later post that discusses this) talks about the advantages of UltiSnips. The well-known vim-LaTeX posts written by Gilles Castel (RIP) relied pivotally on UltiSnips.
It's not just that UltiSnips is a snippet engine. There are many of those (including LuaSnip, the other snippet engine mentioned in the OP series of articles). It's that UltiSnips can dispatch arbitrary expressions to short python code sections, and python has a great scientific library. For example, it's trivial to write a `sympy` snippet that will simplify or compute a given expression and write the output in latex for you.
But UltiSnips works *terribly* with neovim [1] [2]. Why? Because UltiSnips uses python, and neovim's python interface is 100x slower than vim's python interface. There are design decisions for this and I'm not trying to say that neovim is bad. I use both vim and neovim. But I use vim+UltiSnips+vimtex for writing LaTeX.
LuaSnip has interpolation too. I suppose it would be possible to write more code that calls from LuaSnip to a system like sympy (or other). But that's work. On the other hand, I think it takes a true power user to actually want or use the fancy interpolation functions.
[1]: https://github.com/SirVer/ultisnips/issues/974 [2]: https://github.com/SirVer/ultisnips/issues/1533
I'm using neovim with UltiSnips (and VimTeX), and I don't really have any big issues with it. I'm not saying you are wrongm but I do think the problem may be somewhat exagerated.
But somehow this suggests to me that I might have been doing something wrong. I use vim+ultisnips+(your excellent vimtex) while you use neovim. Out of curiousity, do you specifically set your python provider for your neovim in your config?
Yes, I do. I use a dedicated virtual environment for neovim which I create with the following snippet; then I set the `g:python3_host_prog` accordingly [0].
mkdir -p ~/.local/venvs/nvim
python -m venv ~/.local/venvs/nvim
source ~/.local/venvs/nvim/bin/activate
pip install --upgrade pip
pip install pynvim
[0]: https://github.com/lervag/dotnvim/blob/c3169dd18f4396258f83c...I didn't start the editor wars, but the neovim team jumped in with both feet. They deserve the ire of those of us who never wanted to see vim forked in the first place, let alone a half-assed broken "neo" version.
For the record though, this slowness has nothing to do with Vim itself, or the low power of the netbook; it is purely due to inauspicious interaction between specific plugins and can be fixed at the .vimrc level if you are willing to debug.
The slowness I experienced for LaTeX files happened even without any third-party plugins installed, using a one-line .vimrc that only turned on syntax highlighting. So I think it is unfair to say "the slowness has nothing to do with Vim itself". Probably also "or the low power of the netbook" is unjustified, in the sense that the tips in :help tex-slow do likely solve the problem on computers a little beefier than my old netbook (which is probably more than 15 years old at this point). I mean, those suggestions are in the official Vim documentation presumably because they did work for someone.
Think of it this way: if the slowness of LaTeX syntax-highlighting were not a problem in Vim itself (where by "Vim itself" I'm including the vimscript files that ship with Vim, not just the executable), would it be documented in the official Vim documentation?
However, I do not mean to deny your actual experiences; I have seen all sorts of performance-related craziness that doesn't make sense, and I fully believe you when you say you had slow editing with near-empty .vimrc. I just find it baffling; for instance, here is a sample of my using vim in an older tablet, with latex syntax highlighting, UltiSnips, builtin terminal and w3m browser without any lag:
https://i.redd.it/p5h7ongm51541.jpg
So, baffling discrepancies; I wish software performance was more predictable.
Oh, absolutely! I should have said before that I edited many file types in Vim on that netbook and syntax highlighting was lighting fast on all types except LaTeX. Sorry if I gave the wrong impression. Unfortunately for me, LaTeX is by far what I most wrote at the time, so it was an annoying problem.
> So, baffling discrepancies; I wish software performance was more predictable.
Amen to that! I've even been on the other side of this issue, with some Emacs packages I've written. I've received reports of some operations being very slow that I've been unable to reproduce (even though I continue to use underpowered hardware because I value battery life more than speed —I'm typing this, in Emacs, on a 10 year old Chromebook!).
Disclaimer: I'm the author of VimTeX.
With mathjax, markdown is a near-ideal 80/20. Lately, just firing up Hugo (or any refreshable web interface to markdown) and scribbling away in markdown has been wonderful.
Every Markdown spec differs from others in one way or the other and there is no way to tell that if the Markdown documents I am writing today will convert to PDF, HTML, etc. in exactly the same way 10 years later as they are converting today.
Two Markdown specs may end up converting the Markdown into different types of HTML and PDF -- sometimes even with semantic changes like nested lists in one spec is broken list in another one. Nothing is more displeasing than seeing a carefully written nested lists appear as ugly code blocks within lists because a different Markdown spec does not support nested lists the same way as the first Markdown spec I was using. This is just one of many examples where Markdown for one spec can break in another spec.
If you are strictly going to stick with Hugo forever, then that's fine. But how many of us can guarantee that we want to keep using the same tool to render our Markdown for ever? I certainly can't! I really wish there was a simple documentation format that with a single spec with a large number of implementations -- something like the C89 of text formats. Is there one?
Djot has a single well-defined spec, and most of the basic formatting has the same syntax as (a) Markdown, so switching is pretty painless. It has as a main goal to be legible and visually aesthetic as-is, just like Markdown.
What Djot adds is its _predictability_. Nested formatting, precedence order, line breaks behavior, nested blocks, mixed inline and block formatting, custom attributes are all laid out precisely in the spec in a thought-out manner. Till this day I still can't remember how to put line break within a list item in Markdown (and I'm sure there're more than one way).
[0]: https://djot.net/
I have lately been rendering everything as HTML using hugo + mathjax.
> If you are strictly going to stick with Hugo forever, then that's fine. But how many of us can guarantee that we want to keep using the same tool to render our Markdown for ever? I certainly can't!
The problem I have is that I don't want to lock myself into one single Markdown renderer like Hugo or whatever it uses internally. I'd like the flexibility to change tools later without worrying that the new tool may break the rendered output.
Like I said, not even something as basic as nested lists are rendered the same way by all tools. What is rendered as nested list by one tool is rendered as a broken list with unexpected code blocks interspersed between them.
A single spec consistently implemented by all tools could fix these issues. Sadly such a spec does not exist in the Markdown world. That's really why I was looking for something like C89 of the Markdown world.
Github has been fairly stable as a markdown center of gravity. That works fine for me too.
For me, I don't find the need for 100 year compatibility to be a stopping point. 10-20 years is far away enough for me, otherwise the perfect becomes the enemy of good.
snippet lim<- "inverse limit" iA
\varprojlim
endsnippet
snippet o/ "Empty set" wA
\emptyset
endsnippet
However, whichever you prefer, I highly recommend looking into the following two snippet classes of mine: snippet !! "inline math mode postfix" A
\$$0\$
endsnippet
snippet "(\S+)!!" "inline math mode postfix" Ar
\$`!p snip.rv = match.group(1)`\$
endsnippet
snippet "([A-Za-z]+)@@" "Autoformatting common functions" rA
\\`!p snip.rv = match.group(1)`{$0}
endsnippet
Although they are very simple, I am extremely proud of them because they make math insertion so much easier: they turn math mode and calling macros into a postfix call, which is very natural for most of us. Try them and I promise they will help.To see how nice they are, to display $\log{\log{\log{x+1}}}$:
!!log@@log@@log@@x+1How do you do the free body diagrams though?
I couldnt see a section for those in the write-up.
I tried something like this when I was in university for Mech Eng.
In the end blasting through 1000’s of pages of paper notes and working examples by hand is what made things stick and helped me pass exams.
Its sort of like the saying “the ability to do the thing but the wisdom not to do it”
I cycled through every notetaking app and ended up on org-mode in end. Fancy tools don’t make you fundamentally better.
And I don’t think beautifully typeset LaTeX will help you learn better. (Although I love LaTeX and my bachelors and masters thesis were written in it.)
Where I'm coming from: I used to take org-mode notes sometime back and push them to GitHub. Everyone told me GitHub can render org-mode, so it is going to be a great experience when I want to read my notes later and when I want to share the notes with others. But sadly the GitHub org-mode parser is terrible. Instead of just using Emacs itself to parse org-mode files, GitHub has reimplemented some half-baked org-mode parser in Ruby that breaks in all sorts of edge cases. So I can still write my org-mode notes in Emacs and review them in Emacs but I cannot really share them easily with other GitHub users as the initial claims promised it to be.
For some formats that pandoc does not output, there are also specialised ox-format libraries.
There are even several exporters to Github-flavoured markdown. I personally find both ox-pandoc and ox-gfm very useful for that purpose.
https://orgmode.org/manual/LaTeX_002fPDF-export-commands.htm...
https://orgmode.org/guide/HTML-Export.html
I should add, this is `org-export-dispatch`, bound to C-c C-e by default. You can then press `lp` for PDF or `hh` for HTML.
Also, if you're interested, there are HTML themes here: https://github.com/fniessen/org-html-themes
For documents that others should read and write, I use something else (ms word/ppt/Figma.
I feel that Pandoc+Markdown is pretty much what I want. Markdown is quick at taking notes with a syntax far easier to use on the fly, and I have the ability to use LaTeX math and render with LaTeX if I need it.
I know Markdown has a million standards but I just stick with “Pandoc flavored markdown”.
That said, for stuff like tables I also prefer working with org-mode (and then exporting to latex).
For example, I've been in plenty of meetings where an individual will open Outlook or PowerPoint to take notes because deliveries tend to be presentations or emails. Nothing requires this, of course, but the fixed format tends to reach backwards and influence the choice other tools.
As a result, I imagine that note-takers in an academic setting will continue to use LaTeX for notes until the end product can be submitted in something else.
There’s also some tooling that makes LaTeX not wholly unpleasant to use like in-buffer previews in Emacs and Detexify for symbol search:
http://detexify.kirelabs.org/classify.html
Maybe Typst has tools like these too?
I agree that the plugin is best-in-class. Whenever I write LaTeX in Vim without the plugin installed I feel incredibly handicapped. (Also the documentation of the plugin is fantastic.)
Another option some of my friends like is Heynote (https://heynote.com), but, again, I can do the same with VS Code...
You can use in on their website or run the compiler locally just like LaTeX
Yeah, this is a "me" problem for sure. But the above scenario was nearly like that when it was just a pencil and paper for me.
[1]: https://typst.app/