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

3

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

Chinfest answered 28/9, 2018 at 7:43 Comment(0)
C
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

Cursed answered 2/2, 2019 at 17:5 Comment(1)
Would this move also the output .pdf file to %DIR%/aux? OP does not want that, if I understand correctly.Polarimeter
B
10

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.

Brookweed answered 16/2, 2021 at 23:55 Comment(1)
Would it slow down the next time compilcation?Plan
E
-2

You need to update your .vscode/settings.json file as follows:

        `{
        "name": "latexmk -c",
        "command": "latexmk",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-lualatex",
            "-outdir=%OUTDIR%",
            "-auxdir=%OUTDIR%/build",
            "%DOC%"
        ]
    }
  ],`

I've set /build as the directory where the auxiliary files will be generated. You can replace it with the name of the folder you prefer. No need to create the folder beforehand; it will be created automatically during compilation. Additionally, I've kept the -outdir argument because I want the PDF file to be generated in my main project folder. If you prefer to have all generated files (including PDF) stored in a separate directory from your main folder, you can ignore -auxdir and specify it directly in -outdir:

        `{
        "name": "latexmk -c",
        "command": "latexmk",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-lualatex",
            "-outdir=%OUTDIR%/build",
            "%DOC%"
        ]
    }
  ],`
Epaminondas answered 10/3 at 6:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.