Advertisement
Bellyfluous

calendar.sty

Dec 23rd, 2019
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. \NeedsTeXFormat{LaTeX2e}
  2.  
  3. \def\CalendarVersion{3.2}
  4. \def\CalendarVersionDate{2018/09/19}
  5.  
  6. \ProvidesClass{calendar}[\CalendarVersionDate
  7. LaTeX2e class file `calendar' v\CalendarVersion]
  8.  
  9. \typeout{'calendar' style \CalendarVersion \CalendarVersionDate.}
  10. \typeout{Created by Evan Sultanik}
  11. \typeout{****** Bugs/comments/suggestions/technicalities to Evan Sultanik -- [email protected] ******}
  12.  
  13. \RequirePackage{tabularx}
  14.  
  15. \def\@CALtrue{1}
  16. \newcount\@currentdaynum
  17. \newcounter{calendardate}
  18. \newcount\StartingDayNumber
  19.  
  20. \def\dayheader#1#2{
  21. \vspace{2pt} % Whitespace above the heading
  22. \begin{minipage}[t]{0.87\hsize}
  23. \raggedright
  24. \normalsize % Reset back to normal font size in case this is used within the \activities as a second day heading
  25. \textit{#1}
  26. \end{minipage}
  27. \begin{minipage}[t]{0.1\hsize}
  28. \raggedleft
  29. \textit{#2}
  30. \end{minipage}%
  31. \vspace{1pt}% Whitespace below the heading
  32. }
  33. \def\activities#1{
  34. \parbox{\hsize}{\vspace*{5pt}\raggedright\scriptsize #1}\smallskip
  35. }
  36.  
  37. \let\@colbreak=&
  38.  
  39. \def\printdayname#1{\hfil\textsc{#1}\hfil}
  40.  
  41. \newcommand{\dayname}[1]{
  42. \ifnum#1=1 Sunday\else
  43. \ifnum#1=2 Monday\else
  44. \ifnum#1=3 Tuesday\else
  45. \ifnum#1=4 Wednesday\else
  46. \ifnum#1=5 Thursday\else
  47. \ifnum#1=6 Friday\else
  48. \ifnum#1=7 Saturday\else
  49. \PackageError{calendar}{Unrecognized day number: #1!}
  50. \fi\fi\fi\fi\fi\fi\fi
  51. }
  52.  
  53. \StartingDayNumber=1
  54. \newenvironment{calendar}[1]{
  55. \newdimen\@calendarwidth
  56. \@calendarwidth=#1
  57. \begingroup
  58. \def\@calendarmode{\@CALtrue}
  59. \def\day##1##2{
  60. \if\@calendarmode\@CALtrue\else\PackageWarning{calendar}{The '\day' macro is expected to be used in the 'calendar' environment!}\fi
  61. \ifnum\@currentdaynum>7\global\@currentdaynum=1\fi
  62. \global\advance\@currentdaynum by 1
  63. \vspace{-0.5\baselineskip} % Reduce the whitespace above the first day heading
  64. \dayheader{##1}{\thecalendardate}\def\daysep{\vskip1pt\hrule\vskip1pt}
  65. \activities{##2}
  66. \addtocounter{calendardate}{1}
  67. \ifnum\@currentdaynum>7\@arraycr\hline\else&\fi
  68. }
  69. \def\finishCalendar{
  70. \ifnum\@currentdaynum=6 &\\\hline\else
  71. \ifnum\@currentdaynum=5 &&\\\hline\else
  72. \ifnum\@currentdaynum=4 &&&\\\hline\else
  73. \ifnum\@currentdaynum=3 &&&&\\\hline\else
  74. \ifnum\@currentdaynum=2 &&&&&\\\hline\else
  75. \ifnum\@currentdaynum=1 &&&&&&\\\hline
  76. \fi\fi\fi\fi\fi\fi
  77. }
  78. \def\eventskip{\\\vspace{4pt}}
  79. \def\BlankDay{
  80. \if\@calendarmode\@CALtrue\else\PackageWarning{calendar}{The '\calendarday' macro is expected to be used in the 'calendar' environment!}\fi
  81. \ifnum\@currentdaynum>7\global\@currentdaynum=1\fi
  82. \global\advance\@currentdaynum by 1
  83. \addtocounter{calendardate}{1}
  84. \ifnum\@currentdaynum>7\@arraycr\hline\else&\fi
  85. }
  86.  
  87. \setcounter{calendardate}{1}
  88. \newcount\@currday
  89. \@currday=\StartingDayNumber
  90. \newcount\@numdays
  91. \@numdays=7
  92. \let\@cbreak=&
  93. \tabularx{\@calendarwidth}{|X|X|X|X|X|X|X|} \hline
  94. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
  95. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
  96. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
  97. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
  98. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
  99. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
  100. \ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 \\ \hline \hline
  101. \@currentdaynum=1
  102. \let\@firstline=\@CALtrue
  103. }{
  104. \endtabularx
  105. \endgroup
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement