[Tex/LaTex] Tutorial: TeXstudio add output path


How can I add (in TeXstudio and Windows) an output directory for all those (un-)necessary files (I don't need 'em, LaTeX does: .aux, .glo, .idx, .log, …) and automatically create this directory if it doesn't exist?

The pdf file can/should remain in the same directory as the main .tex file.

Best Answer

Follow these few steps:

  1. Create a batch file containing the command mkdir _output, which will create a folder named _output when run. Change _output to whatever name you like in both in this step and below. Save the batch file in a known and easy to access location.
  2. Add the folder containing the batch file to TeXstudio: Options -> Configure TeXstudio -> Build (you might need to enable advanced options), Commands ($PATH). See screenshot below.
  3. Add your output folder name to Log File under Additional Search Paths.
  4. Create a new User Command and enter the name of the batch file (not the full path) in the right-hand side of the row.
  5. In Meta Commands, add this newly created user command to Precompile.
  6. Add --aux-directory=_output to the end of PdfLaTeX command in Commands.

You're done! Enjoy a tidy tex-directory where all the "junk" is in the output directory. Only the .gz file remains in the tex-directory.

TeXstudio Configuration

I hope someone finds this useful...