Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!).
–
N.N.Sep 29 '11 at 9:37

8 Answers
8

With MiKTeX and TeX Live you can use --output-directory=dir. This will put all output files including .log and .pdf/.dvi in this directory (and append it to the search path so that auxiliary files are found).

In MiKTeX you can additionally set --aux-directory=dir which will put only the auxiliary files in this directory.

Why not move.yaml is a part of arara by defauls? Also, can it create the folder stuff if it doesn't exist already?
–
Harish KumarFeb 4 '13 at 0:06

@Harish: personally, I'm not fond of moving files, I prefer deleting them (hence the clean rule instead). :) Since arara 3.0 is now released in the wild, I'm thinking of creating a contrib/ folder in the project repository to keep other rules that aren't in the default set. :) About the directory creation, I need to take a look at the flags of each command; if stuff doesn't exist as a directory, the file will be renamed as stuff.
–
Paulo CeredaFeb 4 '13 at 0:12

@PauloCereda ... moving files has the advantage that log files are kept when we need to search for errors. I would also vote for a move and for a feature to assure that the directory is created if not already there.
–
Bernd GlossMar 12 at 12:00

You could also use latexmk to do the job for you.
auxdir is the directory for all auxiliary files but not the PDF file.

latexmk -auxdir=/tmp test.tex should work. You can extend this to autocompile with latexmk -auxdir=/tmp -pdf -pvc test.tex

The manual man latexmk explains more about the auxdir parameter:

-auxdir=FOO or -aux-directory=FOO
Sets the directory for auxiliary output files of (pdf)latex
(.aux, .log etc). This achieves its effect by the -aux-direc‐
tory option of (pdf)latex, which currently is only implemented
on the MiKTeX version of (pdf)latex.
See also the -outdir/-output-directory options, and the
$aux_dir, $out_dir, and $search_path_separator configuration
variables of latexmk. In particular, see the documentation of
$out_dir for some complications on what directory names are
suitable.

Thanks a lot, I did not hear about latexmk before, it is fantastic and make life a little easier!
–
PHPstJan 31 '13 at 15:53

Nice idea, though as the documentation says, it only works with MikTex. If you have TexLive, not only are the files not put there, but latexmk expects to see them there and when it doesn't find them it returns an error.
–
StephenMar 17 at 17:47

You can do this using the filesystem. Here's a suggested workflow, which I'll illustrate with Bash/Unix, but which can be made to work on Windows: in your working directory, where you edit your Tex file and want your output to be produced, you have build, which is either a subdirectory, or a symlink to some build directory elsewhere.

Set up the directory:

Either mkdir build in the directory where you want to work, or create the symlink to Bash. If you use a subdirectory, then most flavours of Tex will be able to access resources in the working directory, as it is a parent directory.

If $FILE is the basename of the Tex file you want to compile, then ln -s "$FILE".tex build

If you are creating PDF output, then ln -s build/$FILE.pdf .

To run the Tex command, you can just run it in the build directory. Or you can create a wrapper for the executable (untested): with the following shell function you can have aliases such as alias pdflatex="runtexinbuild pdflatex" which will run in the builddirectory if it is there, otherwise give the usual behaviour.

Here is a TeXnicCenter-specific solution which will hopefully seem sound enough to the people claiming it's bad practice to have one single, huge repository for all LaTeX auxiliary files (which it probably is).

On the Build->Define Output Profiles menu, choose your standard build profile (say, LaTeX => PDF) and copy it to a project-specific profile. (Here, Dissertation.) Then add --aux-directory=directoryname to the command line arguments passed to MikTeX.

When compiling path/file.tex, this will create files as path/directoryname/file.aux, and so on. This should be enough of a compromise, I think.

EDIT: to work with BibTeX, this requires %tm to be changed to ./auxiliary/%tm in the command line arguments passed to BibTeX. This can cause some trouble if external "chapter" files are \included but this can be fixed by using \input. I suspect there's some deep reason for this but I don't know if there is another way around it.

You can move the auxiliary files only after the "complete" PDF output is generated. The "complete" means that the cross-reference is properly typeset.

Moving the auxiliary files will be easier if you create a make file (in Linux) or a batch file (in Windows).

An example of batch file (for Windows user) that not only compiles the input file several times (3 times should be enough) but also moves the auxiliary files to a specified folder at the end.

rem batch.bat
echo off
rem %1 TeX input filename without extension
rem %2 The number of times to invoke pdflatex in draftmode
rem %3 Folder name to which the auxiliary files will be moved
if exist "%~1.pdf" del "%~1.pdf"
if exist "%~1.tex" for /l %%x in (1,1,%2) do pdflatex --shell-escape -draftmode -interaction=batchmode "%~1.tex"
if exist "%~1.tex" pdflatex --shell-escape "%~1.tex"
if not exist "%~3" mkdir "%~3"
for %%x in (aux log out toc nav snm) do (if exist "%~1.%%x" move "%~1.%%x" "%~3")

%1 represents the TeX input filename without extension, %2 represents the number of times to invoke pdflatex in draftmode, and %3 represents the folder name to which the auxiliary files will be moved.

Note that pdflatex will be executed %2 plus one times in total.

Exercise:

Assume we have an input file named filename and we want to invoke pdflatex twice in draftmode and the auxiliary files will be moved to dir\subdir\.