A short while ago I decided it was time to learn a little Latex as I want to produce some good looking documents. After many dead-ends I settled on using TexStudio to work with Latex. There’s no reason you can’t do just use a simple text editor but I prefer syntax highlighting and my spelling is terrible so I need a spell checker. My first document will be a re-working of my wife’s thesis. I plan on using Classic Thesis as a template but I’ll likely make some changes to suit my exact requirements.
To get started I downloaded the Classic Thesis package and then set about organizing things to my liking. That meant doing things like moving bibliographies to their own folder, deleting the alternative style and examples that are supplied, changing a few settings, changing the name of the images folder, etc. I ensure the project always builds after each change, most of them are just search and replace, though. One change I really want to make, however, is change where output files are generated. In software development you typically have something like two root folders, one for source and one for the built project. That allows you to just nuke the output folder and start again whenever you like. It also makes source code control a little easier as you can just ignore the whole output folder.
Changing where Output is Generated in TexStudio
Apparently in Latex speak these build and output files are called auxiliary files (some even have .aux extensions) and it looks at first glacce like they they though be easy to move, naturally though, it’s a bit of a mission if you are new to this. There is a section in the TexStudio manual and a question on Tex StackExchange that give about 80% of the answer each. Note that once you’ve made these changes every project you work on with TexStudio will work in this way. That’s not great, it should be on a per-project basis, but I can live with it.
The first instruction in the manual tells you to set the -output-directory=dir
setting on pdflatex. This is easy enough, you just go into the settings at Options -> Configure -> Commands
and update the pdflatex command. What it doesn’t tell you is that setting can’t go at the end of the line, it has to appear before %.tex
or it’ll be ignored.
The pdflatex command won’t automatically create the build directory and will fail with a cryptic message such as “I can’t write on file…” if the directory doesn’t exist. What had me going for a while was the fact that it also needs you to manually create folders in the build directory for other folders in the source directory. For example, if you have .tex
files in a chapters
directory you need to create a chapters
directory in the build directory.
The second instruction for tweaking TexStudio talks about the path Options -> Configure -> Build -> Build Options -> Additional Search Paths -> Log File
. To see this you need to turn on Show Advanced Options
. Note that when it asks for a path for the log and pdf files you just need to enter dir
not the whole path.
The third instruction about modifying bibtex is, as far as I can tell, completely wrong. On my machine at least bibtex has essentially no options. The solution I came up with was this command: sh -c "cd build; cp ../bibs/*.bib .; bibtex %.aux"
which switches to the build directory, copies in the .bib
files and then runs bibtex. This is a variation on the idea given here.