latex-nvim-lazygit workflow

Time for a comfy and lazy resume workflow:

(I use nvim/st/dwm/zathura so you’d be adapting this to your own setup)

Template in a Repo

Get this latex engineering resume template I got from r/EngineeringResumes into a fresh git repo.

mkdir resume
cd resume
git init
wget https://cinardoruk.xyz/LatexResumeTemplate.tex

Why the git? Since a resume needs to be tailored to different companies we’re applying to, we’ll need a convenient way to manage different versions of our .tex file. What better way than to use git?

  • different branches for different companies,
  • commits for when we feel like a ‘quicksave/checkpoint’, so to speak,
  • we can merge one branch onto another when we need to ‘carry over’ changes between versions.

Make sure to get Lazygit as well. It makes the 90% use case simple git operations less of a hassle.

Compilation

Now, we want to

  1. be able to compile our file to a pdf
  2. recompile the pdf file automatically so editing is smooth (like hot-reloading)
pacman -S texlive-bin texlive-binextra texlive-latex texlive-latexrecommended zathura zathura-pdf-poppler

These packages will get us

  • a latex installation, and
  • the latexmk tool, which has a mode for watching a file for changes, automatically recompiling the document and updating the preview.
  • zathura, which is a very minimalist, keyboard-oriented document viewer with no borders/ui whatsoever
  • zathura-pdf-poppler the pdf plugin for zathura

Make sure to edit or create ~/.latexmkrc

Here’s mine:

$latex = "latex -synctex=1 -halt-on-error %O %S";
$pdflatex = "pdflatex -synctex=1 -halt-on-error %O %S";
$pdf_previewer = "start zathura";
$pdf_mode = 1;

The Workflow

All the parts are in place.

Open up 3 terminals in the resume directory, and,

$ nvim resume.tex
$ latexmk -pvc resume.tex
$ lazygit

Voila!

latex-nvim-lazygit workflow

Saving output as…

Right now, latexmk is saving the compiled pdf as resume.pdf It’d be way more convenient if we had a directory that’d hold these output PDFs with whatever filename we want. Create the directory first:

$ mkdir resumeOutputs

Thankfully, we’re using a text editor with scripting support.

drop this in your .config/nvim/init.lua

-- save resume output as
function save_resume_output_as()
	local user_input = vim.fn.input("Enter filename: ")
	local source = '/path/to/resume/dir/resume.pdf'
	local dest = '/path/to/resume/dir/resumeOutputs/' .. user_input

	-- Add .pdf extension if not included
	if not dest:match("%.pdf$") then
		dest = dest .. ".pdf"
	end

	vim.fn.system({ "cp", source, dest })
	print("\nResume saved to: " .. dest)
end

vim.keymap.set('n', '<leader>rs', save_resume_output_as, { desc = 'Save resume output as...' })

<leader>rs will prompt you for a filename, and call save_resume_output_as(), which will copy the output to resumeOutputs/filenameYouEntered.pdf.

Lazymaxxing

Ideally, we want to reduce the number of steps required to go from 0 to ‘working on resume’. What if we type a single command and all relevant windows are opened?

we need three windows for

  • neovim
  • the resume preview
  • lazygit

add this to your .zshrc / .bashrc,

# RESUME EDITING WORKFLOW SETUP

RESUME_DIR="/path/to/your/resume_directory"
RESUME_FILE="$RESUME_DIR"/resume.tex

resume_preview() {
	cd $RESUME_DIR
	latexmk -pvc "$RESUME_FILE"
}

resume_edit(){
	nvim $RESUME_FILE
}

resume_git(){
	cd $RESUME_DIR
	lazygit
}

resume(){
	st -e zsh -c "cd $RESUME_DIR && latexmk -pvc $RESUME_FILE" &> /dev/null &
	st -e zsh -c "cd $RESUME_DIR && lazygit" &> /dev/null &
	nvim $RESUME_FILE
}

Just opening a terminal and typing resume will get you started now. Zero friction. Zero “Ugh now I have to open all these windows to get ready to do the work.”

Happy resume-ing!