Terminally Incoherent

Utterly random, incoherent and disjointed rants and ramblings...

Tuesday, April 25, 2006

Latex Conditionals

If you are a graduate student, and have some sort of assistantship position I have one advice for you. Do not tell your professors that you know/enjoy/use latex. Do not talk to them about latex. If they figure out that you do use it from the superb visual quality of your written assignments they may corner you and ask you about it directly. In that case shrug, make a dumb expression and quickly change the subject/run away.

The truth is that today, most graduate students are brain-dead MS word zombies. In fact most faculty members hate non-wysiwyg stuff with a passion. So once the they spot a latex user they are going to pounce upon him, and ride him till he drops dead, or graduates (whichever comes first).

This is, ladies and gentlemen, how I got stuck making thesis templates for Dr. Antoniou who is about ready to strange me these days. I'm officially working on the templates since... Er... Sometime last semester :P

Yes, I am the undisputed king of procrastination. I could teach you all a thing or two about procrastinating to the fullest. But not today. Come back tomorrow... Or next week maybe.

What I really wanted to talk about today are the conditional statements in Latex. I just typed all this back-story to give you some background on the problem I was facing. You see, at MSU it is only possible to submit a Masters Thesis in May, August or January. Thus, I wanted to make my template automatically select the correct month.

I decided to use ifthen package to do the conditionals. The ifthenelse statement seemed to be perfect here:

\newcommand{\shorttoday}{
   \ifthenelse{\number\month<5}
   {May, }
   {
       \ifthenelse{\number\month <8}
       {August, }
       {January, }
   }
\number\year}


Now, whenever you do \shorttoday you should get an appropriate month. For example, right now it displays May. But if I change month to say December using \month 12 I will get January :)

Now my only issue is that for January I should increment the year somehow. Any tips on how to do that? So far I haven't figured out how that could be done.

Update Thu, April 27 2006, 09:57 PM

I finally figured it out:

\newcounter{theyear}
\setcounter{theyear}{\number\year}

\newcommand{\shorttoday}{
   \ifthenelse{\number\month<5}
   {May, }
   {
       \ifthenelse{\number\month <8}
       {August, }
       {\addtocounter{theyear}{1} January, }
   }
\value{theyear}}


It works :)

0 Comments:

Post a Comment

<< Home