Skip to content

Instantly share code, notes, and snippets.

@TACHY0NN1X
Last active May 13, 2025 23:28
Show Gist options
  • Save TACHY0NN1X/09577046d4ef720014234067af62abd9 to your computer and use it in GitHub Desktop.
Save TACHY0NN1X/09577046d4ef720014234067af62abd9 to your computer and use it in GitHub Desktop.
A guide to setup LaTeX editing and compilation environment on Android, using neovim and tectonic in Termux.

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 PlayStore

All further steps to be followed in Termux.

Update Termux and Setup Storage

pkg up
termux-setup-storage

Install Neovim, and other packages

pkg install neovim nodejs python clang fd ripgrep lua51 luarocks lua-language-server stylua texlab

If anything is missing it'll just pop up once you run :LazyHealth later, then install it.

Installing Tectonic

pkg install tectonic 

Tectonic is a user focused LaTeX compiler, it's mentioned here, since no almost no setup required for running it, and works best. (I sadly did not get any sponsorship for this 🥲)

For further finer details please visit the project : tectonic

LaTeX Setup

Now there are two options:

  • Using the zip file provided with this gist
  • And for the untrustworthy (like me) : Complete Manual Setup

1. Using the zip file provided

Tbh I suggest using this method as all you have to do is :

mkdir -p ~/.config/nvim/ 
cd ~/.config/nvim/ 
mv <path/to/zip> ~/.config/nvim/
unzip zip_file
nvim 

And Voila !!! you've done it. Get on with Compiling your tex files. Check Usage.

2. Manual Setup : For the paranoid

I wouldn't suggest downloading any zip file off of the internet and push it to my .config directory (I wouldn't do it myself), but here I assure you there isn't any malicious code in it. There's also another option before executing neovim read-through all the files.

And for the unconvinced :

Installing LazyVim

mv ~/.config/nvim{,.bak}
git clone https://github.com/LazyVim/starter ~/.config/nvim 

For more details read-up : LazyVim

Installing plugins

Installing Vimtex

cd ~/.config/nvim/lua/plugins/ 
nvim vimtex.lua

Add the following snippet to vimtex.lua

return {
  "lervag/vimtex",
--  init = function()
    -- Vimtex configurations
    --vim.g.vimtex_view_general_viewer = "zathura"
--  end,
}

Setup init.lua

Add the following to ~/.config/nvim/init.lua

require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/snippets/" })

vim.g.vimtex_compiler_method = "tectonic"
vim.g.vimtex_view_general_viewer = "termux-open"

Enable LuaSnip

Enable LuaSnip in LazyExtras from the dashboard. To enable press 'x' on dashboard, press '/' this opens search, search for 'luasnip', press enter, by pressing n reach coding.luasnip, press 'x' to enable it.

Adding snippets:

mkdit -p ~/.config/nvim/lua/snippets/ 
touch tex.lua 

Add the following snippet to tex.lua

local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
--local rep = require("luasnip.extras").rep
local fmta = require("luasnip.extras.fmt").fmta

ls.add_snippets("tex", {
  s({ trig = "hw" }, { t("Hello, World !!!") }),

  s(
    { trig = "article" },
    fmta(
      [[
      \documentclass[12pt]{article}

      \title{<>}
      \author{<>}
      \date{}

      \begin{document}
      \maketitle

         <>

      \end{document}
      ]],
      { i(1), i(2), i(3) }
    )
  ),
})

And Done.

Usage

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.tex

In 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

Additional setup

Workaround for Mason installing error lua_ls :

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-server

Get pretty colors & fonts in Termux:

git clone https://github.com/adi1090x/termux-style
cd termux-style
./install.sh 
termux-style

Choose 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

@TACHY0NN1X
Copy link
Author

1000062673.mp4

Demo video.

@TACHY0NN1X
Copy link
Author

TACHY0NN1X commented Dec 21, 2024

For users who have installed Termux from FDroid, to get the pdf view working with an external pdf viewer, they need to uncomment the line
allow-external-apps = true from ~/.termux/termux.properties. This allows you to use a pdf viewer for viewing the compiled pdf.

@davidpcrd
Copy link

I've tried with a fresh install of Termux and it didn't work. i had error with the automatic install after running nvim. I had to run pkg install git to resolve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment