maplet

My Emacs org-mode / org-roam config as a student

Overall

This blog post explains my current configuration for how I use org-mode / org-roam in Emacs as a student. I write my notes and assignments in notes and then automatically generated agenda files from my course pages. My math notes are also written in LaTeX.

org-mode image

Source: orgmode.org

Platform and Compatibility

This configuration assumes you are running Doom Emacs (either emacs-mac for Apple Silicon or emacs from dnf or pacman). If you are using a different version platform, these configurations should still work.

I have tested this configuration on Fedora and Arch Linux as well as Apple Silicon OSX. If you want to use or modify any of the code snippets, make sure to place them in ~/.doom.d/config.el then either restart Emacs or run M x doom/reload.

Replace ~/Desktop/org-roam/ with your org-roam directory. Make sure to adjust anything using this path to your own setup.

org-roam

The configuration for org-roam is by far the longest and most complicated of my configuration snippets, but it is also very useful. This configuration handles the org-roam directory, completion, templates, and daily notes.

(use-package org-roam
  :init
  (setq org-roam-v2-ack t)
  :custom
  (org-roam-directory "~/Desktop/org-roam")
  (org-roam-completion-everywhere t)
  (org-roam-capture-templates
   '(("d" "default" plain
      "%?"
      :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+date: %U\n")
      :unnarrowed t)
     ("b" "book notes" plain
      (file "~/Desktop/org-roam/templates/20240110195916-book_template.org")
      :if-new (file+head "books/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+date: %U\n#+filetags: books")
      :unnarrowed t)
     ("a" "agenda note" plain
      (file "~/Desktop/org-roam/templates/20240114173032-agenda_template.org")
      :if-new (file+head "agenda/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+date: %U\n#+filetags: agenda")
      :unnarrowed t)))
  (org-roam-dailies-capture-templates
   '(("d" "default"
      entry "* %<%I:%M %p>: %?" ;; concat / create daily node
      :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n\nYesterday: [[file:%(my/org-roam-date -1).org][%(my/org-roam-date -1)]]\nTomorrow: [[file:%(my/org-roam-date 1).org][%(my/org-roam-date 1)]]\n\n"))))

  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         :map org-mode-map
         ("C-M-i" . completion-at-point)
         :map org-roam-dailies-map
         ("Y" . org-roam-dailies-capture-yesterday)
         ("T" . org-roam-dailies-capture-tomorrow))
  :bind-keymap
  ("C-c n d" . org-roam-dailies-map)
  :config
  (require 'org-roam-dailies)
  (org-roam-db-autosync-mode))

Agenda view

(setq org-agenda-files '("~/Desktop/org-roam/agenda"))

This snippet will automatically compile the org-agenda with all of the files in the agenda/ subdirectory of my org-roam directory. (Notes are created in this directory using templates).

Number of days per screen in org-agenda buffer

(setq org-agenda-span 7)

org-agenda-span sets the number of days to show per screen in the buffer. I prefer 7 days in order to view 1 full week at a time.

First day in org-agenda list

(setq org-agenda-start-on-weekday 1)

org-agenda-start-on-weekday is a bit more complicated but I just use 1 so that each screen in the buffer will always start on Monday.

Explanation

With org-agenda-span set to 7 and org-agenda-start-on-weekday set to 1, I can easily move between Monday-Sunday weeks using [ to go back a week in the buffer and ] to go forward.

LaTeX

(with-eval-after-load 'org
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 0.8))
  (setq org-format-latex-options (plist-put org-format-latex-options :density 600))
  (setq org-format-latex-options (plist-put org-format-latex-options :background "Transparent"))
  (setq org-preview-latex-default-process 'dvisvgm) ;; use svg for rendering
)

For a retina display, I had to configure LaTeX to avoid blurry rendering; however, this is also useful for custom styling of LaTeX (different font size, colors, backgrounds, etc) if you want TeX to stand out compared to plain text.

org-roam-ui

If you want a great UI interface to view your org-roam notes and connections, I highly recommend org-roam-ui.

org-roam-ui image Source: org-roam-ui Github

Here is my basic configuration:

(use-package! websocket
    :after org-roam)

(use-package! org-roam-ui
    :after org-roam
    :config
    (setq org-roam-ui-sync-theme t
          org-roam-ui-follow t
          org-roam-ui-update-on-save t
          org-roam-ui-open-on-start t))