%
%			LaTeX Calendar Driver
%
%		Author: C. E. Chew
%		Date:	May 1989
%
% This is the main program for printing out calendars. It provides
% a user interface for the calendar style. The style file contains
% the code that actually produces the calendars.
%
% The program will prompt for the year and the month. The year should
% be entered in full (eg 1989). The month should be entered using
% the first three letters of the month in question, case not being
% significant (eg aug). Responding with an empty line for the month
% causes a calendar for the entire year to be printed out.
%
% The program will include the file dates.tex which contains significant
% dates for the year. The user is free to create the file events.tex
% which has the same format as dates.tex. events.tex should contain
% events of a significant and personal nature (eg birthdays).
%
% Patchlevel 1.1
%
% Edit History:
%
% 04-Dec-1989	Add \clearpage in \onepage. Allow 6 week months.
% 11 Aug 1989	Updated for release
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Configuration Options       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentstyle[12pt,german,cal]{article}%
\pagestyle{empty}%
\oddsidemargin -1in%
\evensidemargin -1in%
\textwidth 8in%
\textheight 10in%
\topmargin 0in%
%
% Six week calendar control. Set to \iftrue to generate 6 week
% calendar months. Set to \iffalse to fold sixth week onto the
% first week of month.
%
\let\ifsixweek=\iffalse%
%
% Big month box height. This controls the size of the boxes
% used for each day in the main part of the calendar.
%
\newlength{\dayboxh} \setlength{\dayboxh}{3cm}%
\newlength{\dayboxw} \setlength{\dayboxw}{2cm}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         End Configuration         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}%
%
\typeout{LaTeX Calendar}%
%
\def\Jan{jan}\def\Feb{feb}\def\Mar{mar}\def\Apr{apr}%
\def\May{mai}\def\Jun{jun}\def\Jul{jul}\def\Aug{aug}%
\def\Sep{sep}\def\Oct{oct}\def\Nov{nov}\def\Dec{dez}%
%
\def\lread{{\endlinechar=-1 \global\read-1 to\line}}%
%
\def\advmonth#1{\advance\month by#1 %
	        \ifnum\month<1 \month=12 \advance\year by-1 \fi%
	        \ifnum\month>12 \month=1 \advance\year by1 \fi}%
%
\def\littlemonth{{\tabcolsep=0.75mm%
		  \Calendar{\the\month}{\the\year}{}{}{rrrrrrr}%
			   {So & Mo & Di & Mi & Do & Fr & Sa \\}%
			   {\iffalse}{}{\iffalse}}}%
%
\def\bigmonth{\Calendar{\the\month}{\the\year}{\scriptsize}{\Huge}%
		       {|p{\dayboxw}|p{\dayboxw}|p{\dayboxw}%
			|p{\dayboxw}|p{\dayboxw}|p{\dayboxw}|p{\dayboxw}|}%
		       {\multicolumn{1}{|c|}{Son}&%
                        \multicolumn{1}{c|}{Mon}&%
                        \multicolumn{1}{c|}{Die}&%
                        \multicolumn{1}{c|}{Mit}&%
                        \multicolumn{1}{c|}{Don}&%
                        \multicolumn{1}{c|}{Fri}&%
                        \multicolumn{1}{c|}{Sat}\\ \horizontal}%
		       {\iftrue}{\dayboxh}{\ifsixweek}}%
%
\def\onepage{\setbox0=\hbox{\bigmonth}%
	     \centerline{\hbox to\wd0{%
                   \fbox{\footnotesize\advmonth{-1}\littlemonth}\hfil%
	           \fbox{\footnotesize\advmonth{1}\littlemonth}}}%
             \vspace{1cm}%
	     \centerline{\box0}\clearpage}%
%
% Read the year. If the line is empty, the current year is taken
% to be the default.
%
\message{Jahr: }\lread \ifx\line\empty \else \newcount\year \year=\line \fi%
%
% Read the month. If the line is empty, the calendar for the entire
% year is printed.
%
\newcount\month \loop%
  \message{Monat: }\lread%
  \ifx\line\empty%
    \month=-1 %
  \else%
    \month=0 %
    \lowercase\expandafter{%
	       \expandafter\def\expandafter\line\expandafter{\line}}%
    \ifx\line\Jan\month=1 \fi \ifx\line\Feb\month=2 \fi%
    \ifx\line\Mar\month=3 \fi \ifx\line\Apr\month=4 \fi%
    \ifx\line\May\month=5 \fi \ifx\line\Jun\month=6 \fi%
    \ifx\line\Jul\month=7 \fi \ifx\line\Aug\month=8 \fi%
    \ifx\line\Sep\month=9 \fi \ifx\line\Oct\month=10 \fi%
    \ifx\line\Nov\month=11 \fi \ifx\line\Dec\month=12 \fi%
  \fi%
\ifnum\month=0 \repeat%
%
\include{dates}%
\include{events}%
%
\ifnum\month=-1 \month=1 \loop \onepage \advance\month by1 %
			 \ifnum\month<13 \repeat%
\else \onepage%
\fi%
%
\end{document}
