A simple setup guide to get a working environment for compiling and editing LaTeX documents on Android using Tectonic (Compiler), Neovim (Editor) with plugins for code completion and compilation in Termux. This can work on any other Linux distro with their respective package manager.
Install Termux from the recommended source i.e. F-Droid Or if it suits your taste GitHub. All further steps to be followed in Termux.
pkg up
termux-setup-storagepkg install git neovim nodejs python clang fd ripgrep lua51 luarocks lua-language-server stylua texlabAdditional recommendations
golang rust
If anything is missing it'll just pop up once you run :LazyHealth later, then install it.
pkg install tectonic Tectonic is a user focused LaTeX compiler, it's mentioned here, since almost no setup is required for running it, and is pretty straightforward. (I sadly did not get any sponsorship for this 🥲)
For further finer details please visit the project : tectonic
Now there are two options:
- Using the zip file provided with this gist
- And for the untrustworthy (like me) : Complete Manual Setup
Obselete, please set it up manually.
mv ~/.config/nvim{,.bak}
git clone https://github.com/LazyVim/starter ~/.config/nvim For more details read-up : LazyVim
cd ~/.config/nvim/lua/plugins/
nvim vimtex.luaAdd the following snippet to vimtex.lua
return {
"lervag/vimtex",
init = function()
-- Vimtex configurations
vim.g.vimtex_view_method = "general"
vim.g.vimtex_view_general_viewer = "xdg-open"
end,
}Add the following to
~/.config/nvim/init.lua
vim.g.vimtex_compiler_method = "tectonic"Lazyvim at the time of writing has disabled luasnip by default and nvim-snippets is the recommended way.
nvim-snippets is enabled by default.
Snippets directory: This is where all your snippets live
mkdir -p ~/.config/nvim/snippets/
touch tex.jsonAdd the following snippets to tex.json
{
"Inline Math": {
"prefix": "mm",
"body": [
"$${1}$"
],
"description": "Inline math mode"
},
"Display Math": {
"prefix": "dm",
"body": [
"\\[",
"\t${1}",
"\\]"
],
"description": "Display math mode"
},
"Environment": {
"prefix": "env",
"body": [
"\\begin{${1:environment}}",
"\t${2:content}",
"\\end{$1}"
],
"description": "General LaTeX environment"
},
"Article Template": {
"prefix": "ar",
"body": [
"\\documentclass{article}",
"",
"\\title{${1}}",
"\\author{${2}}",
"",
"\\begin{document}",
"\\maketitle",
"\t${3}",
"\\end{document}"
],
"description": "Template for article documentclass"
}
}And Done. For exact syntax required for configuring the snippets, do visit the nvim-snippets official documentation.
I'd suggest making a directory for writing articles, to keep it tidy.
cd ~
mkdir -p articles
cd articles
mkdir article_1
cd article_1
nvim test.texIn Neovim type article a pop-up will be shown. Press enter and snippet will be inserted, use <tab> to navigate jump points.
For compilation read-up :- Vimtex
TLDR:
<ESC> to enter NORMAL mode,
\ll to compile,
\lv to view pdf,
And the age-old joke, to exit Neo/vim :
:wq save & quit,
:q! quit without saving changes,
:q quit
Workaround for Mason installing error lua_ls :
mkdir -p /data/data/com.termux/files/home/.local/share/nvim/mason/packages/lua-language-server/libexec/bin/and then
ln -f -s "$(command -v lua-language-server)" /data/data/com.termux/files/home/.local/share/nvim/mason/packages/lua-language-server/libexec/bin/lua-language-serverGet pretty colors & fonts in Termux:
git clone https://github.com/adi1090x/termux-style
cd termux-style
./install.sh
termux-styleChoose whatever you like. I personally recommend using Tokyonight, also install Tokyonight colorscheme for Neovim. Thankyou for reading, Any suggestions and constructive criticism is welcomed, DM on Reddit
1000062673.mp4
Demo video.