0

Does someone have a minimal Makefile, that compiles a latex document using

  • pdflatex
  • bibtex
  • pdflatex
  • pdflatex

while putting all ouput files in a special output-directory to avoid cluttering the root-directory?

  • Why don't you use arara or latexmk? – Johannes_B Jan 07 '19 at 14:51
  • 2
    As soon as you mention output-directories, you do know that they make things much more complicated? A few extra files are nothing compared to the extra level of stress you have to make all programs find the files you hid away. – Johannes_B Jan 07 '19 at 14:52
  • I see. Well that is sad. In my case it's really a mess of a gazillion .mtc .aux .blg .maf .lot .nlo etc pp files :-/. I don't know about arara / latexmk – mcExchange Jan 07 '19 at 14:54
  • 3
    @mcExchange why do the files matter, I just checked and in the directory I use for writing answers for this site there are currently over 2000 aux files, occasionally I rm *.aux and remove them all but mostly I don't bother and they do no harm. If you move the output from tex to another directory, you need to configure everything else to be able to find them and read them back, it's possible but tricky to get right and serves no great purpose. – David Carlisle Jan 07 '19 at 15:06
  • Yeah, I'll give up. It's taking too much time already. My project is quite large and involves a lot of files therefore keeping an overview would be nice. A subfolder for compilation would be nice. – mcExchange Jan 07 '19 at 16:08
  • @mcExchange "I don't know about arara / latexmk" - then find out about latexmk (I use that, not arara) because it does exactly what you seem to want. It even has options to specify directories for temporary and auxiliary files, and advice in the documentation on how not to tie yourself up in knots if you really want to use them ;) – alephzero Jan 07 '19 at 16:12

1 Answers1

1

There's another question like this here:

How do I run bibtex after using the -output-directory flag with pdflatex, when files are included from subdirectories?

Here's my (slightly edited) answer:

Now, running something like

mkdir OUT
TEXMFOUTPUT="OUT"
pdflatex --output-directory OUT myfile
bibtex OUT/myfile
pdflatex --output-directory OUT myfile
pdflatex --output-directory OUT myfile

produces the expected results, and is fully scriptable.

If you are getting the message:

bibtex: Not writing to  $TEXMFOUTPUT/src.blg (openout_any = p).

then you need the following little hack. The issue is that bibtex ability to write to $TEXMFOUTPUT is restricted to avoid file overwriting and the bibtex command returns an error message.

Open the file texmf.cnf, dunno about windows, but on linux:

/usr/share/texlive/texmf/web2c/texmf.cnf (UBUNTU TEXLIVE)
/usr/share/texmf-dist/web2c/texmf.cnf (ARCH LINUX TEXLIVE)

find the openout_any = p line and change it either to a for always or r for restricted (p stands for paranoid fyi).