%
%   Calendar-generating macros in TeX.
%   by Andrew Marc Greene
%   Student Information Processing Board, MIT
%   <amgreene@mit.edu>
%
%

% Here are the declarations of how large to make each calendar.

\newdimen\CalendarWidth  \CalendarWidth=12in
\newdimen\CalendarHeight \CalendarHeight=9in

% Here are the font declarations for date numbers and notes.

\font\datenumfont = amssmc40
\font\notefont = cmss10 scaled \magstep 1

% Here are the commands that set TeX's parameters for
% calendar-setting.

\def\calendar{\begingroup
\parindent=0pt
\parskip=0pt
\hbadness=10000
\baselineskip=0pt}  % Pack it as closely as you can!
\def\endcalendar{\endgroup}

% Here are the TeX registers used for the actual setting of calendars.
% Date contains the date of the NEXT box.
% Day contains the day of the week (0=Sun)
% OnDate is the next ``interesting date.''
% boxwidth and boxheight are the size of each date's box.
% boxrulewid is the width of the rules that form the grid.
% TopNotes is the box that accumulates the notes for the top of boxes.
% BotNotes is the box that accumulates the notes for the bottom of boxes.

\newcount\Date
\newcount\Day
\newcount\OnDate
\newdimen\boxwidth   \boxwidth=\CalendarWidth   \divide\boxwidth by 7
\newdimen\boxheight  \boxheight=\CalendarHeight \divide\boxheight by 5
\newdimen\boxrulewid \boxrulewid=2pt
\newbox\TopNotes
\newbox\BotNotes

\def\DayBox{\hbox{\vsize=\boxheight \hsize=\boxwidth \relax
\vrule width -\boxrulewid \relax
\vrule width \boxrulewid \relax
\vrule width -1sp \relax
\vbox to \vsize{\vsize=\boxheight \hsize=\boxwidth \relax
\hrule height \boxrulewid \relax
\vskip \boxrulewid
\setbox\DateBOX=\vbox{\datenumfont\number\Date}
\ifdim\ht\TopNotes>\ht\DateBOX
\ht\TopNotes=\ht\DateBOX\fi
{\datenumfont\number\Date}\ \box\TopNotes\hfill\break
\global\advance\Date by 1 \relax
\global\advance\Day  by 1 \relax
\vfill
\box\BotNotes
\vskip\boxrulewid
\hrule depth \boxrulewid}%
{\vrule width -\boxrulewid
\vrule width \boxrulewid}}%
}

\newbox\DateBOX

\def\addmovie#1{\setbox\BotNotes\vbox{\hsize=\boxwidth\relax
\unvbox\BotNotes #1}}

