Skip to content

Instantly share code, notes, and snippets.

@TACHY0NN1X
Last active November 27, 2025 23:48
Show Gist options
  • Select an option

  • Save TACHY0NN1X/09577046d4ef720014234067af62abd9 to your computer and use it in GitHub Desktop.

Select an option

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

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.

Update Termux and Setup Storage

pkg up
termux-setup-storage

Install Neovim, and other packages

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

Additional recommendations

golang rust

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

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

Obselete, please set it up manually.

2. Manual Setup : For the paranoid

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_method = "general"
    vim.g.vimtex_view_general_viewer = "xdg-open"
  end,
}

Setup init.lua

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

vim.g.vimtex_compiler_method = "tectonic"

Snippets (Updated)

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

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

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 :

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