VimTeX and Zathura

Compiling and Viewing TeX Docs


geeky stuff
#zathura | #latex | #vimtex | #synctex | #nvim | #pdf

I use [1] vimtex, a vim plugin that provides support for writing and compiling LaTeX documents and [2] zathura as the document viewer.

In the beginning, I was determined to stick to [3] MuPDF as the PDF viewer due to its fast and complete features despite being small and lightweight but I kept encountering unpleasant experiences while compiling documents where it always froze the screen of my laptop when I closed the viewer. As such, I then decided to just use zathura that was built from source as I would like it to have both synctex-forward-search and synctex-backward/inverse-search worked properly.

So basically, in order to have a complete functional zathura that enables full support of synctex, I need the below dependent packages (as available on Arch or in the official website of zathura itself) installed first before compiling it from source:-

  1. gtk3;
  2. glib2;
  3. girara;
  4. xdotool (mandatory for synctex);
  5. libmupdf (as a needed library).
  6. zathura-pdf-mupdf (as its plugin and to be installed after zathura itself); &

I then downloaded the latest version of [4] zathura.tar.gz (currently is 0.3.7), extracted it to ~/build directory, and run make install to install.

Please note that neovim-remote is also necessary for synctex function. Once installed, place the below line in init.vim file:-
let g:vimtex_latexmk_progname= '/usr/bin/nvr'

Now, how to do the synctex-forward-search and synctex-backward-search in zathura when compiling .tex documents with latexmk (the default compiler for vimtex)?

  • For synctex-forward-search: Go to nvim (if using this editor) where the .tex doc is opened and point to the sentence we would like to see in zathura, and then press \lv.
    The ‘\’ here means “Whatever key defined as a maplocalleader in nvim config file”.

    Notice that in zathura, it brings us to the page containing the sentence we previously pointed from nvim.
  • For synctex-backward/inverse-search: In zathura, press Ctrl + highlight (Left Click and select the word with touchpad/mouse), the cursor will then automatically be pointed to the front line of the .tex file in nvim where it contains the word highlighted from zathura.

Watch the video below to see it in action:-

Zathura can be customized with a simple config file. Save the config file as zathurarc in ~/.config/zathura directory, like the one I have [here].

Related configuration files are as follows:-

  1. init.vim (refer to the ‘VIMTEX’ section);
  2. .latexmkrc


Rujukan:


Kali terakhir halaman ini dikemaskini/disemak semula adalah pada .
Top