Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward Searching in Zathura Does not Correctly Zoom to the Specified Page #181

Closed
gkapfham opened this issue Jun 8, 2015 · 4 comments
Closed

Comments

@gkapfham
Copy link

gkapfham commented Jun 8, 2015

This issue is a follow-on from the ones that I previously created about forward searching in vim with vimtex and Zathura, created at @lervag's request. Before I go into the details about the problem that I am facing, I will share some of the configurations of the environments in which I have noticed concerns. Currently, I am running Ubuntu 14.04 LTS and I can reproduce the problems described in this issue with a new version of vim that I built from source a few days ago.

Here are some more details about this version of vim:

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:40:46)
Included patches: 1-52

Here is the version of vim that I recently compiled:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 31 2015 17:09:42)
Garbage after option argument: "-version"
More info with: "vim -h"

Here are some more details about this version of vim:

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 31 2015 17:09:42)
Included patches: 1-729

For reference, here is the version of zathura that I am using:

zathura 0.2.6
(plugin) pdf-poppler (0.2.4) (/usr/lib/zathura/pdf.so)

I have also created a minimal .vimrc file; you will notice that it is only slightly different than the one that people commonly use when reporting issues about vimtex. Also, please note that this version of the .vimrc file contains the set hidden command that has proven useful in getting some of my past minimal working examples to compile as expected with vimtex.

set nocompatible
filetype plugin indent on
syntax enable
set iskeyword+=:
set hidden

" change the mapleader from \ to , -- this makes it easier to perform compilation in LaTeX
let maplocalleader=","
let mapleader=","

call plug#begin('~/.vim/bundle')
Plug 'https://github.com/lervag/vimtex.git', {'for': 'tex'}
call plug#end()

" Starting to use vim-latex and it needs several configurations to work correctly
let g:vimtex_latexmk_options="-pdf -pdflatex='pdflatex -file-line-error -shell-escape -synctex=1'"
let g:vimtex_fold_enabled = 0
let g:vimtex_quickfix_mode = 2
let g:vimtex_quickfix_open_on_warning = 1
let g:vimtex_toc_resize = 0
let g:vimtex_toc_hide_help = 1
let g:vimtex_indent_enabled = 1
let g:vimtex_latexmk_enabled = 1
let g:vimtex_latexmk_callback = 1
let g:vimtex_complete_recursive_bib = 0
let g:vimtex_view_method = 'zathura'

I have also prepared a simple minimal .latexmkrc file that I used when preparing this issue.

$print_type = 'pdf';
$pdf_mode = 1;
$bibtex_use = 2;
push @generated_exts, "cb";
push @generated_exts, "cb2";
push @generated_exts, "spl";
push @generated_exts, "nav";
push @generated_exts, "snm";
push @generated_exts, "tdo";
push @generated_exts, "nmo";
push @generated_exts, "brf";
push @generated_exts, "nlg";
push @generated_exts, "nlo";
push @generated_exts, "nls";
push @generated_exts, "synctex.gz";
push @generated_exts, "tex.latexmain";
push @generated_exts, "run.xml";
$latex = 'latex --src-specials %O %S';
$pdflatex = 'pdflatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %O %S';

# If zero, check for a previously running previewer on the same file and update it.  If nonzero, always start a new previewer.
$new_viewer_always = 0;

# How to make the PDF viewer update its display when the PDF file changes.  See the man page for a description of each method.
$pdf_update_method = 2;

# When PDF update method 2 is used, the number of the Unix signal to send
$pdf_update_signal = 'SIGHUP';

add_cus_dep('nlo', 'nls', 0, 'nlo2nls');
sub nlo2nls {
  system("makeindex $_[0].nlo -s nomencl.ist -o $_[0].nls -t $_[0].nlg" );
}

# vim: ft=perl

The vast majority of the LaTeX documents that I write are divided into multiple files. I followed the vimtex guidelines to add headers to the top of a subfile so that it is clear which file is the main file. To reproduce the fault that I am having on complex LaTeX documents, I have produced the following minimal working example.

First, there is a file that is called minimal.tex:

\documentclass{minimal}
\begin{document}
Hello world first page!
\newpage
Hello world second page!
\newpage
\input{sections/first.tex}
\end{document}

Then, there is the file called first.tex that is in the sections directory:

% vim: ft=tex
% !TEX root = minimal.tex

Hello world third page!!

I am going to write a lot of content now. Does this work?

It is worth noting that the issue reported here is also reproducible for me if the first.tex file is not in the sections directory but instead in the same directory as the minimal.tex file.

