#!/bin/csh -f #set DIR = `pwd` #cd ~/tex set PT = 12pt # ======== getting information ========= @ month = `date '+%m' | awk '{print $1 + 0}'` @ year = `date '+%y'` + 2000 echo -n " 1. From which month(default: $month $year)? " set AAAA = "$<" @ temp = `echo "$AAAA" | wc -w` if ( $temp == 2 ) then @ month = `echo $AAAA | awk '{print $1}'` @ year = `echo $AAAA | awk '{print $2}'` if ( $year < 2000 ) @ year += 2000 else if ( $temp == 1 ) then @ month = $AAAA endif echo -n " 2. How many months(default: 6)? " set BBBB = $< @ temp = `echo "$BBBB" | wc -w` if ( $temp == 1 ) then @ num_month = $BBBB else @ num_month = 6 endif echo -n " 3. How many months on each page[1,2,3](default: 2)? " set CCCC = $< @ temp = `echo "$CCCC" | wc -w` if ( $temp == 1 ) then @ each_page = $CCCC else @ each_page = 2 endif if ( $each_page > 3 ) then echo ' The naswer must be <= 3: adjusted to 2.' @ each_page = 2 endif # ======== preparing two temp files ====== set obj_file = $year'_'$month'_'$num_month.tex set awk_file = temp_awk_$$ cat /dev/null > $obj_file cat /dev/null > $awk_file # ======== making a temp awk_file ========= echo '# mkcal.awk\ $NF >=32 && $NF<=2500 {printf("{\\LARGE\\bf %s} \\vspace{0.1ex}",$0)} \ NR == 2 { \ print ""\ print "\\begin{center}"\ print "\\begin{tabular}{|l|l|l|l|l|l|l|} \\hline" \ print "\\ \\ \\ Sun\\ \\ \\ \\ &\\ \\ \\ Mon\\ \\ \\ \\ " \ print "&\\ \\ \\ Tue\\ \\ \\ \\ &\\ \\ \\ Wed\\ \\ \\ \\ " \ print "&\\ \\ \\ Thu\\ \\ \\ \\ &\\ \\ \\ Fri\\ \\ \\ \\ " \ print "&\\ \\ \\ Sat\\ \\ \\ \\ \\\\ \\hline\\hline" \ }' >> $awk_file echo '\ $NF == 1 {printf("& & & & & &%s\n",$1)} \ $NF == 2 {printf("& & & & &%s&%s\n",$1,$2)} \ $NF == 3 {printf("& & & &%s&%s&%s\n",$1,$2,$3)} \ $NF == 4 {printf("& & &%s&%s&%s&%s\n",$1,$2,$3,$4)} \ $NF == 5 {printf("& &%s&%s&%s&%s&%s\n",$1,$2,$3,$4,$5)} \ $NF == 6 {printf("&%s&%s&%s&%s&%s&%s\n",$1,$2,$3,$4,$5,$6)} \ $NF == 7 {printf("%s&%s&%s&%s&%s&%s&%s\n",$1,$2,$3,$4,$5,$6,$7)} \ $1>= 2 && $1 <= 31 { \ printf("%s&%s&%s&%s&%s&%s&%s\n",$1,$2,$3,$4,$5,$6,$7) } \ \ $1>= 1 && $1 <= 31 {' >> $awk_file if ( $each_page == 1 ) then echo 'print "\\\\ &&&&&& \\\\ &&&&&& \\\\ &&&&&& \\\\ &&&&&& \\\\ &&&&&& \\\\ \\hline" }' >> $awk_file else if ( $each_page == 2 ) then echo 'print "\\\\ &&&&&& \\\\ &&&&&& \\\\ \\hline" }' >> $awk_file else echo 'print "\\\\ &&&&&& \\\\ \\hline" }' >> $awk_file endif echo '\ END { printf("\\end{tabular}\n\\end{center}\n\n\\vspace{1ex}\n\n") }' >> $awk_file # ======== making a temp obj_file ========= echo "% ==== CALENDAR.TEX ====\ \documentstyle[$PT]{article}\ \pagestyle{empty}\ \addtolength{\textwidth}{2.4in}\ \addtolength{\oddsidemargin}{-1.2in}\ \addtolength{\evensidemargin}{-1.2in}\ \addtolength{\textheight}{3.0in}\ \addtolength{\topmargin}{-1.5in}\ \begin{document} \large\bf\ \def\h{\hskip.1in}\ " >> $obj_file @ count = 1 @ count_page = $each_page while ( $count <= $num_month ) cal $month $year | awk -f $awk_file >> $obj_file @ month++ if ( $month > 12 ) then @ month = 1 @ year++ endif if ( $count == $count_page ) echo '\ \vspace{0.5em} \ ' >> $obj_file # \underline{\sc Memo:} \ if ( $count == $count_page && $count < $num_month ) then echo '\newpage' >> $obj_file @ count_page = $count_page + $each_page endif @ count++ end echo "\end{document}" >> $obj_file # === Compiling and showing the object file === set obj_file = `basename $obj_file .tex` pdflatex $obj_file.tex /bin/rm $awk_file /bin/rm $obj_file.tex /bin/rm $obj_file.aux $obj_file.log #/bin/rm $obj_file.dvi #cd $DIR