ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
7.17k stars 236 forks source link

Mouse hovering a reference doesn't show the reference #84

Closed A3EKV closed 3 years ago

A3EKV commented 3 years ago

Hello, The recently implemented feature--- When you hover on a referece, a figure, etc. to display it as adressed here: #43

However, this feature works on some PDF files (such as those who have hyperlinks on the reference numbers). But for some documents it doesn't work (see the attached PDF).

Thank you

document.zip

ahrm commented 3 years ago

Yes, it currently works only in documents with hyperlinks because the other method would produce too many false positives and would be very annoying. I will add this feature if I can avoid the annoying false positives (for example instead of just hovering maybe the user clicks on the link?).

A3EKV commented 3 years ago

I don't know how to implement the following idea but I believe it will work for all documents:

The application should allow the user in these cases, where there is no hyperlinks, to manually specify them. For example if the reference number is not recognized I will select it, then go manually to the references page and draw a rectangle around the desired reference, then I could save this (Maybe this could be saved as metadata to document, or in some JSON file, sorry forgive my ignorance, you know better) similarly to how highlights and bookmarks are saved? so now for that particular reference number I will simply hover over it using the mouse and it will pop up the view from the references view. The user can then repeats this for every references.

IMO, this is way better than nothing.

Thank you

A3EKV commented 3 years ago

@ahrm : I think this could be easily solved by building a feature based on the Bookmarks features itself. The user will bookmark each reference item in the references page and link it to a specific reference number manually. Then Sioyek should use these information to display the reference when one hovers over the reference number.

Is it doable? Thank you

ahrm commented 3 years ago

@ahrm : I think this could be easily solved by building a feature based on the Bookmarks features itself. The user will bookmark each reference item in the references page and link it to a specific reference number manually. Then Sioyek should use these information to display the reference when one hovers over the reference number.

Is it doable? Thank you

Well I think using portal feature would be much more natural. But the problem with this approach is that it is very inconvenient. The whole point of hovering to preview is to be able to quickly and conveniently see the referenced material but this is just too cumbersome. I think the best approach is to have the ability to explicitly request a preview (for example by clicking or something), that would avoid the annoying false positives.

A3EKV commented 3 years ago

@ahrm : I agree. I have tried to use portals but I can't wrap my head around them. I have seen the video recording you provided in your website but can't understand how they work. Could you please add more details in the README?

ahrm commented 3 years ago

@ahrm : I agree. I have tried to use portals but I can't wrap my head around them. I have seen the video recording you provided in your website but can't understand how they work. Could you please add more details in the README?

  • Another option that is very time-consuming is to add the cross-referencing manually to the PDF document using either Adobe Acrobat or PDF-Xchange editor (the latter works perfectly under linux using Wine).

Yes, I should definitely write a better documentation for portals. The idea is you can connect a point in a document (source) to a destination in the document. For example you can connect the location of the reference source to the place where reference is located (you do that by pressing p on the source location and then navigating to the destination and pressing p again). Now if you open the helper window (f12 by default) it automatically shows the destination of closest portal source to your current location.

A3EKV commented 3 years ago

Now, I think I understand how to create portals. thank you.

A3EKV commented 3 years ago

I have played now with portals but after a while an immediate concern will arise: If I have the following paragraph:

Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum [75] Lorem ipsum Lorem ipsum Lorem ipsum 
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem 
Lorem ipsum Lorem ipsum Lorem ipsum Lorem [23] Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem  

If I have linked both [75] and [23] to their respective location using portals in the bibliography it is not readily possible to show the reference of [75] because it will use the closest portal which in this case is for [23]. of course a work-around in this case is to scroll up to hide the line containg [23] and using portal to bring the location of [75] in the bibliography.

However, in cases where there at least two different references in the same line the workaround will not work.

I don't know how portals feature should be enhanced to account for these cases, maybe it should be more explicit by selecting only a portion of the text and open the portal by clicking on that selection as you have suggested in one of your previous replies.

ahrm commented 3 years ago

I added the feature to manually request overviews by right clicking on text in 89f5ef46b105de585de4175e530a8fbc59f09d63. Also now while viewing overviews, mouse wheel scrolls the overview window instead of the main window.

https://user-images.githubusercontent.com/6392321/138746944-9e889db3-4cf3-4dd9-86f8-f7b83a6dc70d.mp4

A3EKV commented 3 years ago

Thank you very much for implementing that, it is amazing. That's exactly what I was personally missing while using overviews but was too lazy to report it. Thank you again.

A3EKV commented 3 years ago

