atom-latextools icon indicating copy to clipboard operation
atom-latextools copied to clipboard

Support for Evince

Open edwinksl opened this issue 9 years ago • 11 comments

I saw that the LaTeXTools for Sublime Text 2 and 3 supports Evince, so I am wondering if its Atom counterpart would support Evince too.

edwinksl avatar Jan 26 '16 05:01 edwinksl

Eventually, yes...

msiniscalchi avatar Jan 26 '16 16:01 msiniscalchi

@edwinksl If you need something in the meantime, you can simply edit the package.

In atom, go to the package settings menu. Once you click on settings for the latextools package, you should see a button to 'view source'. Click it and find the file latextools/lib/viewer.coffee

line 62: okular_cmd = 'evince' lines 57-60:

    if keep_focus
      okular_args = ""
    else
      okular_args = ""

If you are familliar with diff:

58c58
<       okular_args = ""
---
>       okular_args = "--unique --noraise"
60c60
<       okular_args = ""
---
>       okular_args = "--unique"
62c62
<     okular_cmd = 'evince'
---
>     okular_cmd = 'okular'

timtro avatar Feb 01 '16 20:02 timtro

@msiniscalchi, please help. Sorry that I digress the matter but I want to write to the owner of latextools. The "ctrl+alt+b" is very hard to debug. Please add commands for "pdflatex" and "bibtex".

I haved used Latextools intensively. The current build command in Latextools "ctrl+alt+b" gives the "texify" command in MikTeX or "latexmk" in TeXlive or MacTeX. However this command (texify or latexmk) does not give good error analysis which is not clear enough to debug latex codes. I think it because `texify' combines many steps together, pdflatex and bibtex all together (I think). Many times I had to go back to a commannd line to run pdflatex and bibtex to debug the latex codes.

Could you please add choices to do "pdflatex" and "bibtex" separately so that the debug step is easier for us? This will be so wonderful.

Thanks very much

pxdu avatar Apr 10 '16 20:04 pxdu

@pxdu Sounds like you should open a new issue instead.

edwinksl avatar Apr 10 '16 21:04 edwinksl

UPDATE

The author(s) seem to have rearranged things in the newer version. There is now a base-viewer class and new viewers can be created extending that base. I quickly patched over the okular-viewer.coffee creating evince-viewer.coffee:

BaseViewer = require './base-viewer'

module.exports =
class SumatraViewer extends BaseViewer
  _getArgs = (opts = {}) ->
    args = []
    args

  forwardSync: (pdfFile, texFile, line, col, opts = {}) ->
    args = _getArgs opts
    args.push "#{pdfFile}#src:#{line}#{texFile}"
    args.unshift 'evince'
    @runViewer args

  viewFile: (pdfFile, opts = {}) ->
    args = _getArgs opts
    args.push "#{pdfFile}"
    args.unshift 'evince'
    @runViewer args

For some reason, (I'm sure it's obvious, I just haven't dug in to that part of the code) the viewers don't appear in the drop-down list in the settings. The only two options I saw were default and pdf-view. The default is selected in latextools.coffee. If the platform is windows, it defaults to skim-viewer, sumatra-viewer.mac and---uh oh---okular on 'other'. So, around line 316 in latextools.coffee change the switch to something like this:

            switch process.platform
              when 'darwin'
                @viewerRegistry.add ['default', 'skim'],
                  require './viewers/skim-viewer'
              when 'win32'
                @viewerRegistry.add ['default', 'sumatra'],
                  require './viewers/sumatra-viewer'
              else
                @viewerRegistry.add ['default', 'evince'], # Not Okular!
                  require './viewers/evince-viewer'

timtro avatar Apr 21 '16 16:04 timtro

@timtro: Thanks for grasping the intention of that!

A couple of small notes:

  1. The drop-down: Right now, it's populated with static text from the config object in latextools.coffee. I'm hoping that's a limitation that can be overcome, but I haven't yet had time to check into it.

  2. There's (in theory) a way to register custom viewers. It's not the most elegant, thing in the world but you can use this line:

    atom.packages.getActivePackage('latextools').mainModule.addViewer(name, cls)

Where name is the name corresponding to the setting (evince) and cls is the object. The intention here was to allow a way to add a viewer from the Init Script or elsewhere. Doesn't solve the drop-down problem yet though. You'd have to manually edit the Config find the viewer and change the text to whatever.

  1. I wonder how well that patched viewer is going to work. It looks like you've maintained the args.push "#{pdfFile}#src:#{line}#{texFile}" line in forwardSync which generates the Okular-specific forward sync command. I suppose Evince might read the "#{pdfFile}" part and ignore the rest. Basically, all you really need there, though, is "#{pdfFile}".
  2. In case any one is wondering, the reason Evince hasn't been added yet is that the means we have for supporting it is some Python-based dbus scripts, which require some testing in the Atom environment, etc. Okular support, by comparison, was relatively easy.

ig0774 avatar Apr 22 '16 14:04 ig0774

@ig0774 Thanks for clarifying. I really appreciate it. I don't know about how any of the Atom and synctex internals work, so I'm just cobbling together duct tape fixes.

You're quite right that my patched viewer is broken. It works only in the sense that it opens the window and shows the document. I spent the better part of a half-hour trying to figure out how synctex works (with evince) before getting frustrated and abandoning the endeavour. I think that's mostly a lack of good documentation, but I may have just been looking in the wrong places.

I express a special thanks for clarifying the reason Evince hasn't been added yet. In any case, I think I speak for a lot of people when I thank you for your effort in creating these tools. I'm also a fan (and frequent user) of your Sublime Text version.

If there's anything I can do to help, let me know.

timtro avatar May 05 '16 17:05 timtro

Please, consider the merge of PR #93

mario-tux avatar Jul 15 '16 11:07 mario-tux

Any updates on this?

edwinksl avatar Apr 20 '17 00:04 edwinksl

I would also be interested in an update. I noticed that the pdf-view package doesn't show the first page of my document because of a "includegraphics" line. Okular and Evince do. However if Okular is started I have to close it first to make it open a second time and display the file.

bcm0 avatar Apr 22 '17 20:04 bcm0

@adnion I also have that same bug with Okular. It is not a big deal, just a minor nuisance though. Perhaps you can create a new issue for that if there isn't already one.

edwinksl avatar Apr 22 '17 23:04 edwinksl