\def\movie#1#2#3{%  title, time, room
\addmovie{\centerline{\moviefont #1}
\line{\thinspace\timefont #2 \hfill #3\ }
\vskip\boxrulewid}\ignorespaces}

\def\dolby#1#2#3{%  title, time, room
\addmovie{\centerline{\moviefont #1}
\line{\thinspace\rlap{\timefont #2}\hfill{\dolbyfont D}%
\hfill\llap{\timefont #3}\ }
\vskip\boxrulewid}\ignorespaces}

\hsize=30in
\newbox\CalBox

%%%%%%%%%

\def\note #1{\setbox\TopNotes\vbox{\hsize=0pt \hfuzz=4in \relax
\unvbox\TopNotes\vskip\boxrulewid\line{\notefont #1}}%
\ignorespaces}

\def\firstmonth#1{%  #1 is starting day of week, 0 = Sunday
\Day=#1\relax
\newmonth}

\def\newmonth{\Date=1\relax
\setbox\CalBox\vbox\bgroup\hbox\bgroup\null\expandafter\hskip\the\Day\boxwidth
\ignorespaces}

\def\dodate{\DayBox
\ifnum\Day=7\relax
\egroup\vskip-1.7\boxrulewid\hbox\bgroup
\global\Day=0\relax
\fi
\ifnum\Date<\OnDate
  \let\next=\dodate
\else
  \let\next=\ignorespaces
\fi
\next}

\def\ondate#1:{\global\OnDate=#1\relax\dodate}

\def\endmonth#1.{\ondate #1:\egroup\egroup\copy\CalBox\vfill\eject}

\output{%
\message{\the\ht\CalBox is the height of this page.}
\count1=1 \shipout\vbox{\moveright 0.5in
\ifdim\ht\CalBox>\CalendarHeight \vbox{\kern -\boxheight\copy\CalBox}
\message{Raising}
\else \copy \CalBox\fi }
\count1=2 \shipout\vbox{\moveleft  5.7in \box\CalBox}
\global\advance\pageno by 1
\setbox201=\box255}

%%%%%

\font\moviefont = cmssbx10 scaled \magstep 1
\font\timefont = cmssq8    scaled \magstep 1
\font\dolbyfont = dolby     scaled \magstep 1 

\nopagenumbers

%% WHERE SHOULD WE PUT THE REG DAY MOVIE?  IT'S ON JAN 31...
%% Also, we need a \classic command...
%% emphasize non-7&10 movie times

%% when is new-member sign-up??

\calendar
\firstmonth 5     % february starts on a friday
\note{Classes start}
\movie{Horse Feathers}{7:30}{10-250}
\dolby{Pump Up the Volume}{7\&10}{26-100}
\ondate 2: \dolby{Flatliners}{7\&10}{26-100}
\ondate 3: \movie{A Fish Called Wanda}{7\&10}{10-250}
\ondate 5: \movie{New Member Signup}{8 PM}{Mezz.~Lounge}
\ondate 7: \movie{L. A. Story}{}{}
           \movie{(FREE Sneak!)}{8:00}{26-100}
\ondate 8: \movie{The \kern -3pt Philadelphia \kern -3pt Story}{7:30}{10-250}
	   \dolby{Presumed Innocent}{7\&10}{26-100}
\ondate 9: \movie{Postcards from}{}{}\dolby{the Edge}{7\&10}{26-100}
\ondate 10:\movie{A Clockwork Orange}{6:30\&10}{10-250}
\ondate 15:\movie{Henry V (1944)}{7:00}{10-250}
           \dolby{Ghost}{6:30\&10}{26-100}
\ondate 16:\dolby{Reversal of Fortune}{7\&10}{26-100}
\ondate 17:\movie{Raiders of}{}{}\dolby{the Lost Ark}{7\&10}{10-250}
\ondate 18:\note{President's Day}\note{No classes}
           \movie{Metropolis}{}{}\movie{(FREE)}{8:00}{10-250}
\ondate 22:\movie{The Defiant Ones}{7:30}{10-250}
           \dolby{Wild at Heart}{6:30\&10}{26-100}
\ondate 23:\dolby{Narrow Margin}{7\&10}{26-100}
\ondate 24:\movie{Who Framed}{}{}\movie{Roger Rabbit?}{7\&10}{10-250}
\ondate 26:\movie{\llap{``}From the Invisible}{}{}\movie{to the
Institute''}{}{}\movie{with Jeremy Wolfe}{8:00}{Kresge}
\endmonth 29.

\newmonth	% March
\movie{The General}{7:30}{10-250}
\dolby{White Palace}{7\&10}{26-100}
\ondate 2:\movie{The Rescuers}{}{}\dolby{Down Under}{3,7,\&10}{26-100}
\ondate 3:\dolby{Blade Runner}{7\&10}{10-250}
\ondate 8:\note{ADD DATE} 
          \movie{Strangers on a Train}{7:30}{10-250}
          \dolby{Predator II}{7\&10}{26-100}
\ondate 9:\dolby{Goodfellas}{6:30\&10}{26-100}
\ondate 10:\movie{The Man Who}{}{}\movie{Would Be King}{7\&10}{10-250}
\ondate 15:\movie{Alexander Nevsky}{7:30}{10-250}
           \dolby{Henry and June}{6:30\&10}{26-100}
\ondate 16:\dolby{The Freshman}{7\&10}{26-100}
\ondate 17:\movie{2001: A Space}{}{}\movie{Odyssey}{6:30\&10}{10-250}%%Four-Track!
\ondate 22:\movie{Kind Hearts}{}{}\movie{and Coronets}{7:30}{10-250}
           \dolby{Pacific Heights}{7\&10}{26-100}
\ondate 23:\movie{The \kern -2pt Many \kern -2pt Adventures}{}{}\movie{of Winnie the Pooh}{3,7,\&10}{26-100}
\ondate 24:\movie{Airplane!}{7\&10}{10-250}
\ondate 25:\note{Spring}\note{Vacation}\note{begins}
\ondate 29:\note{Spring}\note{Vacation}\note{ends}
           \movie{All That Jazz}{7\&10}{10-250}
\ondate 30:\dolby{Beetlejuice}{7\&10}{10-250}
\ondate 31:\movie{Body Heat}{7\&10}{10-250}
\endmonth 32.

\newmonth	% April
\ondate 5:
\movie{The \kern -2pt Prisoner \kern -2pt of \kern -2pt Zenda}{7:30}{10-250}
\dolby{The Krays}{7\&10}{26-100}
\ondate 6:\dolby{Misery}{7\&10}{26-100}
\ondate 7:\dolby{The Jungle Book}{3,7,\&10}{10-250}
\ondate 9:\movie{``Hacks and}{}{}\movie{MIT Traditions''}{}{}
          \movie{with Brian Leibowitz}{8:00}{26-100}
\ondate 12:\movie{Three Men and}{}{}\dolby{a Little Lady}{7\&10}{26-100}
\ondate 13:\dolby{Mermaids}{7\&10}{26-100}
\ondate 14:\movie{Repo Man}{7\&10}{10-250}
\ondate 15:\note{Patriots' Day}\note{No classes}
\ondate 16:\note{No classes}
\ondate 19:\movie{Key Largo}{7:30}{10-250}
           \dolby{Edward Scissorhands}{7\&10}{26-100}
\ondate 20:\movie{Dances with Wolves}{6\&10}{26-100}
           \dolby{}{8:00}{10-250}
\ondate 21:\movie{A View to a Kill}{7\&10}{10-250}
\ondate 26:\note{DROP DATE}
           \movie{Laura}{7:30}{10-250}
           \dolby{The Russia House}{7\&10}{26-100}
\ondate 27:\dolby{Air America}{7\&10}{26-100}
\ondate 28:\movie{The Adventures of}{}{}\dolby{Buckaroo Banzai}{7\&10}{10-250}
\endmonth 31.

\newmonth	% May
\ondate 3:\movie{The Band Wagon}{7:30}{10-250}
          \dolby{Home Alone}{7\&10}{26-100}
\ondate 4:\dolby{Kindergarten Cop}{7\&10}{26-100}
\ondate 5:\dolby{Mystic Pizza}{7\&10}{10-250}
\ondate 6:\note{First Term}\note{Reg Material avail.}\note{Lobby 10}
\ondate 7:\note{First Term}\note{Reg Material avail.}\note{Lobby 10}
\ondate 10:\movie{The Lady}{}{}\movie{from Shanghai}{7:30}{10-250}
           \movie{Hamlet}{7\&10}{26-100}
\ondate 11:\movie{TBA}{}{}
\ondate 12:\dolby{Blue Velvet}{7\&10}{10-250}
\ondate 13:\note{Last day}\note{of classes}
\ondate 16:\note{FINALS}
\ondate 17:\note{FINALS} 
           \movie{TBA}{}{}
\ondate 18:\dolby{Flight of the Intruder}{7\&10}{26-100}
\ondate 20:\note{FINALS}
\ondate 21:\note{FINALS}
\ondate 22:\note{FINALS}
\ondate 23:\movie{Reg. Material}{}{}\movie{DUE}{}{}
\endmonth 32.

\endcalendar

\end
