Skip to content

Latex writing workflow

Tools

  1. Latex distribution: TexLive
  2. Compiling: latexmk

Vim plugins

  1. Ale: Linting & Fixing
  2. Coc: LSP
  3. Deoplete: Autocomplete
  4. Utlisnips: Snippets
  5. Vimtex: Latex tools
  6. ctags(Gutentags): tags
  7. Vim Surround: Make easier to add brackets:

Vim workflow

  1. Completion: Deoplete/Coc + Vimtex
  2. Snippets:

Quickly insert environments -> Vim snippets(f.ex fig + tab)

  1. Auto close environment:

press ]] in insert mode to auto-close an environment

  1. Mappings:

:h vimtex-default-mappings

cse: change an environment
dse: delete an environment
tse:toggle stared env and no-star env, e.g., change from equation* to equation and vice versa.
]]: close an environment (only work in insert mode, in normal mode, it will bring cursor to next subsection instead). After you have typed begin{ENV}, use ]] to auto-close it with \end{ENV}
  1. Jump between references + definitions:

See ctags documentation

:VimtexInfo: show all relevant info about current LaTeX project.
:VimtexTocOpen: show table of contents window
:VimtexTocToggle: toggle table of contents window
:VimtexCompile: Compile the current LaTeX source file and opens the viewer after successful compilation.
:VimtexStop: Stop compilation for the current project.
:VimtexClean: clean auxiliary files generated in compliation process.
  1. Live PDF preview with Okular/Zathura & Vimtex

:VimtexCompile

  1. Linting + Syntax check with Ale
  2. lacheck
  3. chktex
  4. Proselint
  5. Tex directives

Compile latex with xelatex

%!TeX program = xelatex

  1. Table of contents

Show table of contents: VimtexTocOpen

  1. Document compliation with vimtex & latexmk:

:VimtexCompile

  1. Motions
Move between section boundaries with [[, [], ][, and ]]
Move between environment boundaries with [m, [M, ]m, and ]M
Move between comment boundaries with [* and ]*
Move between matching delimiters with %

Snippets

  1. Automate every repetitive keystroke using vim snippets(In vim use UltiSnips)
  2. Create course specific snippets and load them on your .vimrc though a simlink: set rtp+=~/current_course

Latex math snippets

  1. mk: Inline math
  2. md: Displayed math
  3. Use subscript: A1 -> A_1
  4. Fractions:
// 	→ 	\frac{}{}
3/ 	→ 	\frac{3}{}
4\pi^2/ 	→ 	\frac{4\pi^2}{}
(1 + 2 + 3)/ 	→ 	\frac{1 + 2 + 3}{}
(1+(2+3)/) 	→ 	(1 + \frac{2+3}{})
(1 + (2+3))/ 	→ 	\frac{1 + (2+3)}{}
  1. Postfix snippets: F.ex v,. → \vec{v}

Math specific

  1. Use Sympy and Mathematica to evaluate mathematical expressions

Compiling and see(Hot reload) document

Use latexmk to compile latex document.

In vim use vimtex command: :VimtexCompile to automatically compile the latex document on save and hot reload document on the preferred PDF viewer(F.ex Zathura)

Searching in notes

Rg + RegEx

Drawing figures

Use Inkscape to draw figures and import them with latex into document

Grammar and Vocabulary

Use a key binding to automatically correct spelling mistakes without interrupting the flow

  • Press Ctrl + L to correct the previous spelling mistake

See vim specific documentation file for further spelling and grammar related tools.

Citations

Use Zothero as citation manager.

  • Zothero Browser extension for fast documentation.
  • Export Zothero resources to desired format(F.ex BibTex) and use them in the Latex document.

Resources

See special resources file: Resources file

Latex

Snippets

Vim as latex editor