Curing LaTeX’s paranoia

To ease the maintenance of my PhD thesis I’ve split up the document source into several parts and placed them in a folder hierarchy that seemed appropriate (to me). The root is a folder named writings. Below that folder there is a folder for each chapter. For the purpose of this blog post I’ll refer to them as chapter_1, …, chapter_n. Each of these folders has a file chapter_i.tex and chapter_i_stub.tex. All images are contained under a folder images in writings. The stub files are used to build a single chapter. There is also a folder thesis which contains the files to build the complete document.

writings
-- chapter_1
---- chapter_1.tex
---- chapter_1_stub.tex
---- ...    
-- ...
-- chapter_n
---- ...
-- images
---- chapter_1
---- ...
---- chapter_n
-- thesis
---- thesis.tex

When trying to build the complete document however this gave an error message as follows:

! I can't write on file `../chapter_1/chapter_1.aux'.

The problem was that LaTeX is by default a bit paranoid about file handling. It’s however easy to cure this paranoia. First you’ll need to locate the texmf.cnf file. In my case it was in the folder /usr/share/texmf/web2c. If you’re using Ubuntu you can easily find the file by searching for it on http://packages.ubuntu.com and searching the package contents. I have found this to be a lot faster than searching your hard disk. (I also find this useful to see which texlive package I need to install to get a certain sty file.)

In this file you need to find the line that looks like

openout_any = p

As the documentation above this line explains, this setting determines which files LaTeX may open for output. By default it is set to p for paranoid. This means that only non-dotfiles in or below the current directory can be opened. As you can see in the tree structure above this is not the case here, so we will need to change this setting. I switch it to r for restricted. This means that only opening dotfiles is disallowed.

Update: If your doing this on Mac OS X with a standard installation of TeX Live then you will normally find the texmf.cnf file at /usr/local/texlive/YYYY/texmf/web2c/texmf.cnf, but you probably won’t want to edit this file. Just add the following line to the file /usr/local/texlive/YYYY/texmf.cnf

openout_any = r

Of course in the file names above you need to replace YYYY by the year of the TeX Live distribution you have installed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: