# Placing Intermediate and Output Files in Another Folder

I am trying to figure out a way to cleanly separate the TEX files from all of the intermediate and output files. Various approaches I've tried, including the one described by ‘Bundle’ TeX output in a directory don't seem to work. I'm using TexMaker + MikTex (portable). Ideally, I would like my file/directory structure to look something like this:

• texproject
• texfiles
• 1.tex
• 2.tex
• intfiles
• 1.out
• 1.log
• 1.aux
• 2.out
• 2.log
• 2.aux
• pdffiles
• 1.pdf
• 2.pdf

Instead, what I have, is the jumbled-up mess where all of these files live in the same directory. I've tried setting the ouput-directory, for example, on pdflatex but this doesn't work. The pdf file still gets created in the same place but now it doesn't show up in the previewer. This should be pretty easy to solve but I've so far been unsuccessful. How can I set up my environment to use the above structure when compiling?

Update: I believe I have narrowed this down to something specific to TexMaker. If the desired aux and out directories are passed via the command line to pdflatex, everything builds as it should. Yet, I get numerous message boxes popping up saying that files can't be found and the PDF doesn't display in the internal viewer. I can't see any obvious options within TexMaker to change to address this. So, has anyone been able to make the scenario I'm describing work with TexMaker?

-
Have you tried `-aux_directory=../intfiles` and `-output-directory=../pdffiles`? That should work with MikTeX. – Peter Grill Nov 16 '11 at 16:41
@PeterGrill Well, it partially works; I've tried passing these parameters to PDFLATEX but there are still things that seem to be looking in the current directory for the output and intermediate files. Although build succeeds, numerous "can't find file" message boxes pop up and the internal pdf viewer can't seem to find the file – 3Sphere Nov 16 '11 at 17:36
Wondering if that has anything to do with .aux files from previous runs? I will try to test this later today when I am on my PC that has MikTeX. – Peter Grill Nov 16 '11 at 17:48
@PeterGrill No, even when all aux files everywhere are cleared out it has this problem. Something (TexMaker?) is trying to write to a log file and can't find the file and the internal PDF viewer can't find the PDF; I'm thinking this is something TexMaker-specific because MikTex seems to build the files properly. – 3Sphere Nov 16 '11 at 17:58
Just tried that as well (using Win7+MikTex+Texmaker). Texmaker invokes pdflatex, which writes all files to the folders specified. Writing works and all files are created as they should. But then Texmaker tries to read and display the log in the integrated Messages/Log viewer and the pdf in the integrated pdf viewer and does not find the files. – matth Nov 16 '11 at 18:27

## 6 Answers

As suggested by lockstep, I write a short answer: AFAIK, this is currently not possible, because the path cannot be changed for the messages / log viewer and for the pdf viewer from within the Texmaker GUI. There is a feature request on the Texmaker issue list to make the path configurable: http://code.google.com/p/texmaker/issues/detail?id=97 Maybe you are lucky and in a later release this will be available. I personally would also use this new feature (and only backup the input folder, not the output folder).

-

Since Texmaker 3.4, you can specify the option "Use a build directory for output", which creates a "build" folder in your project folder, and saves everything but the .tex file there. See the manual Now you can also specify the output directory as an option to pdflatex as e.g. -output-directory pdf. But you will also have a copy of the pdf in the build folder no matter what. And I haven't found a straight-forward way to have the output file in the root folder, either.

(And I also have a .gz file in the folders, but that might be an option you can turn off.)

-
note that you then need to update your `biber` / `bibtex` command as `biber build/%` (respectively `bibtex build/%.aux`). Regarding the pdf as output in the root folder, I am using a symbolic link (`ln -s build/pdfName.pdf pdfName.pdf`). – ebo Oct 22 '15 at 9:50

For TeXstudio (since a fork from texmaker, it might be similar there):

1. Add the options `-aux_directory` and `-output-directory` to the latex pdflatex and other commands, if needed.
2. Change the appropriate lines (160 and 161 in my case) in the `texstudio.ini` file, in W7 usually located under

`C:\Users\username\AppData\Roaming\texstudio`

Modify the path for the two varables accordingly.

`Tools\Log%20Paths=C:\\\Users\\\username\\\AppData\\\Local\\\Temp`

`Tools\PDF%20Paths=D:\\\repos\\\pdf`

(double-backslashes by intention)

Enjoy!

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. A suggestion: Do us a favour and change your username to something more telling than "user1234". – Martin Schröder Jan 22 '14 at 9:40

In Texstudio, if you want to save outputs of latex in a directory (and thereby have the directory that contains your source files uncluttered, set the -output-directory option of pdflatex command in Tools → Configure TextStudio → Commands Change the value of PdfLatex the -output-directory option and output is the directory you need the output files to be stored. It can be any name and in any location, but make sure you give is the full path (or relative path).

pdflatex -synctex=1 -interaction=nonstopmode -output-directory=output %.tex

The Linux version of Texstudio (that I am using) does not support -aux-directory option.

After doing that, if the pdf preview does not work, refer to this solution.

-

If you are working on Linux, you might use symbolic links as a workaround, e.g. create the directories `../texfiles` and `../pdffiles`, then run the following script:

``````#! /bin/bash

for i in *.tex
do
ln -s \$(pwd)/\$i ../texfiles
done

for i in *.pdf
do
ln -s \$(pwd)/\$i ../pdffiles
done
``````

The script can be expanded to update the directories dynamically (needs to be called via `write18` or maybe a hook in TexMaker?).

-

In TeXstudio (2.10.8) we can set a subdirectory, in this example named "output", as follows:

Menu > Options > Configure TeXstudio ...

• Commands [Tab] > PdfLaTex. Add key/value switch `-output-directory=output`.

So my command changed from

``````pdflatex.exe -synctex=1 -interaction=nonstopmode %.tex
``````

... to ...

``````pdflatex.exe -synctex=1 -interaction=nonstopmode -output-directory=output %.tex
``````

If you are using other build commands aside from "PdfLaTex" then make analogous changes there. I'm only building against PdfLaTex so that's all I had to change.

• Commands [Tab] > External PDF Viewer. I'm using Foxit Reader, so in my case I changed from ...

`````` "C:\PROGRAM FILES (X86)\FOXIT SOFTWARE\FOXIT READER\FOXITREADER.EXE" "?am.pdf"
``````

... to ...

`````` "C:\PROGRAM FILES (X86)\FOXIT SOFTWARE\FOXIT READER\FOXITREADER.EXE"  C:\Users\John\Documents\Sda\Code\Markup\Latex\Examples\output\?rm.pdf"
``````

It would be desirable to only need a relative path, something like `\output\?rm.pdf`, but so far I've only been able to get it working with the hardcoded absolute path.

• Commands [Tab] > Biber (this is used for bibliographies with the biblatex package).

Change

`````` biber.exe %
``````

... to ...

`````` biber.exe -output-directory=output -input-directory=output %
``````
• Build [Tab] > Additional Search Paths. Add `\output` (with the backslash) to "Log File" and "PDF File" fields.

With your source MyExample.tex file loaded in the current window press F5 (TeXstudio Menu > Tools > Build & View). After the build completes the PDF viewer should correctly pickup and display `\output\MyExample.pdf`.

This combines and updates @SisayChala's and @user44553's answers.

-