Starting with version 3.7, SumatraPDF can preview LaTeX documents that
you edit and compile inside WSL (Windows Subsystem for Linux). It
supports source-to-PDF and PDF-to-source navigation, the same as in a
setup where everything runs on Windows.
For general SyncTeX concepts, inverse-search command-line placeholders,
and Windows-native editor setup, see LaTeX integration.
How Previewing Works #
When you compile a
.tex file, most LaTeX tools can also generate a
SyncTeX file (.synctex or .synctex.gz) alongside the PDF. The SyncTeX
file records which line of the source corresponds to each piece of text
in the PDF. SumatraPDF uses the SyncTeX file to provide:- Forward search: jump from a line in the source file to the corresponding location in the PDF.
- Inverse search: jump from a location in the PDF back to the corresponding line in the source file.
Forward Search #
To trigger forward search from a WSL terminal, run:
/mnt/c/path/to/SumatraPDF.exe -forward-search "<path to .tex file>" <line> "<path to .pdf file>"
You can run the command by hand to see how it works. SumatraPDF opens
the PDF (if necessary) and highlights the location that corresponds to
the given source line.
Usually you configure your editor to run the command for you, with the
file paths and line number filled in.
The exact setup depends on your editor. For example, if you use VS Code
with the WSL Remote extension, you will first need a LaTeX language
server. One option is TexLab:
Once installed, add the following settings to
settings.json:{
"texlab.forwardSearch.executable": "/mnt/c/Users/path/to/SumatraPDF.exe",
"texlab.forwardSearch.args": [
"-forward-search",
"\\\\wsl.localhost\\Ubuntu\\%f",
"%l",
"\\\\wsl.localhost\\Ubuntu\\%p"
]
}
Note that TexLab launches SumatraPDF directly from Windows rather than
through a WSL shell. As a result, file paths must be written using the
\\wsl.localhost\<DISTRO>\... form.After configuring TexLab, open the Command Palette (
Ctrl+Shift+P) and
run LaTeX: Forward Search while editing a .tex file. TexLab fills
in the file paths and line number and starts SumatraPDF.Inverse Search #
Inverse search is configured in SumatraPDF. You specify a command that
SumatraPDF runs whenever you double-click a location in the PDF.
To configure it:
Ctrl + K,Set Inverse Search Command Linecommand in Command Palette.- Enter the command that should open your editor at a specific file and line number.

The command should have the general form:
"executable" [options] [arguments]
Whenever you double-click a location in the PDF, SumatraPDF fills in
the file and line and runs the command. Most often the command opens (or
focuses) your editor at the matching source location, but it can start
any program that takes a file path and line number.
For VS Code with WSL Remote, the following command opens a file at a
specific line:
"C:\Users\path\to\Code.exe" --remote wsl+Ubuntu --goto "<path to .tex file>:<line>"
Test the command by hand first. It should open (or focus) VS Code,
connect to the given WSL distribution, and go to the requested file and
line.
Once it works, configure SumatraPDF to use it by replacing the file path
and line number with
%f and %l:InverseSearchCmdLine = "C:\Users\path\to\Code.exe" --remote wsl+Ubuntu --goto "%f:%l"
Whenever you double-click a location in the PDF, SumatraPDF replaces
%f and %l with the source file and line number and runs the command.In inverse search, SumatraPDF passes file paths in the Unix form that
WSL uses (for example
/home/project/doc.tex or /mnt/project/doc.tex).
The Unix form is new in version 3.7. Earlier versions did not handle
WSL-style paths found in SyncTeX data, which often led to broken links
in WSL setups. With the new behavior, WSL-aware editors can resolve and
open the source files, as shown above with VS Code’s remote integration.