TexStudio and Building in a Working Directory

I have been using TexStudio with Miktex on Windows for years and find it to be an excellent tool for writing, reviewing, and navigating highly technical documents involving large amounts of mathematics and defined structure.

I recently went through another round with the build system while trying to build in a working directory. Latex tends to write a lot of logs, index files, and intermediate files to the base directory and this can clutter things up. This is especially troublesome when working with GIT for version control.

Below are the steps I took in 2021 to get everything running again on Windows with Miktex. The majority of the files are written to a subdirectory “__BUILD__PDF__” which is automatically created if needed, and the directory is ignored in GIT.

My TexStudio commands now look like this:

And the build system

Miktex apparent uses the “aux-directory” option while rather than “-output-directory”. I add the new __build__pdf__ directory to the search paths for good measure, and the bibtex build command must be modified to find everything.

As a bonus, I create the custom user command

cmd /c if not exist "__BUILD__PDF__" ( mkdir "__BUILD__PDF__" ) else ( echo Build Directory __BUILD__PDF__ already exists.)

and this runs a command console in windows with “cmd /c <whatever>” so I can script checking for existence of the directory and create it needed. I then add the custom command to the start of the build sequence.

Finally, I add the line

__build__pdf__/

to the .gitignore file to ignore all the build files.