Here is what happens when I am using gvim with this minimal example. First, load the file minimal.tex and press \ll to start background compilation with `gvim'. This leads to the following debugging output as produced by vimtex.

b:vimtex : minimal
  root : '/home/gkapfham/working/writing/minimal-single'
  aux : '/home/gkapfham/working/writing/minimal-single/minimal.aux'
  log : '/home/gkapfham/working/writing/minimal-single/minimal.log'
  out : '/home/gkapfham/working/writing/minimal-single/minimal.pdf'
  tex : '/home/gkapfham/working/writing/minimal-single/minimal.tex'
  tmp : '/tmp/v9ZZ2YN/1'
  pid : '13107'
  cmd_latexmk_compile : 'cd ''/home/gkapfham/working/writing/minimal-single'' && max_print_line=2000 latexmk -pdf -pdflatex=''pdflatex -file-line-error
 -shell-escape -synctex=1'' -e ''$pdflatex =~ s/ / -file-line-error /'' -pvc -e ''$success_cmd = "gvim --servername GVIM --remote-expr \"vimtex\#latexm
k\#callback(1)\""'' -e ''$failure_cmd = "gvim --servername GVIM --remote-expr \"vimtex\#latexmk\#callback(0)\""'' -e ''$new_viewer_always = "0"'' -e ''
$pdf_previewer = "start zathura  -x \"/usr/local/bin/gvim --servername GVIM --remote +\%{line} \%{input}\" \%S"'' ''minimal.tex'' >/tmp/v9ZZ2YN/1 2>&1'

  base : 'minimal.tex'
  viewer
    xwin_id : '102760455'
    class : 'Zathura'
    cmd_forward_search : 'zathura --synctex-forward 1:1:''/home/gkapfham/working/writing/minimal-single/minimal.tex'' ''/home/gkapfham/working/writing/
minimal-single/minimal.pdf'''
    init : function('20')
    view : function('21')
    start : function('22')
    forward_search : function('23')
    latexmk_callback : function('24')
    latexmk_append_argument : function('25')
    focus_viewer : function('<SNR>46_focus_viewer')
    focus_vim : function('<SNR>46_focus_vim')
    xwin_exists : function('<SNR>46_xwin_exists')
    xwin_get_id : function('<SNR>46_xwin_get_id')

Please note that the cmd_forward_search is using the synctex-forward command to enable forward searching to work correctly. However, if I check the man page for zathura, I find that, at least for Ubuntu 14.04, this command does not exist! The only two relevant options are:

  -s, --synctex                        Enable synctex support
  -x, --synctex-editor-command=cmd     Synctex editor (forwarded to the synctex command)

I looked into compiling zathura from source and found that this is not (easily) possible on Ubuntu 14.04 LTS because of the fact that zathura's graphics engine requires a newer version of GTK than is default on my operating system. As such, forward searching does not work correctly when I try to run the \lv command in either the minimal.tex file or the first.tex file.

Is there any way for you to add code to vimtex that will also use the synctex-editor-command instead of relying on the newer command that is currently being used? While it seems very likely that this is not an issue related to vimtex, it is probably one that prevents many users from leveraging this functionality because they are required to use Ubuntu 14.04 and they cannot easily upgrade to a newer Zathura or version of GTK.

@lervag
Copy link
Owner

lervag commented Jun 8, 2015

Dear @gkapfham,

As expected, this problem seems to be due to your version of Zathura. I'm on Arch Linux, where I have Zathura version 0.3.3 installed. I've found a couple of external references about synctex support in Zathura:

  • Zathura changelog: Full support for backward and forward search appeared in version 0.2.7.
  • This blog post also states the same as the above changelog. The blog post also describes how to get both forward and backward search working, and was probably one of the main resources for my implementation.

However, as the above references say "full" support, there might be some limited support in version 0.2.6. Specifically, I am curious what happens if you try from the command line the following:

zathura -s minimal.pdf
zathura --synctex-forward 1:1:minimal.tex minimal.pdf

Specifically, I am curious if perhaps the problem here is that the -s flag is necessary for older versions of Zathura. If this is the case, then the issue might actually be solved by setting the an option:

let g:vimtex_view_zathura_options = '-s'

@gkapfham
Copy link
Author

gkapfham commented Jun 8, 2015

Hello, @lervag! When I type your suggested commands in the terminal window, I find the following output. Again, it seems that the command that vimtex uses for running forward searching does not exist in the version of zathura that is provided by Ubuntu 14.04 LTS.

zathura --synctex-forward 1:1:minimal.tex minimal.pdf
error: Error parsing command line arguments: Unknown option --synctex-forward

@lervag
Copy link
Owner

lervag commented Jun 8, 2015

I've investigated the source code of Zathura, which reveals that --synctex-forward was introduced in version 0.2.7, i.e. it is not available in version 0.2.6. Thus it seems the only solution is to get a newer version of Zathura, or to use a different pdf viewer. I'm very sorry for the inconvenience, but I'm afraid there is nothing I can do about this from the vimtex end.

If you want, you can clone the git repository yourself:

git clone git://pwmt.org/zathura.git

@lervag
Copy link
Owner

lervag commented Jun 18, 2015

I prefer to keep the open issues as a list of things to work on. Since I find this issue "resolved" in the sense that I can't fix it, I'm closing it.

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

No branches or pull requests

2 participants