%
%   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

\calendar
\firstmonth 6     % september starts on a saturday
\note{Saturday}
\ondate 2: \note{Sunday}
\ondate 3: \note{Monday}
\ondate 4: \note{Tuesday}
\ondate 5: \note{Wednesday}
\ondate 6: \note{Thursday}
\ondate 7: \note{Friday} \dolby{Predator}{7\&10}{26-100}
\ondate 8: \note{FREE MOVIE}\note{FOR}\note{FRESHMEN}
	   \movie{Ferris Bueller's}{}{}\dolby{Day Off}{7\&10}{26-100}
\ondate 9: \movie{Dr.~Strangelove}{6:30\&9:30}{10-250}
\ondate 10:\note{Reg Day}
	  \movie{Teenage Mutant}{}{}\movie{Ninja Turtles}{7:00,9:30}{26-100}
	  \dolby{}{11pm}{Kresge}
\ondate 11:\note{First Day}\note{of Classes}
\ondate 11:\movie{LSC New Member}{}{}\movie{Signup Meeting}{8 PM}{Mezz.~Lounge}
\ondate 14:\dolby{Driving Miss Daisy}{7\&10}{26-100}
\ondate 15:\movie{The Hunt for}{}{}\dolby{Red October}{6:30\&10}{26-100}
\ondate 16:\movie{Spellbound}{6:30\&9:30}{10-250}
\ondate 21:\note{Autumn}\note{begins}\movie{My Left Foot}{7\&10}{26-100}
\ondate 22:\movie{Born on the}{}{}\dolby{Fourth of July}{6:30\&10}{26-100}
\ondate 23:\dolby{Brazil}{6:30\&9:30}{10-250}
\ondate 28:\dolby{Henry V}{7\&10}{26-100}
\ondate 29:\dolby{Pretty Woman}{7\&10}{26-100}
\ondate 30:\dolby{Octopussy}{6:30\&9:30}{10-250}
\endmonth 31.

\newmonth	% Oct
\note{Monday}
\ondate 2:\note{Tuesday}
\ondate 3:\note{Wednesday}
\ondate 4:\note{Thursday}
\ondate 5:\note{Friday} \movie{The Cook, the Thief,}{}{}\movie{\kern -2.5pt His\kern 1pt Wife,\kern 1pt and\kern 1pt  Her\kern 1 pt  Lover}{7\&10}{26-100} 
\ondate 6:\note{Saturday} \dolby{Always}{7\&10}{26-100}
\ondate 7:\note{Sunday} \dolby{Big}{6:30\&9:30}{10-250}
\ondate 8:\note{Columbus Day}\note{No classes}
\ondate 9:\note{No classes}
\ondate 12:\note{ADD}\note{DATE}
	   \dolby{Dick Tracy}{7\&10}{26-100}
\ondate 13:\dolby{The Handmaid's Tale}{7\&10}{26-100}
\ondate 14:\movie{The Seven Samurai}{8pm}{10-250}
\ondate 19:\dolby{Total Recall}{6,9\&Mid}{26-100}
\ondate 20:\dolby{Another 48 Hours}{7:00\&9:30}{26-100}
\ondate 21:\movie{Seven Year Itch}{6:30\&9:30}{10-250}
\ondate 26:\dolby{Tremors}{7:00\&9:30}{26-100}
\ondate 27:\movie{An American}{}{}\movie{Werewolf}{}{}\movie{in London}{7:00\&9:30}{26-100}
\ondate 28:\dolby{Wall Street}{6:30\&9:30}{10-250}
\endmonth 32.

\newmonth	% Nov
\note{Thursday}
\ondate 2:\note{Friday} \dolby{Days of Thunder}{7\&10}{26-100}
\ondate 3:\note{Saturday} \dolby{Akira}{7\&10}{26-100}
\ondate 4:\note{Sunday} \movie{His Girl Friday}{6:30\&9:30}{10-250}
\ondate 5:\note{Monday}
\ondate 6:\note{Tuesday}
\ondate 7:\note{Wednesday}
\ondate 9:\movie{Tie Me Up,}{}{}\movie{Tie Me Down}{7\&10}{26-100}
\ondate 10:\dolby{Die Hard II}{7\&10}{26-100}
\ondate 11:\dolby{F/X}{6:30\&9:30}{10-250}
\ondate 12:\note{Veterans Day}\note{No classes}
\ondate 16:\movie{Cinema Paradiso}{7\&10}{26-100}
\ondate 17:\dolby{Crazy People}{7:00\&9:30}{26-100}
\ondate 18:\movie{Never Say}{}{}\dolby{Never Again}{6:30\&9:30}{10-250}
\ondate 20:\movie{Drop Date}{}{}\movie{Eve Movie}{TBA}{TBA}
\ondate 21:\note{DROP}\note{DATE}
\ondate 22:\note{Thanksgiving}\note{No classes}
\ondate 23:\note{No classes}
	   \movie{The Adventures of}{}{}\dolby{Milo and Otis}{8pm}{26-100}
\ondate 24:\movie{All Dogs}{}{}\dolby{Go to Heaven}{8pm}{26-100}
\ondate 25:\movie{Chitty, Chitty}{}{}\movie{Bang Bang}{8pm}{10-250}
\ondate 30:\dolby{RoboCop II}{7\&10}{26-100}
\endmonth 31.

\newmonth	% Dec
\note{Saturday} \dolby{Betsy's Wedding}{7:00\&9:30}{26-100}
\ondate 2:\note{Sunday} \movie{It's a Wonderful Life}{6:30\&9:30}{10-250}
\ondate 3:\note{Monday}\movie{Second Term}{}{}\movie{Reg. Material}{}{}\movie{Available}{}{Lobby 10}
\ondate 4:\note{Tuesday}\movie{Second Term}{}{}\movie{Reg. Material}{}{}\movie{Available}{}{Lobby 10}
\ondate 5:\note{Wednesday}
\ondate 6:\note{Thursday}
\ondate 7:\note{Friday} \dolby{Back\kern 2pt to\kern 2pt the\kern 2pt Future\kern 2pt III}{6,9\&Mid}{26-100}
\ondate 8:\dolby{Bird on a Wire}{7\&10}{26-100}
\ondate 9:\movie{Adventures in}{}{}\dolby{Babysitting}{6:30\&9:30}{10-250}
\ondate 13:\note{Last day}\note{of classes}
   	   \dolby{TBA}{TBA}{TBA}
\ondate 14:\dolby{TBA}{TBA}{TBA}
\ondate 15:\dolby{TBA}{TBA}{TBA}
\ondate 17:\note{FINALS}
\ondate 18:\note{FINALS}
\ondate 19:\note{FINALS}
\ondate 20:\note{FINALS}
\ondate 21:\note{FINALS}\movie{Reg. Material}{}{}\movie{DUE}{}{}
\ondate 22:\note{Winter break}\note{begins}
\endmonth 32.

\endcalendar

\end
