-
Notifications
You must be signed in to change notification settings - Fork 64
Previewing
texlab supports compiling LaTeX using a custom request (textDocument/build)
and by building a document after saving if configured to do so.
To enable building on save, simply set texlab.build.onSave to true.
Previewing can be configured in a variety of ways:
-
If you are using
latexmk, you can create a.latexmkrcfile and call your viewer accordingly. Afterwards, you can add the-pvflag to yourtexlab.build.args. -
If you want the PDF viewer to stay synchronized with the cursor position in your editor, you can instruct
texlabto execute a forward search after every build (texlab.build.forwardSearchAfter). To do so, you need to enable SyncTeX and update thetexlab.forwardSearchconfiguration. If you want to use this feature, we do not recommend the-pvcflag becausetexlabdoes not get notified bylatexmkwhen a document gets built. Instead, you can usetexlab.build.onSave.
In the following sections, we will give SyncTeX configurations for several popular viewers. If your viewer is not listed here, you can send us a pull request or create an issue.
If you editor supports the window/showDocument request,
then you can use texlab inverse-search --input <FILE> --line <LINE> to forward the inverse search to the editor.
In this section, we will give instructions for the texlab inverse-search subcommand.
If your editor does not support it or the path of texlab is not fixed/known, then you need to adapt the commands to your editor.
Some plugins can help with setting up inverse search:
-
Neovim:f3fora/nvim-texlabconfig -
Emacs:ROCKTAKEY/lsp-latex
We highly recommend SumatraPDF on Windows because Adobe Reader locks the opened PDF file and will therefore prevent further builds.
Add the following lines to your editor config:
{
"texlab.forwardSearch.executable": "C:/Users/{User}/AppData/Local/SumatraPDF/SumatraPDF.exe",
"texlab.forwardSearch.args": [
"-reuse-instance",
"%p",
"-forward-search",
"%f",
"%l"
]
}Add the following line to your SumatraPDF settings file (Menu -> Settings -> Advanced Options):
InverseSearchCmdLine = "texlab inverse-search --input "%f" --line %l"You can execute the search by pressing Alt+DoubleClick in the PDF document.
The SyncTeX feature of Evince requires communication via D-Bus. In order to use it from the command line, install the evince-synctex script.
Add the following lines to your editor config:
{
"texlab.forwardSearch.executable": "evince-synctex",
"texlab.forwardSearch.args": ["-f", "%l", "%p", "\"texlab -i %f -l %l\""]
}The inverse search feature is already configured if you use evince-synctex.
You can execute the search by pressing Ctrl+Click in the PDF document.
Add the following lines to your editor config:
{
"texlab.forwardSearch.executable": "okular",
"texlab.forwardSearch.args": ["--unique", "file:%p#src:%l%f"]
}Change the editor of Okular (Settings -> Configure Okular... -> Editor) to "Custom Text Editor"
and set the editor command.
For texlab inverse-search, you can use the following command:
texlab inverse-search -i "%f" -l %lYou can execute the search by pressing Shift+Click in the PDF document.
Add the following lines to your editor config:
{
"texlab.forwardSearch.executable": "zathura",
"texlab.forwardSearch.args": ["--synctex-forward", "%l:1:%f", "%p"]
}Add the following lines to your ~/.config/zathura/zathurarc file:
set synctex true
set synctex-editor-command "texlab inverse-search -i %{input} -l %{line}"You can execute the search by pressing Ctrl+Click in the PDF document.
Add the following lines to your editor config:
{
"texlab.forwardSearch.executable": "qpdfview",
"texlab.forwardSearch.args": ["--unique", "%p#src:%f:%l:1"]
}Change the source editor setting (Edit -> Settings... -> Behavior -> Source editor) to:
texlab inverse-search -i "%1" -l %2and select a mouse button modifier (Edit -> Settings... -> Behavior -> Modifiers -> Mouse button modifiers -> Open in Source Editor)
of choice.
You can execute the search by pressing Modifier+Click in the PDF document.
We recommend Skim on macOS since it is the only native viewer that supports SyncTeX.
Additionally, disable the "Reload automatically" setting in the Skim preferences (Skim -> Preferences -> Sync -> Check for file changes).
Add the following lines to your editor config:
{
"texlab.forwardSearch.executable": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"texlab.forwardSearch.args": ["-r", "%l", "%p", "%f"]
}If you want Skim to stay in the background after
executing the forward search, you can add the -g option
to texlab.forwardSearch.args.
Select your editor preset in the Skim preferences (Skim -> Preferences -> Sync -> PDF-TeX Sync support).
You can execute the search by pressing Shift+⌘+Click in the PDF document.
Add the following lines to your editor config:
"texlab.forwardSearch.executable": "sioyek",
"texlab.forwardSearch.args": [
"--reuse-window",
"--execute-command",
"toggle_synctex",
"--inverse-search",
"texlab inverse-search -i \"%%1\" -l %%2",
"--forward-search-file",
"%f",
"--forward-search-line",
"%l",
"%p",
],