visual-studio-codelatexpdflatextex-livelatexmk

How to hide extra/auxiliary files generated by pdflatex in Linux


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)?


Solution

  • 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