This is a LaTeX workflow setup I use to edit my notes. It heavily relies on snippets and custom definitions to streamline the process and make the workflow more efficient.
- Make a better readme.md.
- Automatically generate a Snippets.md file with all the translations.
- Improve modularity of the setup.
- Simplify the snippet definitions.
- Add support for internationalization (multi-language snippets).
- Integrate a well-defined and modular LaTeX preamble (still undecided).
Here's a quick preview of how the setup looks:
This setup is primarily in Spanish, and you'll need to make a few adjustments in three files to translate it into your preferred language. The goal is to eventually support multiple languages, but for now, here's how you can switch it up.
In your home directory, create a folder containing the following files:
my-preamble-latex
βββ letterfonts.tex
βββ macros.tex
βββ preamble.tex
Each of these files serves a specific purpose. If you're unsure, you can open them up and check the contents. Just ensure that you're able to compile LaTeX documents after making your changes.
To integrate these files into your LaTeX project, add the following lines to the preamble of your LaTeX document:
\documentclass{report}
\input{\string ~/my-preamble-latex/preamble.tex}
\input{\string ~/my-preamble-latex/macros.tex}
\input{\string ~/my-preamble-latex/letterfonts.tex}
\begin{document}
...
\end{document}
Note: You can modify the directory structure as you see fit, but make sure you include the files correctly to keep everything working.
One of the key features that makes this workflow efficient is LuaSnip. It's a snippets engine that helps you focus on writing the content of your documents while it handles repetitive boilerplate code. Here's an example of how it can be used:
If you're using Neovim with Lazy.nvim, make sure your file structure under ~/.config/nvim/
is set up correctly. Here's how to integrate LuaSnip into your Neovim setup.
Add the following to your lazy
configuration:
return {
"L3MON4D3/LuaSnip",
version = "v2.3",
build = "make install_jsregexp",
config = function()
local ls = require("luasnip")
ls.config.set_config({
enable_autosnippets = true,
store_selection_keys = "<Tab>",
history = true,
update_events = "TextChanged,TextChangedI",
region_check_events = "InsertEnter",
delete_check_events = "InsertLeave",
})
-- Lazy-load snippets for given filetypes
require("luasnip.loaders.from_lua").lazy_load({ paths = "~/.config/nvim/lua/plugins/snippets/" })
-- Set up key mappings for snippet expansion and jumping
vim.cmd([[
" Use Tab to expand and jump through snippets
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
smap <silent><expr> <Tab> luasnip#jumpable(1) ? '<Plug>luasnip-jump-next' : '<Tab>'
" Use Shift-Tab to jump backwards through snippets
imap <silent><expr> <S-Tab> luasnip#jumpable(-1) ? '<Plug>luasnip-jump-prev' : '<S-Tab>'
smap <silent><expr> <S-Tab> luasnip#jumpable(-1) ? '<Plug>luasnip-jump-prev' : '<S-Tab>'
]])
end,
}
Make sure you have your LaTeX snippets organized in ~/.config/nvim/lua/plugins/snippets/
. Here's an example structure:
~/.config/nvim/lua/plugins/snippets/
βββ snippets
β βββ tex
β βββ <anything-1>.lua # LaTeX snippets
β βββ <...>.lua # More snippets
β βββ <anything-n>.lua
You can structure the snippets however you'd likeβjust keep them organized to help you stay on top of things.
If you're new to LuaSnip, these resources will help you get started:
- A LuaSnip guide for LaTeX workflows
- Neovim setting up snippets with LuaSnip
- TJ DeVries' Introduction to LuaSnip video
- L3M0N4D3's snippet examples
If you find any issues or have suggestions for improvements, feel free to open a pull request. I'd appreciate your input!