So I use vscode to write up most of my assignments, and sometimes I need to use tikz figures, and to make that process easier I use tikzfig and tikzit. At times, I edit the tikz files directly without the tikzit interface, but if I miss a semi colon and then try and compile vscode destroys my whole pdf, and I get an error code saying I have an invalid pdf structure. Does anyone know how to stop this from happening, other than just becoming a perfect coder who makes no mistakes?

  • Are you using LaTeX Workshop extension?
    – jak123
    Sep 18, 2022 at 3:40
  • Yes I am using latex workshop
    – Chris
    Sep 18, 2022 at 4:05
  • Try adding a step to back up your pdf to the recipe and see if that works. You can also try to add the --halt-on-error to the pdftex step. I don't have LaTeX currently installed to give you a full sample. Check recipes docs here: github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes
    – jak123
    Sep 18, 2022 at 4:54
  • 1
    Becoming a perfect coder is probably the best option. It is not expected that you don't make any mistakes, but it is expected when you make a mistake that you can find a way to fix it. You need to do that anyway, otherwise your TikZ figure will be missing or wrong.
    – Marijn
    Sep 18, 2022 at 13:18
  • 1
    Can't you delete the corrupted pdf and let it get rebuilt from scratch?
    – Teepeemm
    Sep 19, 2022 at 2:28

1 Answer 1


I couldn't type this as a comment, so try this to create a backup of your pdf before each run. I'm assuming you are running this through LaTeX Workshop:

  1. Open VS Code settings (Ctrl+Shift+P, then search for Open User Settings (JSON))

  2. Look for latex-workshop.latex.tools and add a new tool to the end of the list (if you are not on Windows, replace copy with the proper copy command, cp for Linux/mac):

        "name": "backup",
        "command": "copy",
        "args": [
  3. Look for latex-workshop.latex.recipes and add the backup tool to it. For example, you can modify the default pdflatex ➞ bibtex ➞ pdflatex × 2 as:

        "name": "backup ➞ pdflatex ➞ bibtex ➞ pdflatex × 2",
        "tools": [

This will create a backup file each time you run your recipe.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .