Writing Latex Documents in Emacs
Through various projects, assignments, and more, I end up writing a lot of LaTeX files. For academic works, this is often for papers, writeups, and problem sets. LaTeX is really obtuse and hard to write clearly in though! It's like HTML but worse!
One solution which I've tried before is Overleaf, an online editor for these document types. The problem with it though is that compiling latex on the website is much slower than on my computer. The ironic "disconnect" of the internet slows down the writing process. Not only that, but when wifi is unavailable doing work becomes impossible! Clearly no good at all. Collaboration is also a mixed bag. When everyone in a project is familiar with software magic like git, I would much rather use that as opposed to Overleaf's collaboration options.
There is also a second issue in the LaTeX workflow. In 99% of cases, I don't want or need the magic powers of LaTeX beyond the formatting formality and consistency it provides. I'd much rather edit text in plain text, or in an editor like Pages, and have it become LaTeX-looking. For better or worse, this convoluted formatting is the expectation in many spheres of communication.
How could we make a system which gives the convenience of writing plain text with the formatting super-powers of LaTeX when we need it?
The open source community to the rescue! Below is a continually-in-progress guide to the open source LaTeX landscape, and how I've navigated it.
# Tooling Options
- Tex Live
- MiKTeX // Tex Live
# What I use
- 1-2 sentence description, link to install instructions
- Gif of markdown
- Gif of latex
- Use-case examples
# Further Reading
- Static website processors
- Github Pages
- Plain Text
new post draft ^
old post ->
# Packages - Overview
First, we need to install some things. Namely a LaTeX distribution and Emacs itself.
# Install Homebrew
I use a macbook, so unlike most linux distributions I do not have a package
manager to manage various software related to programming. You can install
Homebrew by opening a terminal and entering:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)""
alternatively, you can read about it more at Brew.sh
# * Install Emacs
$ brew tap railwaycat/emacsmacport
$ brew install emacs-mac
when it finishes, emacs will be installed.
# * Install MacTex
the best supported distribution of LaTeX on mac is MacTex, you can download it here: http://www.tug.org/mactex/mactex-download.html.
# * Install Emacs packages
Start by firing up emacs and performing the key stroke:
Command+x, and then
list-packages, then performing the keystroke:
Ctrl+s, then typing
use-package, then enter. Finally click "install".
then create the file
init.el in the folder
~/.emacs.d/. Put the following into it
(require 'package) (setq-default package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/") ("org" . "https://orgmode.org/elpa/")) package-enable-at-startup nil load-prefer-newer t) (package-initialize) (unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (use-package auctex :defer t :ensure t :config (setq TeX-auto-save t) (setq TeX-parse-self t) (setq TeX-save-query nil)) (use-package flyspell :config (add-hook 'text-mode-hook 'flyspell-mode)) (use-package olivetti :ensure) ;; company = complete-any, a completion backend (use-package company :ensure :config (add-hook 'prog-mode-hook 'company-mode) (add-hook 'tex-mode 'company-mode) (setq company-idle-delay 0.1) (bind-key "<C-tab>" 'company-manual-begin)) ;; sort company completions by usage stats (use-package company-statistics :ensure :config (company-statistics-mode))
then restart Emacs and the packages will auto-install.