VimTeX and Zathura
Compiling and Viewing TeX Docs
Synctex-searches work just fine by installing
zathura and all the dependencies from Arch official repository (libmupdf can be skipped) as long as we set the vimtex-clientserver (please refer to the first related configuration file below) which is specifically for vimtex-synctex-inverse-search.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.
Therefore, I then decided to just use zathura that was built from source as I would like 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 following dependencies (as available on Arch or in the official website of zathura itself) installed prior to compiling it from source:-
- gtk3;
- glib2;
- girara;
- xdotool (mandatory for
synctex); - libmupdf (as a needed library);
- zathura-pdf-mupdf (as its plugin and to be installed after
zathuraitself).
I then downloaded the latest version of [4] zathura (currently is 0.4.7), extracted it to ~/build directory, and run make install to install.
neovim, neovim-remote is also necessary for synctex function. Once installed, place the below line in init.vim file:-VimLlet g:vimtex_latexmk_progname= '/usr/bin/nvr'To be added into your
init.vimor.vimrcor.vimrc.localfile, depending on whether or not you use any distributions ofvim pluginsandresources. Do refer to the configuration provided bylervagbeforehand. Please ensure that the ‘lervag/vimtex’ plugin is installed.VimL"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " VIMTEX """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let &rtp = '~/.vim/bundle/vimtex,' . &rtp let &rtp .= ',~/.vim/bundle/vimtex/after' let g:tex_flavor = 'latex' " Starting to use vimtex and it needs several configurations to work correctly let g:vimtex_fold_enabled = 0 let g:vimtex_indent_enabled = 1 let g:vimtex_complete_recursive_bib = 0 let g:vimtex_view_method = 'zathura' let g:vimtex_complete_close_braces = 1 let g:vimtex_quickfix_mode = 2 let g:vimtex_quickfix_open_on_warning = 1 call vimtex#imaps#add_map({ \ 'lhs' : '<m-i>', \ 'rhs' : '\item ', \ 'leader' : '', \ 'wrapper' : 'vimtex#imaps#wrap_environment', \ 'context' : ["itemize", "enumerate", "compactitem"], \}) " Setting `vimtex-clientserver` is important for inverse-search if empty(v:servername) && exists('*remote_startserver') call remote_startserver('VIM') endifAlternatively,
vimtex-synctex-inverse-searchcan also be achieved by adding the following configurations:-open
.texfile with the below command:-ORbashvim --servername VIM filename.texplace this line in
.zshrcfile:-~/.zshrcalias vim="vim --servername VIM"*(A note for myself): To make it work when opening
.texfiles fromranger, add this line to the following file:-~/.config/ranger/rifle.confext tex, has vim = vim --servername VIM "$@"Additional Notes
The additional configuration above is not needed forgvimas it works out of the box.
Take note of the below line in this
.latexmkrcfile:$pdflatex = 'xelatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %S %O -verbose';This line will be responsible to act as the command in compiling a latex document to PDF automatically.
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 vim (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 amaplocalleaderinvimconfig file".Notice that in
zathura, it brings us to the page containing the sentence we previously pointed from vim.For
synctex-backward/inverse-search: In zathura, pressCtrl + 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 vim where it contains the word highlighted from zathura.
Watch the video below to see it in action (updated on 24 September 2020, and the editor used is VIM).
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.
Tentang Blog & Penulis
Linux dan perisian sumber terbuka, Virtual Machine, serta Typesetting system.Full Stack DevelopmentAnalisis Data
Sumber dari Wallpaper Cave.