Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Setting up forward/inverse Synctex search with supplementary tex files #13

@YanniPapandreou

Description

@YanniPapandreou

Hi,

First of all thank you for creating this plugin, I was struggling to set up synctex on neovim properly and this just works!

I am using the default pdf reader Sioyek and synctex works in both forward and reverse directions when I am editing a single tex file. I am having issues however when I have a more complicated tex document with supplementary tex files. To be more clear I have a project structure like follows:

 doc
├──  chapters
│  ├──  chapter_1
│  │  ├──  intro.tex
│  │  └──  summary.tex
│  └──  chapter_2
│     ├──  intro.tex
│     └──  summary.tex
└──  main.tex

When I open main.tex in neovim and toggle knap autopreview with <F7> the document opens and I can use both forward and reverse search. However, if I go to a part of the pdf in Sioyek which was included in the main document via \input{chapters/chapter_1/intro.tex} and try to right-click to do an inverse search it does not jump to the appropriate file and instead neovim just prints something like:

jump spot at line 5 col 0 in /path/to/docs/./chapters/chatper_1/intro.tex

I cannot understand how to fix this from the docs. Also if I open the file chapters/chapter_1/intro.tex in neovim after launching the autopreview from main.tex and I press <F7> again then I can successfully use reverse search by pressing <F4> in Sioyek and right-clicking. However, now I cannot forward search from the supplementary file using <F8>, neovim prints out Viewer not currently active.

I have put on the top of my supplementary file % TeX root = ../../main.tex.

Is there a way to fix these issues?

These are my settings for knap:

local gknapsettings = {
  texoutputext = "pdf",
  textopdf = "pdflatex -interaction=batchmode -halt-on-error -synctex=1 %docroot%",
  -- textopdf = "pdflatex -jobname \"$(basename -s .pdf %outputfile%)\" -halt-on-error",
  textopdfviewerlaunch = "/home/yanni/Applications/Sioyek-x86_64_2df5964a856fc1f662dd4663896aeb21.AppImage --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --reuse-instance %outputfile%",
  textopdfviewerrefresh = "none",
  textopdfforwardjump = "/home/yanni/Applications/Sioyek-x86_64_2df5964a856fc1f662dd4663896aeb21.AppImage --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --reuse-instance --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",
  textopdfshorterror = "A=%outputfile% ; LOGFILE=\"${A%.pdf}.log\" ; rubber-info \"$LOGFILE\" 2>&1 | head -n 1",
  -- textopdfbufferasstdin = true,
  delay = 250
}

vim.g.knap_settings = gknapsettings

and my keymaps are the default ones suggested:

-- F5 processes the document once, and refreshes the view
vim.keymap.set('i','<F5>', function() require("knap").process_once() end)
vim.keymap.set('v','<F5>', function() require("knap").process_once() end)
vim.keymap.set('n','<F5>', function() require("knap").process_once() end)

-- F6 closes the viewer application, and allows settings to be reset
vim.keymap.set('i','<F6>', function() require("knap").close_viewer() end)
vim.keymap.set('v','<F6>', function() require("knap").close_viewer() end)
vim.keymap.set('n','<F6>', function() require("knap").close_viewer() end)

-- F7 toggles the auto-processing on and off
vim.keymap.set('i','<F7>', function() require("knap").toggle_autopreviewing() end)
vim.keymap.set('v','<F7>', function() require("knap").toggle_autopreviewing() end)
vim.keymap.set('n','<F7>', function() require("knap").toggle_autopreviewing() end)

-- F8 invokes a SyncTeX forward search, or similar, where appropriate
vim.keymap.set('i','<F8>', function() require("knap").forward_jump() end)
vim.keymap.set('v','<F8>', function() require("knap").forward_jump() end)
vim.keymap.set('n','<F8>', function() require("knap").forward_jump() end)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions