My university has provided a thesis project template with tons of files in it. My current working directory looks a bit like this:

... lots of other stuff ...
mythesis.tex    <-- these are the only files I work with
chapter01.tex   <--
chapter02.tex   <--

I was wondering if there is a good way to move all those files "out of the way", without installing them globally (all these packages are only useful for this specific project). Is there a way to make my directory structure look a bit more like this one?

out/    <--- .pdf, .dvi, .aux, .log, etc go here
stuff/  <--- all the custom packages, logos, etc go here.

I managed to separate the output files by passing a --output-directory flag when I invoke latex but I have no idea if there is a way to move all the other things to a separate folder. The closest I managed so far was to cd into the stuff folder when running latex but that forces me reference all my tex files as ../chapterXX instead of chapterXX, even in include directives and things like that.

I'm wondering if there is a way to do what I want without needing to resort to extra tools such as snapshot or arlatex, as suggested in this other question

  • Related: Prevent pdflatex from writing a bunch of files
    – Werner
    Apr 8, 2015 at 16:18
  • Why don't you move all your .tex chapter files with into a new folder named Chapters. Then put \input{Chapters/chapter01} in your master file mythesis.tex to include them.
    – alesc
    Apr 8, 2015 at 16:22
  • @alesc: I am already splitting my project into chapters. The problem is all those extra files from the thesis template. sty packages, cls files, logos, etc
    – hugomg
    Apr 8, 2015 at 16:23
  • This is possible with MiKTeX, if you're under windows.
    – Bernard
    Apr 8, 2015 at 17:52
  • I'm on Linux :(
    – hugomg
    Apr 8, 2015 at 18:20

1 Answer 1


Note: The following works on all TeXLive-based distributions, but not with MikTeX.

I usually put stuff like this in a project-local texmf subfolder. To have pdflatex and others actually search this folder, it has to be added to the TEXINPUTS environment variable. I usually have a sourceme.bash file that I source in the shell:

export TEXINPUTS=./texmf//:${TEXINPUTS}
export BSTINPUTS=./texmf//:${BSTINPUTS}
export BIBINPUTS=./texmf//:${BIBINPUTS}

However, as I have started to do this in almost every project, I have recently added these lines to my login script, so that pdflatex looks for a ./texmf folder in every case.

If you are using a Makefile, of course you could this for the purpose as well:

export TEXINPUTS := ./texmf//:${TEXINPUTS}
export BSTINPUTS := ./texmf//:${BSTINPUTS}
export BIBINPUTS := ./texmf//:${BIBINPUTS}

The double slash at the end of a path lets pdflatex recursively search the respective folder, so you could maintain a complete TDS-compliant texmf-tree inside. Similar to TEXINPUTS for LaTeX style files, images, and \inputs, there are many more environment variables available. The most important are:

  • BSTINPUTS for BibTeX (and biblatex) style files.
  • BIBINPUTS for the .bib files.
  • TEXFONTS for additional (vector) fonts.
  • This doesn't put all the "output" files in a separate directory but I guess thats not a big deal now that all the input files are in a separate folder. Getting rid of the chaff becomes just a matter of doing a rm -f *.aux *.log #...
    – hugomg
    Apr 8, 2015 at 20:01
  • @hugomg: I didn't comment on the output part, as you have already solved it. --output-directory is the key. (I use it all the time.)
    – Daniel
    Apr 8, 2015 at 20:36
  • I'm having problems with dvips if I try to put things in a separate directory. Maybe it would work if I could change my template to use pdflatex directly.
    – hugomg
    Apr 8, 2015 at 20:47
  • Try to add the output directory itself to TEXINPUTS. You may also consult kpsewhich --show-path .pfa | less to debut the search path.
    – Daniel
    Apr 8, 2015 at 21:36
  • 1
    Hm... I remember I had that problem as well, but don't know exactly how I solved it. It may help if you invoke bibtex from the out folder, i.e. cd out;bibtex mythesis; cd-. If you are using biblatex anyway (which I have been doing for a couple of years now), you could also use biber, which provides an --output_directory option.
    – Daniel
    Apr 9, 2015 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.