Tex File Creation Scripts

The new semester has started and I am hearing some lectures where you have to hand in assignments every week. We computer scientists are not that pretty ourselves in most cases, so at least our submissions should not look like the stereotypical .doc submission of other students. And logic is pretty, and $latex \LaTeX$ is like so logic, you actually have to program your text.

So over the past semesters, I have, just like most of my fellow students, created a bunch of \newcommands (“macros”) tailored to my needs when TEXing. They are kind of default to my submissions so these macros should be present in every tex file I create.

Now typically there are two approaches to get your default macros and such into a new TEX document from a “template” TEX file:

  1. copy the whole template file, paste it to your desired destination, rename it, change title, author and date inside the tex, delete the stuff between \begin{document} and \end{document}
  2. open the tex file, copy the head, create a new tex file, paste the head, change title, author…. ect.
  3. Use \input{way/too/long/and/complicated/path/to/my/template.tex} in order to be able to use those sweet commands

IMHO, this is just dumb – doing this is like working off some sort of…. script. SCRIPT.

As python is a lovely scripting language, I created some scripts to handle that, hooray! Now I just type, e.g. “texnew -s MT 2” and – there it is – a tex file named “MT_Exercise02_RomanLamsal.tex”, containing all the stuff I need for my submissions for the lecture Machine Translation I am currently hearing. Well, except the solutions to the assignment, of course.

You can check out this github repository of mine if you want to use the scripts (tweak to your needs, son) and or just read through the source code.

Much documentation, so understandable. So great.

Leave a Reply

Your email address will not be published. Required fields are marked *