I have tried to scroll inside the overview using the mouse wheel , but it scrolls the current page instead.

Update: manually requesting the right click to show the overview doesn't work for me:

image

Searching the config files for the words 'right click' yields the following:

$ egrep -irn -A1 'right.+clic'
Binary file sioyek matches
--
prefs.config:14:# The color of highlight bar which is displayed when right click is pressed
prefs.config-15-vertical_line_color    0.0 0.0 0.0 0.1
--
keys.config:188:# toggle synctex mode. When in synctex mode, right clicking on a pdf launches the corresponding latex page.
keys.config-189-toggle_synctex      <f4>

It appears that the right click is already used.

ahrm commented 3 years ago

I have tried to scroll inside the overview using the mouse wheel , but it scrolls the current page instead.

Update: manually requesting the right click to show the overview doesn't work for me:

  • I have tried to disable the overview on hover.
  • When I right click, a vertical gray highlight is displayed: (see the screenshot below when I right click on Figure 1.2):

image

Searching the config files for the words 'right click' yields the following:

$ egrep -irn -A1 'right.+clic'
Binary file sioyek matches
--
prefs.config:14:# The color of highlight bar which is displayed when right click is pressed
prefs.config-15-vertical_line_color    0.0 0.0 0.0 0.1
--
keys.config:188:# toggle synctex mode. When in synctex mode, right clicking on a pdf launches the corresponding latex page.
keys.config-189-toggle_synctex        <f4>

It appears that the right click is already used.

Where do you right click? You should right click on 1.2 in the picture you posted. Also are you sure you are using the latest commit? Did you compile the code yourself? Because there are still no releases with that commit in this repository. An experimental build of the latest commit is here: https://github.com/hexomancer/sioyek/releases/tag/v0.31.115 . Also I recommend to turn off hover_overview in your prefs_user.config, that is: hover_overview 0

A3EKV commented 3 years ago

@ahrm : Thank you for the reply. Of course needless to say that I am pulling the latest commits and builiding Sioyek myself everytime.

The compilation fails because it can't find the sqrt function, maybe the cmath header is missing?

...
      |                  ~~^~~~~~~~~~~~
pdf_viewer/utils.cpp: In function ‘float standard_deviation(std::vector<_Ch_type>, float)’:
pdf_viewer/utils.cpp:1036:14: error: ‘sqrt’ is not a member of ‘std’; did you mean ‘sort’?
 1036 |  return std::sqrt(static_cast<float>(sum) / values.size());
      |              ^~~~
      |              sort

...

Update:

I have solved the compilation error by adding cmath to pdf_viewer/utils.h

ahrm commented 3 years ago

@ahrm : Thank you for the reply. Of course needless to say that I am pulling the latest commits and builiding Sioyek myself everytime.

  • well, it turns out there was an error during the compilation they I didn't see (because I've automated this through ansible).

The compilation fails because it can't find the sqrt function, maybe the cmath header is missing?

...
      |                  ~~^~~~~~~~~~~~
pdf_viewer/utils.cpp: In function ‘float standard_deviation(std::vector<_Ch_type>, float)’:
pdf_viewer/utils.cpp:1036:14: error: ‘sqrt’ is not a member of ‘std’; did you mean ‘sort’?
 1036 |  return std::sqrt(static_cast<float>(sum) / values.size());
      |              ^~~~
      |              sort

...

Update:

I have solved the compilation error by adding cmath to pdf_viewer/utils.h

You are right. This was fixed in dac8b1a62f3b14b12ead99204301e170a53edd9b .

A3EKV commented 3 years ago

After making that change, it works nicely. Except with a minor issue, if you want to quit the overview you need to right-click again. The Esc doesn't work in this case which is in my opinion counter-intuitive.

ahrm commented 3 years ago

After making that change, it works nicely. Except with a minor issue, if you want to quit the overview you need to right-click again. The Esc doesn't work in this case which is in my opinion counter-intuitive.

Fixed in f753b53f021e342a3bfdc6fa00c91c35743f4bc5 .

A3EKV commented 3 years ago

Fixed in f753b53 .

Another small issue is when you right click on a URL nothing happens of course but the mouse wheel doesn't work until you right click again or hit Esc key. Shouldn't URLs excluded from overview in the first place.

ahrm commented 3 years ago

Fixed in f753b53 .

Another small issue is when you right click on a URL nothing happens of course but the mouse wheel doesn't work until you right click again or hit Esc key. Shouldn't URLs excluded from overview in the first place.

Fixed in 211483c19112c47f6c3a82f81a88c6b3321bf8b8.