Debian Codegraph @

texmf-dist/source/latex/schedule/schedule.dtx

raw
1 % \iffalse
2 %
3 % Single-source dtx file built on Will Robertson's dtxgallery single-source.dtx example.
4 %
5 %<*internal>
6 \iffalse
7 %</internal>
8 %<*readme>
9 ----------------------------------------------------------------
10 schedule.sty --- A style for personal weekly schedules
11 E-mail: [email protected]
12 Released under the LaTeX Project Public License v1.3c or later
13 See http://www.latex-project.org/lppl.txt
14 ----------------------------------------------------------------
15
16 This package defines the schedule environment. This is primarily intended for
17 constructing charts of recurring weekly appointments. It may also
18 be used to create a schedule of events and sign-up sheets (for example,
19 scheduling mandatory office visits with students for discussing paper topics,
20 etc.)
21
22 This package requires the packages calc and xcolor.
23 %</readme>
24 %<*internal>
25 \fi
26 \begingroup
27 %</internal>
28 %<*batchfile>
29 \input docstrip.tex
30 \keepsilent\askforoverwritefalse
31 \preamble
32
33 This is a generated file.
34
35 Copyright (c) Ethan Deneault <[email protected]>, 2019
36 (current maintainer)
37 Copyright (c) Jason Alexander, 1997-2001
38 (author)
39
40 This file may be distributed and/or modified under the
41 conditions of the LaTeX Project Public License, either
42 version 1.3c of this license or (at your option) any later
43 version. The latest version of this license is in:
44
45 http://www.latex-project.org/lppl.txt
46
47 and version 1.3c or later is part of all distributions of
48 LaTeX version 2005/12/01 or later.
49
50 \endpreamble
51 \usedir{tex/latex/schedule}
52 \generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
53 %</batchfile>
54 %<batchfile>\endbatchfile
55 %<*internal>
56 \generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
57 \generate{\file{README.md}{\from{\jobname.dtx}{readme}}}
58 \endgroup
59 %</internal>
60 %
61 %<*driver>
62 \documentclass{ltxdoc}
63 \usepackage{schedule}
64 \EnableCrossrefs
65 \CodelineIndex
66 \RecordChanges
67 %\OnlyDescription
68 \begin{document}
69 \DocInput{\jobname.dtx}
70 \end{document}
71 %</driver>
72 % \fi
73 %
74 %
75 % \changes{v1.00}{1997/10/11}{Initial version.}
76 % \changes{v1.10}{2019/7/26}{Clarified `noon' and `midnight' for 12:00}
77 % \changes{v1.20}{2019/7/31}{Added switches for 12-hour or 24-hour time notation}
78 %
79 % \GetFileInfo{schedule.sty}
80 %
81 % \DoNotIndex{\if,\else,\fi,\expandafter}
82 % \DoNotIndex{\csname,\endcsname}
83 % \DoNotIndex{\addtocounter,\stepcounter,\advance,\Alph,\alph,\arabic}
84 % \DoNotIndex{\begin,\end,\begingroup,\endgroup,\catcode,\centerline,\day,\def}
85 % \DoNotIndex{\divide,\do,\edef,\endgroup,\evensidemargin,\fbox,\gdef,\global}
86 % \DoNotIndex{\headheight,\headsep,\hfill,\hphantom,\Huge,\ifnum,\ifx,\large}
87 % \DoNotIndex{\long,\m@ne,\mbox,\medskip,\message,\month,\multiply}
88 % \DoNotIndex{\noindent,\nopagebreak,\normalsize,\oddsidemargin,\pagebreak}
89 % \DoNotIndex{\par,\relax,\rightmargin,\roman,\setcounter,\setlength}
90 % \DoNotIndex{\smallskipamount,\space,\textheight,\textsf,\textwidth}
91 % \DoNotIndex{\the,\topmargin,\undefined,\underline,\value,\vspace}
92 % \DoNotIndex{\xdef,\year,\z@,\time,\topsep}
93 %
94 % \title{The \textsf{schedule} package\thanks{This file
95 % has version number \fileversion, last
96 % revised \filedate.}}
97 % \author{Jason Alexander \\
98 % Ethan Deneault\footnote{Current maintainer, please send bug reports to:
99 % \texttt{[email protected]}}}
100 % \date{\filedate}
101 % \maketitle
102 %
103 % \MakeShortVerb{\|}
104 %
105 % \begin{abstract}
106 %This package defines the {\ttfamily schedule} environment. This is primarily intended for
107 %constructing charts of recurring weekly appointments. It may also
108 %be used to create a schedule of events and sign-up sheets (for example,
109 %scheduling mandatory office visits with students for discussing paper topics,
110 %etc.)
111 %
112 %This package requires the packages {\ttfamily calc} and {\ttfamily xcolor}.
113 % \end{abstract}
114 %
115 % \section{Introduction}
116 % \texttt{schedule} provides a simple interface for creating graphical charts
117 % displaying weekly appointments. Many respects of the overall layout can be
118 % customized to suit the user's desires. Unless these default settings are
119 % changed, the created schedule will run from Monday to Friday, 8:00am to 5:00pm,
120 % and the only predefined command to insert appointments will be |\class|, which
121 % draws the appointment using black text on a medium-gray background.
122 %
123 % The main feature of the \texttt{schedule} package is its accuracy in
124 % diagramming the length of appointments. Unlike some professionally available
125 % schedule creation programs, the representation of the length of appointments in
126 % the \texttt{schedule} package is accurate to the minute. In other
127 % words, if you have two appointments, one running from 2:00pm to 3:30pm on
128 % Tuesday and another running from 2:00pm to 3:31pm on Wednesday, there is a
129 % visible difference between the two representations. Unfortunately, unless you
130 % have a high-resolution printer (by which I mean more than 600 dpi) these
131 % differences will likely only be noticeable by a on-screen previewing program like
132 % \texttt{ghostview}.
133 %
134 % \section{Examples}
135 %
136 % The following schedule is typeset using the commands:
137 %
138 % \pagebreak
139 %
140 % \begin{verbatim}
141 % \CellHeight{.4in}
142 % \CellWidth{1in}
143 % \TimeRange{12:00-15:00}
144 % \SubUnits{30}
145 % \BeginOn{Monday}
146 % \TextSize{\tiny}
147 % \FiveDay
148 % \TwelveHour
149 %
150 % \NewAppointment{meeting}{red}{white}
151 % \NewAppointment{workshop}{green}{blue}
152 %
153 % \begin{schedule}[Fall Quarter, 1997]
154 % \class{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
155 % \class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
156 % \class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
157 % \meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
158 % \workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
159 % \class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
160 % \end{schedule}
161 % \end{verbatim}
162 %
163 % The result is:
164 % \CellHeight{.4in}
165 % \CellWidth{1in}
166 % \TimeRange{12:00-15:00}
167 % \SubUnits{30}
168 % \BeginOn{Monday}
169 % \TextSize{\tiny}
170 % \FiveDay
171 % \TwelveHour
172 %
173 % \NewAppointment{meeting}{red}{white}
174 % \NewAppointment{workshop}{green}{blue}
175 %
176 %\begin{schedule}[Fall Quarter, 1997]%
177 % \class{Moral Philosophy}{HOB2 233}{M}{14:00-16:50}
178 % \class{Math Logic}{EIC 128}{T,Th}{11:00-12:20}
179 % \class{Critical Reasoning}{SSL 290}{M,W,F}{13:00-13:50}
180 % \meeting{Departmental Meeting}{HOB2 233}{W}{12:00-12:50}
181 % \workshop{Crit. Reas. Workshop}{HOB2 233}{T}{13:00-13:50}
182 % \class{Office Hours}{HOB2 210}{W,F}{14:00-14:50}
183 %\end{schedule}%
184 %
185 % This example demonstrates all of the user-customizable options. Note
186 % several ``features'' of the package:
187 % \begin{enumerate}
188 % \item Appointments falling outside of the specified time range
189 % for the schedule are automatically truncated to fit. If the
190 % appointment falls entirely outside of the time range, it is not
191 % printed at all.
192 %
193 % \item The command |\class| is predefined to chart appointments pertaining
194 % to class attendence. New appointment types may be defined by the
195 % user via the |\NewAppointment| command. The new appointments may
196 % use any predefined color for the text or background. Note that the
197 % \textsf{color} package allows one to define new colors.
198 %
199 % \item The boxes created to represent appointments are sized to be
200 % accurate to the minute. In other words, if you have two
201 % appointments, one 52 minutes long and the other 53 minutes long, the
202 % box representing the second appointment will be slightly longer.
203 %
204 % \item The schedule is typeset in a centered displayed environment.
205 % \end{enumerate}
206 %
207 % \section{User Commands}
208 %
209 % \begin{macro}{\CellHeight}
210 % Including |\CellHeight|\meta{length} before the \textsf{schedule} environment
211 % tells \LaTeXe\ what height to make the cells in the schedule (all cells have
212 % the same height). Since a
213 % cell corresponds to an hour in the schedule, this command allows the user to
214 % specify how much vertical space a single hour ought to take up.
215 % \end{macro}
216 %
217 % \begin{macro}{\CellWidth}
218 % Including |\CellWidth|\meta{width} before the \textsf{schedule} environment
219 % tells \LaTeXe\ how wide to make every cell in the schedule. The overall
220 % width of the schedule is determined by multiplying this value by the number of
221 % days (set by the |\FiveDay| or |\SevenDay| command), plus the width of the
222 % time labels on the left-hand side.
223 % \end{macro}
224 %
225 % \begin{macro}{\TimeRange}
226 % This command must appear before the \textsf{schedule} environment, otherwise
227 % \LaTeXe\ will not know how deep to make the grid. It is important to note
228 % that the time range is specified using a 24-hour format, with a \emph{single}
229 % hyphen between the two times. Deviating from this format will generate an
230 % error.
231 % \end{macro}
232 %
233 % \begin{macro}{\SubUnits}
234 % The |\SubUnits|\meta{number} tells the package how to subdivide the hour. If
235 % one does not want any subdivisions, simply use |\SubUnits{60}|. The value of
236 % \meta{number} can be any number than evenly divides 60. It is assumed that,
237 % in specifying this value, you know what you are doing: i.e., if you tell
238 % \LaTeXe\ to use a |\CellHeight| of 1in, but then set |\SubUnits{3}|, you will
239 % get 20 subdivisions (with times) in a cell only 1in high. In other words, the
240 % text on the left-hand side of the schedule will be typeset as a horrible mess.
241 % The solution is simple: if you want a large number of subdivisions, simply set
242 % |\CellHeight| to a greater value.
243 % \end{macro}
244 %
245 % \begin{macro}{\BeginOn}
246 % Including |\BeginOn|\meta{day} tells \LaTeX\ what day of the week to start
247 % the schedule on. The possible values are `Sunday', `Monday', `Tuesday', `Wednesday',
248 % `Thursday', `Friday', or `Saturday'. My apologies for non-English speaking
249 % users of \LaTeX. If there is a demand for it, I will fix this in future
250 % releases.
251 % \end{macro}
252 %
253 % \begin{macro}{\TextSize}
254 % With the |\TextSize|\meta{font-size} command, the user tells \LaTeX\ what
255 % size font to use when typesetting the text inside the boxes. This command
256 % ought to be one of the standard \LaTeX\ font-size commands, e.g., |\tiny|,
257 % |\scriptsize|, etc. Using two large of a font will almost always result in
258 % bad line breaks inside the boxes, though, due to the narrow width of a cell.
259 % \end{macro}
260 %
261 % \begin{macro}{\FiveDay}
262 % Tells \LaTeX\ to typeset a five-day schedule.
263 % \end{macro}
264 %
265 % \begin{macro}{\SevenDay}
266 % Tells \LaTeX\ to typeset a seven-day schedule.
267 % \end{macro}
268 %
269 % \begin{macro}{\TwelveHour}
270 % Tells \LaTeX\ to typeset times using a 12-hour clock.
271 % \end{macro}
272 %
273 % \begin{macro}{\TwentyFourHour}
274 % Tells \LaTeX\ to typeset times using a 24-hour clock.
275 % \end{macro}
276 %
277 % \begin{macro}{\NewAppointment}
278 % By using the |\NewAppointment| command, the user can customize the appearance
279 % of the schedule by changing the color of the text or the background color.
280 % The syntax is |\NewAppointment|\meta{appointment-name}\meta{background-color}\meta{text-color}.
281 % \end{macro}
282 %
283 % \StopEventually{}
284 %\newpage
285 %\section{Source Code}
286 % \iffalse
287 %<*package>
288 % \fi
289 % \begin{macrocode}
290 \ProvidesFile{schedule.sty}
291 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
292 \ProvidesPackage{schedule}[2019/7/31 v1.20 schedule package]
293 \RequirePackage{calc}
294 \RequirePackage{xcolor}
295 \definecolor{dark}{gray}{.75}
296 %
297 % CONSTANTS FOR THE WEEK
298 %
299 \def\@sunday{Su}
300 \def\@Sunday{Sunday}
301 \def\@monday{M}
302 \def\@Monday{Monday}
303 \def\@tuesday{T}
304 \def\@Tuesday{Tuesday}
305 \def\@wednesday{W}
306 \def\@Wednesday{Wednesday}
307 \def\@thursday{Th}
308 \def\@Thursday{Thursday}
309 \def\@friday{F}
310 \def\@Friday{Friday}
311 \def\@saturday{Sa}
312 \def\@Saturday{Saturday}
313 %
314 % COUNTERS, LENGTHS, ETC.
315 %
316 \newlength{\cell@height}
317 \setlength{\cell@height}{1in}
318 \newlength{\cell@width}
319 \setlength{\cell@width}{1in}
320 \newlength{\box@depth}
321 \newcounter{sch@col@width} \setcounter{sch@col@width}{60}
322 \newlength{\box@width}
323 \setlength{\box@width}{1in*(\value{sch@col@width}/60)}
324 \newlength{\col@width}
325 \setlength{\col@width}{1in*(\value{sch@col@width}/60)}
326 \newlength{\sch@depth} \setlength{\sch@depth}{9in}
327 \newlength{\fill@length}
328 \newlength{\@temp@length}
329 \newlength{\@@temp@length}
330 \newlength{\line@thickness} % The thickness of the lines in the drawing
331 \setlength{\line@thickness}{.4pt}
332 \newlength{\adjusted@cell@width}
333 \newlength{\adjusted@cell@height}
334
335 \newcounter{picture@units@wide}
336 \newcounter{xcoords}
337 \newcounter{ycoords}
338 \newcounter{timea}
339 \newcounter{timeb}
340 \newcounter{grid@width}
341 \newcounter{grid@height}
342 \newcounter{number@of@cells} % The number of VERTICAL cells
343 \newcounter{number@of@subcells}
344 \newcounter{number@of@days} % The number of days in the grid
345 \newcounter{dp@vlines} % The number of vertical lines actually needed is
346 % \value{number@of@days} + 1 ...
347 \newcounter{dp@hlines} % The number of horizontal lines actually needed is
348 % \value{number@of@cells} + 1 ...
349 \newcounter{dp@hcell@lines} % The number of horizontal lines that are
350 % either (1) associated with an hour, or
351 % (2) on the top or bottom of the grid.
352 \newcounter{pu@cell@width}
353 \newcounter{pu@cell@height}
354 \setcounter{pu@cell@height}{60}
355 \newcounter{pu@grid@top}
356 \newcounter{pu@grid@width}
357 \newcounter{pu@subticks}
358 \newcounter{start@time}
359 \newcounter{end@time}
360 \newcounter{x@coord} % Temporary x-coordinate
361 \newcounter{y@coord} % Temporary y-coordinate
362 \newcounter{@tempc}
363 \newcounter{@tempd}
364 \newcounter{label@sep} % distance from label to gride
365 \setcounter{label@sep}{5} %initialized to 5 picture units
366
367 \newcounter{x@Sunday}
368 \newcounter{x@Monday}
369 \newcounter{x@Tuesday}
370 \newcounter{x@Wednesday}
371 \newcounter{x@Thursday}
372 \newcounter{x@Friday}
373 \newcounter{x@Saturday}
374
375 \newsavebox{\temp@box}
376 \newif\ifweekends
377 \newif\iftwelve
378 \newcount\@i
379 \newcount\@j
380
381 \def\TimeRange#1{\compute@number@of@cells #1\end@compute}
382 \def\compute@number@of@cells#1:#2-#3:#4\end@compute{%
383 \setcounter{number@of@cells}{#3-#1}%
384 \setcounter{start@time}{#1}%
385 \setcounter{end@time}{#3}}
386
387 \def\TextSize#1{\def\appt@textsize{#1}}
388 \TextSize{\scriptsize}
389
390 \def\IncludeWeekends{\weekendstrue}
391 \def\NoWeekends{\weekendsfalse}
392
393 \def\SevenDay{\weekendstrue}
394 \def\FiveDay{\weekendsfalse}
395 \def\TwelveHour{\twelvetrue}
396 \def\TwentyFourHour{\twelvefalse}
397
398 \def\CellHeight#1{\setlength{\cell@height}{#1}%
399 \setlength{\unitlength}{\cell@height*\ratio{1pt}{60pt}}}
400 \def\CellWidth#1{\setlength{\cell@width}{#1}%
401 \setcounter{pu@cell@width}{1*\ratio{\cell@width}{\unitlength}}}
402 \def\SubUnits#1{\setcounter{pu@subticks}{#1}%
403 \setcounter{number@of@subcells}{60/\value{pu@subticks}}}
404
405 \def\calculate@grid@dimensions{%
406 \ifweekends \setcounter{number@of@days}{7}
407 \else \setcounter{number@of@days}{5}%
408 \fi%
409 \setcounter{dp@hcell@lines}{\value{number@of@cells}+1}
410 \setcounter{grid@width}{\value{number@of@days}*\value{pu@cell@width}}%
411 \setcounter{grid@height}{\value{number@of@cells}*60}
412 \setcounter{dp@vlines}{\value{number@of@days}+1}
413 \setcounter{dp@hlines}{\value{number@of@cells}*(60/\value{pu@subticks}) + 1}}
414
415
416 \def\draw@grid{%\calculate@grid@dimensions
417 \linethickness{.2pt}%
418 \multiput(0,0)(0,\value{pu@subticks}){\value{dp@hlines}}{\line(1,0){\value{grid@width}}}%
419 \thicklines
420 \multiput(0,0)(0,60){\value{dp@hcell@lines}}{\line(1,0){\value{grid@width}}}
421 \thinlines}
422
423 \def\LineThickness#1{\setlength{\line@thickness}{#1}%
424 \linethickness{\line@thickness}%
425 \setlength{\adjusted@cell@width}{\cell@width - 1\line@thickness}
426 \setlength{\adjusted@cell@height}{\cell@height - 1\line@thickness}}
427
428
429 \def\@Su@week{{Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday}}
430 \def\@M@week{{Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday}}
431 \def\@T@week{{Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday}}
432 \def\@W@week{{Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday}}
433 \def\@Th@week{{Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday}}
434 \def\@F@week{{Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday}}
435 \def\@Sa@week{{Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday}}
436
437 \def\BeginOn#1{\def\start@day{#1}}
438
439 \def\add@labels{%
440 \ifx\start@day\@Sunday \expandafter\do@days\@Su@week \relax
441 \else\ifx\start@day\@Monday \expandafter\do@days\@M@week \relax
442 \else\ifx\start@day\@Tuesday \expandafter\do@days\@T@week \relax
443 \else\ifx\start@day\@Wednesday \expandafter\do@days\@W@week \relax
444 \else\ifx\start@day\@Thursday \expandafter\do@days\@Th@week \relax
445 \else\ifx\start@day\@Friday \expandafter\do@days\@F@week \relax
446 \else\expandafter\do@days\@Sa@week \relax
447 \fi\fi\fi\fi\fi\fi}
448
449
450 \def\@sfor #1:=#2 \upto #3 \step #4 \do #5{%
451 #1=#2\relax%
452 \@whilenum #1<#3 \do {#5 \advance#1 by #4}#5}
453
454 \def\add@times{%
455 \setcounter{@tempc}{\value{start@time}}%
456 \@sfor \@i :=0 \upto \value{number@of@cells} \step 1 \do%
457 {\setcounter{x@coord}{0}% Set the x-coord right
458 \setcounter{y@coord}{\value{grid@height}-60*\@i}% adjust for the right hour cell
459 \ifnum\value{@tempc}=0%
460 \iftwelve
461 \setcounter{@tempd}{\value{@tempc}+12}%
462 \put(\value{x@coord},\value{y@coord}){%
463 \makebox(0,0)[r]{\the@tempd:00~midnight~~}}% Midnight Hack
464 \else
465 \setcounter{@tempd}{\value{@tempc}}%
466 \put(\value{x@coord},\value{y@coord}){%
467 \makebox(0,0)[r]{\the@tempd:00~~}}% Midnight Hack
468 \fi
469 \else\ifnum\value{@tempc}=24%
470 \iftwelve
471 \setcounter{@tempd}{\value{@tempc}-12}%
472 \put(\value{x@coord},\value{y@coord}){%
473 \makebox(0,0)[r]{\the@tempd:00~midnight~}}% Midnight Hack
474 \else
475 \setcounter{@tempd}{\value{@tempc}}%
476 \put(\value{x@coord},\value{y@coord}){%
477 \makebox(0,0)[r]{\the@tempd:00~~}}% Midnight Hack
478 \fi
479 \else\ifnum\value{@tempc}>12%
480 \iftwelve
481 \setcounter{@tempd}{\value{@tempc}-12}%
482 \put(\value{x@coord},\value{y@coord}){%
483 \makebox(0,0)[r]{\the@tempd:00~pm~}}%
484 \else
485 \setcounter{@tempd}{\value{@tempc}}%
486 \put(\value{x@coord},\value{y@coord}){%
487 \makebox(0,0)[r]{\the@tempd:00~~}}%
488 \fi
489 \else\ifnum\value{@tempc}=12%
490 \iftwelve
491 \setcounter{@tempd}{\value{@tempc}}%
492 \put(\value{x@coord},\value{y@coord}){%
493 \makebox(0,0)[r]{\the@tempd:00~noon~}}% Noontime Hack
494 \else
495 \setcounter{@tempd}{\value{@tempc}}%
496 \put(\value{x@coord},\value{y@coord}){%
497 \makebox(0,0)[r]{\the@tempd:00~~}}%
498 \fi
499 \else
500 \iftwelve
501 \put(\value{x@coord},\value{y@coord}){%
502 \makebox(0,0)[r]{\the@tempc:00~am~}}%
503 \else
504 \put(\value{x@coord},\value{y@coord}){%
505 \makebox(0,0)[r]{\the@tempc:00~~}}%
506 \fi
507 \fi\relax%
508 \fi\relax%
509 \fi\relax%
510 \fi\relax%
511 \@sfor \@j := \value{pu@subticks} \upto 59 \step \value{pu@subticks} \do%
512 {\ifnum\@i=\value{number@of@cells}% Test to see if this should be the last label
513 \relax%
514 \else%
515 \ifnum\@j=60%
516 \relax%
517 \else%
518 \ifnum\@j<10%
519 \def\the@minutes{0\the\@j}%
520 \else\def\the@minutes{\the\@j}%
521 \fi%
522 \setcounter{y@coord}{\value{y@coord}-\@j}%
523 \ifnum\value{@tempc}=0%
524 \iftwelve
525 \setcounter{@tempd}{\value{@tempc}+12}%
526 \put(\value{x@coord},\value{y@coord}){%
527 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~am~}}% Hack to get 12:xx AM right.
528 \else
529 \setcounter{@tempd}{\value{@tempc}}%
530 \put(\value{x@coord},\value{y@coord}){%
531 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~~}}
532 \fi
533 \else\ifnum\value{@tempc}=24%
534 \iftwelve
535 \setcounter{@tempd}{\value{@tempc}-12}%
536 \put(\value{x@coord},\value{y@coord}){%
537 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~am~}}% Hack to get 12:xx AM right.
538 \else
539 \setcounter{@tempd}{\value{@tempc}}%
540 \put(\value{x@coord},\value{y@coord}){%
541 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~~}}
542 \fi
543 \else\ifnum\value{@tempc}>12%
544 \iftwelve
545 \setcounter{@tempd}{\value{@tempc}-12}%
546 \put(\value{x@coord},\value{y@coord}){%
547 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~pm~}}% ...write the time (using pm)...
548 \else
549 \setcounter{@tempd}{\value{@tempc}}%
550 \put(\value{x@coord},\value{y@coord}){%
551 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~~}}
552 \fi
553 \else\ifnum\value{@tempc}=12%
554 \iftwelve
555 \setcounter{@tempd}{\value{@tempc}}%
556 \put(\value{x@coord},\value{y@coord}){%
557 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~pm~}}% Hack to get 12:xx PM right.
558 \else
559 \setcounter{@tempd}{\value{@tempc}}%
560 \put(\value{x@coord},\value{y@coord}){%
561 \makebox(0,0)[r]{\tiny\the@tempd:\the@minutes~~}}
562 \fi
563 \else
564 \iftwelve
565 \put(\value{x@coord},\value{y@coord}){%
566 \makebox(0,0)[r]{\tiny\the@tempc:\the@minutes~am~}}% ...write the time (using am).
567 \else
568 \put(\value{x@coord},\value{y@coord}){%
569 \makebox(0,0)[r]{\tiny\the@tempc:\the@minutes~~}}
570 \fi
571 \fi%
572 \fi%
573 \fi%
574 \fi%
575 \fi%
576 \fi%
577 \setcounter{y@coord}{\value{y@coord}+\@j}}
578 \addtocounter{@tempc}{1}}}%
579
580 \def\do@days#1#2#3#4#5#6#7{%
581 \setcounter{x@coord}{1*\ratio{\value{pu@cell@width} pt}{2 pt}}%
582 \setcounter{y@coord}{\value{grid@height}+\value{label@sep}}%
583 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #1}}%
584 \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
585 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #2}}%
586 \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
587 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #3}}%
588 \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
589 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #4}}%
590 \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
591 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #5}}%
592 \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
593 \ifweekends
594 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #6}}%
595 \setcounter{x@coord}{\value{x@coord}+\value{pu@cell@width}}%
596 \put(\value{x@coord},\value{y@coord}){\makebox(0,0)[b]{\large #7}}\fi}
597
598
599 \def\set@x@coords@for@days{%
600 \ifx\start@day\@Sunday%
601 \@i=0\relax%
602 \@tfor \@temp := {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} \do%
603 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
604 \advance\@i by 1}
605 \def\skipday@i{F}
606 \def\skipday@ii{Sa}\fi
607 \ifx\start@day\@Monday
608 \@i=0\relax%
609 \@tfor \@temp := {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} \do%
610 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
611 \advance\@i by 1}
612 \def\skipday@i{Sa}
613 \def\skipday@ii{Su}\fi
614 \ifx\start@day\@Tuesday
615 \@i=0\relax%
616 \@tfor \@temp := {Tuesday} {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday} \do%
617 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
618 \advance\@i by 1}
619 \def\skipday@i{Su}
620 \def\skipday@ii{M}\fi
621 \ifx\start@day\@Wednesday
622 \@i=0\relax%
623 \@tfor \@temp := {Wednesday} {Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday} \do%
624 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
625 \advance\@i by 1}
626 \def\skipday@i{M}
627 \def\skipday@ii{T}\fi
628 \ifx\start@day\@Thursday
629 \@i=0\relax%
630 \@tfor \@temp := {Thursday} {Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} \do%
631 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
632 \advance\@i by 1}
633 \def\skipday@i{T}
634 \def\skipday@ii{W}\fi
635 \ifx\start@day\@Friday
636 \@i=0\relax%
637 \@tfor \@temp := {Friday} {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} \do%
638 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
639 \advance\@i by 1}
640 \def\skipday@i{W}
641 \def\skipday@ii{Th}\fi
642 \ifx\start@day\@Saturday
643 \@i=0\relax%
644 \@tfor \@temp := {Saturday} {Sunday} {Monday} {Tuesday} {Wednesday} {Thursday} {Friday} \do%
645 {\setcounter{x@\@temp}{\@i*\value{pu@cell@width}}%
646 \advance\@i by 1}
647 \def\skipday@i{Th}
648 \def\skipday@ii{F}\fi
649 }
650
651 % ------------------------------------------------------------------------
652 % Commands to insert info about an appointment
653 % ------------------------------------------------------------------------
654 \newif\ifset@start@time
655 \newif\ifset@end@time
656 \newif\ifsetboxdepth
657 \newif\ifinrange
658
659 \def\NewAppointment#1#2#3{% #1 = name, #2 = background color, #3 = textcolor
660 \expandafter\def\csname #1\endcsname##1##2##3##4{%
661 \setboxdepthtrue% assume we want to calculate the box depth
662 \inrangetrue% assume the appt is in range
663 \set@start@timetrue% assume we want to calculate the start time
664 \set@end@timetrue% assume we want to calculate the end time
665 \@includetrue% assume we will include it
666 \edef\appt@name{#1}% save the appt name
667 \edef\appt@color{#2}% save the background color
668 \edef\appt@textcolor{#3}% save the save color
669 \expandafter\def\csname #1@name\endcsname{##1}% save the name
670 \expandafter\def\csname #1@location\endcsname{##2}% save the loc.
671 \expandafter\def\csname #1@days\endcsname{##3}% save the days
672 \expandafter\def\csname #1@time\endcsname{##4}% save the time
673 \place@appt@box##3,\stop}}
674
675 \NewAppointment{class}{dark}{black}
676
677 \def\place@appt@box#1{%
678 \ifx#1\stop \let\@next=\@gobble%
679 \else \let\@next=\set@x@coords\fi\@next#1}
680
681 \def\set@x@coords#1,{\def\the@day{#1}%
682 \ifx\the@day\@sunday\setcounter{xcoords}{\value{x@Sunday}}%
683 \else\ifx\the@day\@monday\setcounter{xcoords}{\value{x@Monday}}%
684 \else\ifx\the@day\@tuesday\setcounter{xcoords}{\value{x@Tuesday}}%
685 \else\ifx\the@day\@wednesday\setcounter{xcoords}{\value{x@Wednesday}}%
686 \else\ifx\the@day\@thursday\setcounter{xcoords}{\value{x@Thursday}}%
687 \else\ifx\the@day\@friday\setcounter{xcoords}{\value{x@Friday}}%
688 \else\setcounter{xcoords}{\value{x@Saturday}}%
689 \fi\fi\fi\fi\fi\fi%
690 \edef\@@temp{\csname \appt@name @time\endcsname}%
691 \expandafter\set@y@coords\@@temp\stop}
692
693 \def\set@y@coords#1:#2-#3:#4\stop{%
694 \def\@starthour{#1}%
695 \def\@startminutes{#2}
696 \def\@endhour{#3}%
697 \def\@endminutes{#4}%
698 \ifnum#1<\value{start@time} \setcounter{ycoords}{\value{grid@height}}%
699 \edef\@starthour{\value{start@time}}
700 \def\@startminutes{0}
701 \set@start@timefalse%
702 \fi%
703 \ifnum#3<\value{end@time} \relax%
704 \else \edef\@endhour{\value{end@time}}
705 \def\@endminutes{0}%
706 \setcounter{ycoords@bot}{0}
707 \set@end@timefalse
708 \fi %
709 \ifset@start@time%
710 \setcounter{ycoords}{\value{grid@height}-(60*(#1-\value{start@time})+#2)}\fi%
711 \ifset@end@time%
712 \setcounter{ycoords@bot}{\value{grid@height}-(60*(#3-\value{start@time})+#4)}\fi%
713 \setlength{\box@depth}{\@endhour\cell@height + (\cell@height*\ratio{\@endminutes pt}{60pt}) %
714 - \@starthour\cell@height - (\cell@height*\ratio{\@startminutes pt}{60pt})}%
715 \ifnum#1<\value{end@time} \relax\else \inrangefalse \fi%
716 \draw@appt@box\place@appt@box}
717
718 \newif\if@include
719
720 \def\draw@appt@box{%
721 \ifweekends \relax % if we use 7-days, this won't change
722 \else \ifx \the@day\skipday@i \@includefalse \fi % first condition for change
723 \ifx \the@day\skipday@ii \@includefalse \fi\fi % second condition for change
724 \ifinrange \relax\else \@includefalse \fi %
725 \if@include %
726 \put(\value{xcoords},\value{ycoords}){\colorbox{\appt@color}{\parbox[t]{\cell@width}{\ %
727 \vspace{\box@depth}}}}
728 \thinlines
729 \put(\value{xcoords},\value{ycoords}){\line(1,0){\value{pu@cell@width}}}
730 \put(\value{xcoords},\value{ycoords@bot}){\line(1,0){\value{pu@cell@width}}}
731 \put(\value{xcoords},\value{ycoords}){%
732 \ \parbox[t]{\cell@width-8pt}{\mbox{}\\ \appt@textsize %
733 \ifdim\box@depth>\baselineskip
734 \textcolor{\appt@textcolor}{\csname \appt@name @name\endcsname} \\ %
735 \ifdim\box@depth>2\baselineskip
736 \textcolor{\appt@textcolor}{\csname \appt@name
737 @location\endcsname}\fi\fi }}\fi}
738
739 \def\convert@class@time#1:#2-#3:#4\end@time{%
740 {\count1=#1\relax%
741 \count3=#3\relax%
742 \ifnum#1>12 \advance\count1 by -12\fi\relax%
743 \ifnum#3>12 \advance\count3 by -12\fi\relax%
744 \ifnum#1<12\relax%
745 \ifnum#3<12\relax \mbox{\the\count1:#2am--\the\count3:#4am}\relax%
746 \else \mbox{\the\count1:#2am--\the\count3:#4pm}\fi\relax%
747 \else \mbox{\the\count1:#2pm--\the\count3:#4pm}\fi\relax}}
748
749 \def\compute@box@depth#1:#2-#3:#4\end@bx{%
750 \setlength{\box@depth}{#3\cell@height + (\cell@height*\ratio{#4pt}{60pt}) %
751 - #1\cell@height - (\cell@height*\ratio{#2pt}{60pt})}}
752
753 \newcounter{ycoords@bot}
754
755 \newcounter{x@tempa}
756 \newcounter{x@tempb}
757 \newcounter{y@tempa}
758 \newcounter{y@tempb}
759 \newcounter{temp@cnt@a}
760
761 \newlength{\title@height}
762 \newlength{\label@height}
763 \settoheight{\label@height}{Wednesday}
764
765 \newcounter{pu@label@width}
766 \newlength{\center@hack}
767
768 \newenvironment{schedule}[1][:]%
769 {\bigskip
770 \calculate@grid@dimensions%
771 \setcounter{pu@grid@width}{\value{pu@cell@width}*\value{number@of@days}}%
772 \settowidth{\@temp@length}{\normalsize 12:00\ pm\ }%
773 \setcounter{pu@label@width}{1*\ratio{\@temp@length}{\unitlength}}%
774 \setcounter{pu@grid@top}{\value{grid@height}+(1*\ratio{\label@height}{\unitlength}) + %
775 (1*\ratio{.25in}{\unitlength})}%
776 \if#1:\relax \else%
777 \settoheight{\title@height}{\large #1}%
778 \addtocounter{pu@grid@top}{1*\ratio{\title@height}{\unitlength}}%
779 \fi%
780 \setlength{\center@hack}{(.5\linewidth-.5\unitlength*\value{pu@grid@width}+%
781 .5\unitlength*\value{pu@label@width})}%
782 \noindent\hspace*{\center@hack}%
783 \begin{picture}(\value{pu@grid@width},\value{pu@grid@top})%
784 \draw@grid
785 \add@labels
786 \if#1:\relax \else
787 \setcounter{ycoords}{\value{grid@height}+(1*\ratio{\label@height}{\unitlength}) + %
788 (1*\ratio{.25in}{\unitlength})}
789 \setcounter{xcoords}{1*\ratio{\value{pu@grid@width} pt}{2 pt}}
790 \put(\value{xcoords},\value{ycoords}){\makebox(0,0)[b]{\Large #1}}
791 \fi
792 \add@times
793 \set@x@coords@for@days}
794 {\multiput(0,0)(\value{pu@cell@width},0){\value{dp@vlines}}{\line(0,1){\value{grid@height}}}
795 \end{picture}\bigskip}
796
797 \setlength{\fboxsep}{0in}
798 % \end{macrocode}
799 % \iffalse
800 %</package>
801 % \fi
802 % \newpage
803 % \PrintChanges
804 % \PrintIndex
805 % \Finale