Latex-workshop: SyncTex with Skim pdf viewer?

Created on 19 Nov 2017  路  10Comments  路  Source: James-Yu/LaTeX-Workshop

I would like to use Skim viewer to preview the tex document but I don't know how to configure the pdf sync command inside the Skim viewer since vscode is not in its preset config. I uploaded an screenshot to show where I am stuck.

screen shot 2017-11-19 at 10 01 25 am

Most helpful comment

Here is the full workaround, as a tip for aftercommings.

Firstly, make a symbol link in /usr/local/bin, since Skim only search /usr/bin and /usr/local/bin.

ln -sf /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron /usr/local/bin/vscode

Secondly, in the configuration of the LaTeX workshop extension, we have the following settings.

    "latex-workshop.view.pdf.external.command": {
        "command": "displayfile",
        "args": [
            "-r",
            "%PDF%"
        ]
    },
    "latex-workshop.view.pdf.external.synctex": {
        "command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
        "args": [
            "-r",
            "%LINE%",
            "%PDF%",
            "%TEX%"
        ]
    },
    "latex-workshop.view.pdf.viewer": "external",

Here, for displayfile, we need a script modified from displayline in $PATH.

Finally, in Skim, we give the following settings, for reverse sync.

Command: vscode
Arguments: -g "%file":%line

All 10 comments

The command is path to vscode binary, and argument is to tell vscode to open which file and the line no.
Ref https://sourceforge.net/p/skim-app/wiki/TeX_and_PDF_Synchronization/ how to get filename and line no, and find vscode documentation for how to specify file and line via command line.

While @innerlee provided a workaround, I would like to note that this extension does not officially support 3rd-party pdf viewers. Multiple previous issues have discussed this problem.

Which is a pity given how slow the international compilation/view cycle has become.

Here is the full workaround, as a tip for aftercommings.

Firstly, make a symbol link in /usr/local/bin, since Skim only search /usr/bin and /usr/local/bin.

ln -sf /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron /usr/local/bin/vscode

Secondly, in the configuration of the LaTeX workshop extension, we have the following settings.

    "latex-workshop.view.pdf.external.command": {
        "command": "displayfile",
        "args": [
            "-r",
            "%PDF%"
        ]
    },
    "latex-workshop.view.pdf.external.synctex": {
        "command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
        "args": [
            "-r",
            "%LINE%",
            "%PDF%",
            "%TEX%"
        ]
    },
    "latex-workshop.view.pdf.viewer": "external",

Here, for displayfile, we need a script modified from displayline in $PATH.

Finally, in Skim, we give the following settings, for reverse sync.

Command: vscode
Arguments: -g "%file":%line

This does not seem to update the file in Skim upon finishing compilation, or to switch to right location. That has to be manually (ctrl-alt-v), which means time wasted waiting and monitoring for the compilation to finish...

@vomout Skim can trace the chage of PDF file by it self.

@Liam0205 But not jump to the correct location (where the build was triggered). This is what SublimeText LaTeXTools does: it will open the PDF after the build has finished in the location where the build was triggered.

@vomout You might need to raise a new issue. : )

@Liam0205 , sorry for being slow, but where do you store your script displayfile? I suppose you have to make it executable and searchable? When you recompile, do you refresh the same instance of Skim or another instance will be opened?

Finally can you explain why we need displayline and displayfile and not /Applications/Skim.app/Contents/MacOS/skim?

Thank you!

@Liam0205 , I think I answered some of my own questions but not all: It looks like if I use /Applications/Skim.app/Contents/MacOS/skim, I'll get a fresh instance each time without the "--revert" option. It also doesn't let me go to a specific line.

Now what I'm still unsure about: Why can't we use displayline for the external command "latex-workshop.view.pdf.external.command" as well? This may make it easier for others to try without having to create the displayfile script and make it executable in a searchable location. I tested and it didn't work, but I'm unsure why, if it simply calls the command with the arguments. It wouldn't be a bad thing if upon opening the external view, you get to the right line right away. I also tried with %LINE% being replaced by 1, in the case the parameter isn't available, but it also doesn't work. So right now what I do is I always use the SyncTex command and never the Viewer command (ctrl-option-V).

What I tried:

    "latex-workshop.view.pdf.external.command": {
        "command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
        "args": [
            "-r 1",
            "%PDF%"
        ]
    }
Was this page helpful?
0 / 5 - 0 ratings