Saturday, February 9, 2008

Optional sections of your document using LaTex

If you're like me, you have more that you could put on your resume than you can fit. You have to cut it down to what's relevant, but sometimes the best things to put in differ based on who you're sending it to. So you have to make different versions of your resume. And then it turns out you need to reformat something in your basic info, and you have to change every version. If you used a word processor for this, you know how this could be a pain in the ass.

This is why I liked the idea of LaTeX; it's technically a programming language. TeX is anyway. I could make one giant resume, and put a bunch of conditionals in there. Now, I figured out how to do this, and I think it's a hack, I'm not really sure how this language works and I don't really care to find out. Point is, this works.

Here's an example. Let's say there's an internship that I did a while ago that I might not want to include in all versions of my resume. First, I define this variable at the top:

\global\let\includeinternship\relax


Then I test if it's undefined:


\ifx\includeinternship\undefined
\textbf{Internship}
\begin{itemize}
\item Brought coffee to employees
\item Sat around
\item Oh one time my boss had me make a spreadsheet
\end{itemize}
\fi


You defined it, so it won't show up. Sortof backwards, but it works. Again, it's a hack, and I'm too lazy to figure out how to do it right. So, to make it show up, comment out the definition:

%\global\let\includeinternship\relax


So you could put all the variables on top, and that's a lot more convenient than what you had before. But it could still be better. Lets say you have different versions of your resume.tex handy, with different variable settings. If you have to change some formatting or details in your resume, you're back where you started; you have to make the change in all versions of the file. So, you should have only one version of resume.tex, and include the file variables.sty:

In resume.tex:
\usepackage{variables}


In variables.sty, in the same directory:

%\global\let\includeinternship\relax
\global\let\includecrappygpa\relax
%\global\let\includemacaroniartproject\relax


So now, you keep around multiple versions of variables.sty, with different combinations of variable definitions commented out. Any changes to your resume, you only have to do once. Now, what if you're updating your resume and you decide to add variables. Well, that's the downside. You would have to add it to all the variable files. But that's a lot better and more straightforward, in my opinion, than making a more complicated change to multiple versions of a whole resume file.

At this point, you can make multiple versions of variables.sty, or you can make a quick change to variables.sty and make a new resume.pdf. With multiple versions, you still have to rename them to variables.sty to use them. So, you just put it in my resume generating script:


cp $1 variables.sty
pdflatex resume.tex


Of course, you have to be careful not to have anything you want to keep in variables.sty, because the cp will overwrite it. Keep your actual work in different files that you pass to this script. For instance:

./makeResume.sh version3.sty

1 comment:

yacin said...

This is pretty slick! Definitely going to implement this for my resume. It sucks having 3 versions of it :(.