Default files for LaTeX projects
In a previous post, I dealt with generating default files for a GPL’ed project. In this post, I briefly talk about generating default files for a LaTeX project.
If you’re an avid LaTeX user like me, over time you would notice that there are a number of files that keep rearing their heads over and over again. For each new document that I write, I would create a Makefile containing the necessary commands for compiling my document and commands for cleaning up junk files. The junk files I’m referring to include, among others, the following types of file:
Well, DVI and PS files are strictly not junk files. DVI files are useful for previewing your document during the writing process. PS files can be used for printing out hard copies of your documents. But I usually prefer to read the PDF files of the final drafts of my documents.
After using LaTeX for some time now, I realize that I often create files similar to the following:
- Makefile — for storing useful commands
- bibliography.bib — for BibTeX entries
- template.tex — the master TeX file of my document
So here’s another no-brainer Python script to automagically generate the files in the above list. The script does appear to be a bit lengthy, but it’s not difficult for a Python beginner to understand. Just be patient and read through the script and you would notice that the following excerpt is the main part of that script:
[...] fileNames = ["template.tex",\ "Makefile",\ "bibliography.bib"] fileContents = [TEX_MASTER,\ MAKEFILE,\ BIBTEX_ENTRIES] i = 0 while i < len(fileNames): path = [os.getcwd()] path.append(SLASH) path.append(fileNames[i]) path = "".join(path) file = open(path, "w") file.write(fileContents[i]) file.close() i += 1
See… What did I tell you? No-brainer, right?