bookokrat icon indicating copy to clipboard operation
bookokrat copied to clipboard

Add file reload on changes (and maybe support for synctex)

Open bugzmanov opened this issue 9 months ago • 9 comments

From reddit: Can you support synctex and live reload upon change of contents (for instance when a latex or typst run writes/updates the PDF on disk). Then i can use it as the live previewer for vimtex and typst plugins in neovim.

bugzmanov avatar Feb 08 '26 14:02 bugzmanov

From u/krishnakumarg

Thank you. You might want to ping u/lervag (the creator of vimtex) once you have synctex and live reload ready.

Perhaps have a look at the Zathura and Sioyek codebase to just get an idea of how they implemented these features.

bugzmanov avatar Feb 09 '26 11:02 bugzmanov

I currently use tdf https://github.com/itsjunetime/tdf in combination with vimtex. Works good for my use case and has good behavior auto reloading the updated pdf. Maybe you can get some inspiration from there approach.

HoseaD avatar Mar 18 '26 15:03 HoseaD

@HoseaD I’m curious if tdf is just a better tool for this kind of work. Do you mind sharing your thoughts/experience ?

bugzmanov avatar Mar 18 '26 18:03 bugzmanov

@bugzmanov tdf is also missing synctex as far as i know and is quite simple. I just started using bookokrat today and really liked the experience so far. Also tried if i can use it for vimtex and found this issue then. I would really like to see bookokrat evolving, because it looks really promising for me!

HoseaD avatar Mar 18 '26 21:03 HoseaD

@HoseaD hi! synctex support has landed in main. You would need to set it up in settings (space+s) :

Image

I'm not a big user of Latex, so i've done some testing to make sure that it's working. but do let me know if you see any issues.

bugzmanov avatar Apr 12 '26 14:04 bugzmanov

@bugzmanov thanks for the work, but i found a little issue at least on my setup.

SyncTeX fails for \input files.

Description: I am trying to use Bookokrat as a PDF viewer for Neovim/VimTeX, but Synctex is failing for any content that isn't directly inside main.tex.

When I trigger a forward search from a sub-file (e.g., files/00_introduction.tex), Bookokrat's info bar simply says [INFO] SyncTeX: no match for 00_introduction.tex..., even though the line exists.

HoseaD avatar Apr 12 '26 18:04 HoseaD

@HoseaD multi-file sorry. i haven't though about this (i'm bad at latex) 🤦 the fix is in main. should work now. let me know if you find anything else. thanks for reporting!

bugzmanov avatar Apr 12 '26 20:04 bugzmanov

@bugzmanov the multi file support works good now, thanks a lot!

But i found another small bug. Forward search on \chapter{} jumps to the previous page

I'm running into an edge case with the SyncTeX forward search when using commands that trigger a page break, like \chapter{}.

The Issue: Performing a forward search exactly on a \chapter{} line jumps to the empty space at the bottom of the previous page, instead of the rendered header on the new page.

The Root Cause (SyncTeX quirk): Because \chapter executes a \clearpage under the hood, SyncTeX maps that single source line number to two different physical pages in the .synctex file:

Page N: As a vertical bounding box that seals the previous page.

Page N+1: As the actual horizontal text nodes where the title is printed.

HoseaD avatar Apr 13 '26 10:04 HoseaD

@HoseaD apparently this is a "well known" issue that doesn't have a good solution. based on my quick research most viewers don't address it. am i right ? i can add a "current page" bias to the search - i.e. when jumping it would reorder all possible results based on proximity to the currently opened page. or .. i'm open to suggestions :)

bugzmanov avatar Apr 13 '26 12:04 bugzmanov