PDF Preview in Visual Studio Code
In my setup I only installed LaTeX Workshop (version 8.7.2), without LaTeX Preview, and it worked out of the box (with MikTeX and the latexmk
package already installed).
I would recommend disabling LaTeX Preview and Markdown PDF (it sounds like you already tried that and it didn't work) then try to open the pdf in these other ways to see if they work:
- On the toolbar next to the file tab click on this button:
- Press
Ctrl + Shift + P
and start typinglatex workshop view latex pdf file
and click on it when it appears. - Edit: On the side bar, click on the "TeX" button, then "View LaTeX PDF". Try expanding the menu and try the different options.
- On the side bar click on this button to open the Explorer: , then click on the pdf file. If you see a message about it being a binary file click on something like "open anyway".
If none of these work, you have a problem with VS Code's pdf viewer. If only the last one works it's a problem with LaTeX workshop. If all of them work there's something wrong with the keyboard shortcut.
Update
For updated question:
It looks like the tasks.json
is set so that calling "update pdf" will call "build" before running, but you want calling "build" to call "update pdf" after running.
I think the tasks.json
should look like this:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run pdflatex",
"type": "shell",
"group": "build",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"_CFA.tex"
]
},
{
"label": "Run bibtex",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
},
"command": "bibtex",
"args": [
"-terse",
"*.aux"
]
},
{
"label": "update pdf",
"command": "${command:latex-workshop.refresh-viewer}"
},
{
"label": "Compile and update",
"group": {
"kind": "build",
"isDefault": true
},
"dependsOrder": "sequence",
"dependsOn": ["Run pdflatex", "update pdf"]
}
]
}
Here I have created a new task that calls "Run pdflatex" and then "update pdf" in sequence. I have also made it the default build tool, so it will run with Ctrl+Shift+B
. If you want to run bibtex
as well, you can add it to the "dependsOn"
field.
Note that LaTeX-Workshop's build recipe runs with Ctrl+Alt+B
rather than Ctrl+Shift+B
. To get that to work, you can remove latexmk
form the list of recipes by putting this in your settings.json
:
"latex-workshop.latex.recipes": [
{
"name": "pdflatex ➞ bibtex ➞ pdflatex × 2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
],
I installed the plugin LaTeX workshop
to compile, and Markdown PDF
to preview, which works fine for me.