1

Is there a way to deal with the additional files generated when compiling a .tex file? I have found information here, but it seems you have to compile the .tex file in command line.

I would like to specify the directory for the .aux .soc .log .gz files so that when I compile the .tex document, only the .pdf output is placed in the folder containing the .tex file.

I am using TeXStudio and MiKTeX 2.9.

Thank you!

Prevost
  • 345

1 Answers1

1

If you are satisfied with the command line switch provided in your linked page, you can simply tell TeXStudio to use it: In the program options, go to the second section (possibly called Commands - I only have a German version available in which it is called Befehle) and add the command line additions to the PdfLaTeX, LaTeX or XeLaTeX edit, depending on what you are using.

Edit: This is how you do it, but let me just point out why I would discourage you of doing it.

First, you may choose an absolute directory. Then, you should never name two of your TeX files the same or there will be some confusion - if you load different packages, the first run might even fail. So this is a bad idea.

Since the commands are executed within the directory of the TeX file, it is easy to use relative paths. You may (see comment) decide to put it in a subdirectory (build or something similar [note that aux will not work, since it is forbidden as a directory name in Windows]). If the dir does not exist, it will be created automatically. This works nicely most of the times, unless you have some packages which rely on some kind of undisturbed path structure. For example, I did create some commands which allow me to easily split a tikzpicture into multiple smaller subplots. For this, an external file is created and then compiled. If you manually set a different -aux-directory, imports of resources in the externalized file will fail. So this approach has to be taken with care as well.

  • It's indeed called "Commands" in the English version. – samcarter_is_at_topanswers.xyz Sep 13 '16 at 15:57
  • @Benjamin Desef - I'm not sure I understand. Does that not choose the engine to compile the .tex document? I am reading the TeXstudio: user manual regarding the Commands... – Prevost Sep 13 '16 at 17:34
  • @Prevost: Yes, it does. For example, I've modified my command line to pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape --extra-mem-bot=1000000000 %.tex; the first two arguments should be there by default, I introduced the latter ones. And as said in your linked answer, you have to provide -aux-directory=<whatever> instead. The applications are automatically run in the folder of the TeX file, so you can use relative paths. You may also change the command to texify with the option --clean, if you want to delete all auxiliary files afterwards (which I do not recommend). – Benjamin Desef Sep 14 '16 at 08:09
  • @BenjaminDesef - And are you compiling the .tex document using the command line? Or are you compiling via TeXstudio. It sounds like from your answer you are instructing TeXstudio to compile it but it would be equivalent to calling that through the comand line...is this correct? – Prevost Sep 14 '16 at 11:42
  • @BenjaminDesef - when i pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape --extra-mem-bot=1000000000 %.tex into the PdfLaTeX Commands in Configure TeXstudio, I receive the error Could not start Build & Videw:PdfLaTeX: pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape --extra-mem-bot=1000000000 "Myfilename".tex – Prevost Sep 14 '16 at 11:50
  • @Prevost: Regarding your first question: Yes. This is just something basic about how applications run. It does not matter whether there is a command line or sth else, the Windows API functions that underly program execution (ShellEscape/CreateProcess) are all the same. Hence this edit in TeXstudio is kind of a one-liner "command line", with some special meaning for the percent character. Try the following: pdflatex -aux-directory=aux %.tex and make sure that in the folder of your TeX file, the subdirectory "aux" exists. Possibly my command failed with you because of insufficient memory. – Benjamin Desef Sep 14 '16 at 13:23
  • @Prevost: I have updated the answer a bit. Sorry for the last comment, don't call your directory aux. This is a forbidden name under Windows. Use a different name. – Benjamin Desef Sep 14 '16 at 13:34
  • @BenjaminDesef - This was enough to convince me not pursue, especially the issue about .tex files with the same name. This will happen, or at least I'm not prepared to take the steps to ensure it doesn't happen with multiple people. I asked this question originally because we had multiple .tex files in the same folder that were being combined. Really, I reorganized it and used \include to organize (didn't realize that sooner since I am newer to LaTeX. – Prevost Sep 15 '16 at 14:04