1

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

package1.sty
package2.sty
package3.sty
classFile.bst
classFile.cls
ttlps.def
logo.ps
... 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.
mythesis.tex
chapter01.tex
chapter02.tex

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

hugomg
  • 1,071

1 Answers1

2

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.
hugomg
  • 1,071
Daniel
  • 37,517
  • 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 08 '15 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 08 '15 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 08 '15 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 08 '15 at 21:36
  • The problem I am having now is that bibtex when I run bibtex out/mythesis, it fails with a I couldn't open auxiliary file chapter01.aux error. The only workaround I found was to use \input{chapter01} instead of \include{chapter01} but I'm not super fond of that... – hugomg Apr 09 '15 at 05:41
  • 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 09 '15 at 07:33