sanjib-sen/WebLaTex

Sync and View with external Viewer

Opened this issue · 3 comments

Hello,

is there a way to sync and view with, lets say, sumatraPDF in windows?

@MightyMirko Do you want to use the local VSCode instead of GitHub codespace? In that case sure.

Add this to .vscode/settings.json file:

"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.synctex.command": "C:/Users/<UserName>/AppData/Local/SumatraPDF/SumatraPDF.exe",
  "latex-workshop.view.pdf.external.synctex.args": [
    "-forward-search",
    "%TEX%",
    "%LINE%",
    "-reuse-instance",
    "-inverse-search",
    "\"C:\\Users\\<Username>\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"C:\\Users\\<U>\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js\" --ms-enable-electron-run-as-node -r -g \"%f:%l\"",
    "%PDF%"
  ],

In settings.txt of SumatraPDF, set

InverseSearchCmdLine = "C:\Users\<Username>\AppData\Local\Programs\Microsoft VS Code\Code.exe" "C:\Users\<Username>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js" --ms-enable-electron-run-as-node -r -g "%f:%l"
EnableTeXEnhancements = true

Reference:
https://github.com/James-Yu/LaTeX-Workshop/wiki/View#sumatrapdf

I am using it in a docker on wsl2 environment.

Instead of path to c i have to assign path to mnt/c?

{
    "name": "latex-docker-workspace",
    "image": "your-docker-image:latest",
    "remoteUser": "root",
    "hostRequirements": {
        "storage": "32gb"
    },
    "remoteEnv": {
        "user": "your-username",
        "sumatraPath": "/mnt/c/Program Files/SumatraPDF/SumatraPDF.exe",
        "vscodePath": "/mnt/c/Users/${user}/AppData/Local/Programs/Microsoft VS Code/Code.exe",
        "vscodeCliPath": "/mnt/c/Users/${user}/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js"
    },
    "features": {},
    "customizations": {
        "vscode": {
            "settings": {
                "latex-workshop.view.pdf.viewer": "external",
                "latex-workshop.view.pdf.external.synctex.command": "${sumatraPath}",
                "latex-workshop.view.pdf.external.synctex.args": [
                    "-forward-search",
                    "%TEX%",
                    "%LINE%",
                    "-reuse-instance",
                    "-inverse-search",
                    "\"${vscodePath}\" \"${vscodeCliPath}\" --ms-enable-electron-run-as-node -r -g \"%f:%l\"",
                    "%PDF%"
                ]
            },
            "extensions": [
                "James-Yu.latex-workshop"
                // Add other extensions if needed
            ]
        }
    }
}

This works in one direction for now