7

I have seen answers to this similar question which suggest using latexmk -c or pdflatex -aux-directory=/some/temp/dir <additional options>. I prefer the latter because you can create a subdirectory without having to remove and generate files repeatidly. Currenlty, this option is "only implemented on the MiKTeX version of (pdf)latex". On the other hand, the former approach does not seem to work properly. I use LaTeX Workshop in Visual Studio Code which by default uses latexmk. To add the -c flag, I created the following receipe:

"latex-workshop.latex.tools": [
        {
            "name": "latexmk -c",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-c",
                "%DOC%"
            ]
        }
      ],

    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk -c",
            "tools": [
              "latexmk -c"
            ]
        }
      ]

If I first create the pdf file from latex source files and then add the -c flag for the next compiles, it removes the additional files properly. However, if you want to compile for the first time (when there is no pdf or auxiliary files available), it does not generate any pdf file and I should consider removing the -c flag. Even if you already have the pdf file and its associated files available, once you remove only the pdf file from the folder, the same problem occurs. Is there an efficient way to hide such auxiliary files (by removing them or preferably puting them in a subfolder) in Linux (or in vscode)?

rasul
  • 1,009
  • 9
  • 14

2 Answers2

15

I have the following entry in .vscode/settings.json:

"latex-workshop.latex.outDir": "%DIR%/aux",

It works quite well. All temporary files are kept in aux so compilation is fast but does not pollute my .tex files

Juan Leni
  • 6,982
  • 5
  • 55
  • 87
8

You can set that up in the options for LaTex Workshop whithin VSCode.

enter image description here

After enabling that option, and after a successful compilation, all the auxiliary files are deleted automatically.

Lucas Aimaretto
  • 1,399
  • 1
  • 22
  • 34