%\iffalse % % file: timesht.dtx % Copyright (C) 1996-1997 by Frank Bennett. All rights reserved. % % IMPORTANT NOTICE: % % You are not allowed to change this file. You may however copy % this file to a file with a different name and then change the % copy if (a) you do not charge for the modified code, (b) you % acknowledge the author of this file in the new file, if it % is distributed to others, and (c) you attach these same % conditions to the new file. % % You are not allowed to distribute this file alone. You are not % allowed to take money for the distribution or use of this file % (or a changed version) except for a nominal charge for copying % etc. % % You are allowed to distribute this file under the condition that % it is distributed with all of its contents, intact. % % For error reports, or offers to help make this a more powerful, % friendlier, and altogether more thrilling package, please contact me on % fb@soas.ac.uk. Better yet, make a contribution to % my pension. Account details available on request. % %\fi % % \def\fileversion{3.1.1.1} % \def\filedate{1998/01/17 18:15:23} % % \iffalse % %<*driver> \documentclass{ltxdoc} %\CodelineIndex %\EnableCrossrefs \begin{document} \OnlyDescription % Comment out for implementation details \DocInput{timesht.dtx} \end{document} % %\fi % % \changes{v1.1}{1997/02/26}{Redraft of original Timesheets % package, using Timetable package as a model.} % \changes{v1.2}{1997/10/18}{New public release of all styles % and modules incorporating global bug-fixes.} % %\iffalse % Source tree moved under RCS % --------------------------- % timesht.dtx,v % Revision 3.1.1.1 1998/01/17 18:15:23 root % Release code, checksum verified % % Revision 3.1 1998/01/17 17:15:05 root % Release code % % Revision 2.15 1998/01/17 11:54:43 root % *** empty log message *** % % Revision 2.14 1998/01/17 11:48:41 root % *** empty log message *** % % Revision 2.13 1998/01/17 10:27:17 root % *** empty log message *** % % Revision 2.12 1998/01/17 10:25:29 root % *** empty log message *** % % Revision 2.11 1998/01/17 04:42:57 root % *** empty log message *** % % Revision 2.10 1998/01/16 20:42:51 root % *** empty log message *** % % Revision 2.9 1998/01/16 17:10:16 root % *** empty log message *** % % Revision 2.8 1997/12/06 09:04:25 root % Finished elimination of landscape code, eliminated superfluous brace. % % Revision 2.7 1997/12/06 09:01:41 root % Initialized tms@blocklist to empty macro. % % Revision 2.6 1997/12/06 08:54:55 root % Changed docstrip label from class to package. % % Revision 2.5 1997/12/06 08:32:41 root % Disable paragraph indenting inside calendar environment. % % Revision 2.4 1997/12/06 08:27:43 root % Converted to style from class. % % Revision 2.3 1997/12/04 19:32:22 bennett % Added typeface variables for appointments having only a % single time. % % Revision 2.2 1997/11/07 10:44:05 root % Release code. % % Revision 2.1.1.3 1997/11/05 06:21:56 root % Superfluous brace in new definition. % % Revision 2.1.1.2 1997/11/05 06:17:14 root % Hooked up title parameter following report fro, % % from Edward Czilli. % % Revision 2.1.1.1 1997/11/04 05:06:07 root % Development branch % % Revision 2.1 1997/11/01 14:47:16 bennett % Release code. % % Revision 1.7 1997/10/30 20:25:58 root % Moved \extrarowheight so that it is only invoked once, when % the table is first opened. % % Revision 1.6 1997/10/30 13:46:59 root % Moved reset of counter, in the code for the group-closing % footer, above the closing \\\hline to avoid leftovers on % the following line. % % Revision 1.5 1997/10/30 12:38:13 root % Changed use of \@newline to \par, to avoid weird errors arising % from LaTeX for reasons I do not fully understand. % % Revision 1.4 1997/10/30 12:31:50 root % Put \relax after the option text setting blockminutes. % % Revision 1.3 1997/10/29 20:13:36 bennett % *** empty log message *** % % Revision 1.2 1997/10/29 17:18:39 root % Added reset of block counter on end of subgroup, to make % underlining between blocks position correctly on second % and subsequent pages. % % Revision 1.1 1997/10/29 08:17:52 root % Initial revision % %\fi % % \title{User's Guide to the Timesheet % package\thanks{This file is version number % \fileversion{}. It was last revised on % \filedate{}.}} % % \author{Frank G. Bennett, Jr.} % % \maketitle % % \setcounter{StandardModuleDepth}{1} % \DeleteShortVerb{\|} % \MakeShortVerb{\"} % % \CheckSum{598} % % \section{Note} % % Documentation for this package is contained in the file % \texttt{calguide.tex}. % %\StopEventually{\PrintIndex} % % \section{The Class File} % % Preliminaries. % % \begin{macrocode} %<*package> \NeedsTeXFormat{LaTeX2e}[1995/06/01] \ProvidesPackage{timesht} [1998/01/17 18:15:23 3.1.1.1 Timesheet (Frank Bennett)] % \end{macrocode} % % Initialize all registers and if statements to be % used by this class. % % \begin{macrocode} \newif\iftms@usetimes \tms@usetimestrue \newlength\tms@tablewidth \newlength{\tms@hw} \newlength{\tms@templen} \newlength{\tms@widthlessboxes} \newlength{\tms@timetextlen} \newtoks\tms@tempreg@a \newtoks\tms@tempreg@b \newcount\tms@tempcount \newcount\tms@start \newcount\tms@end \newcount\tms@minuteblocks \newcount\tms@boxes \newcount\tms@days \newcount\tms@blocks \newcount\tms@time@start \newcount\tms@time@end \newcount\tms@hours@start \newcount\tms@minutes@start \newcount\tms@hours@end \newcount\tms@minutes@end \newcount\tms@minute@base \newlength{\tms@numlen} \newcount\tms@rightprop \newcount\tms@leftprop \newcount\tms@groupblocks \newcount\tms@groupblockcount \tms@groupblockcount=1% \newlength{\tms@colonlen} \newlength{\tms@dashlen} \newlength{\tms@leftlen} \newlength{\tms@rightlen} \tms@leftprop=1% \tms@rightprop=1% % \end{macrocode} % Language setup. % \begin{macrocode} \input calopts.cfg \InputIfFileExists{dates.cfg}{}{} \ProcessOptions % \end{macrocode} % % Load a bunch of useful packages. % % \begin{macrocode} \RequirePackage{longtable} \RequirePackage{array}[1996/06/14] \RequirePackage{calendar} \RequirePackage{keyval} % \end{macrocode} % % Turn off the listing of days in the Calendar style. % It only works well for monthly calendars. % % \begin{macrocode} \tracingdates=0% % \end{macrocode} % % Set up a list of options for the Calendar style engine % to use with the "keyval" parser. % % \begin{macrocode} \define@key{opt}{leftspace}{\setlength{\LTleft}{#1}} \define@key{opt}{rightspace}{\setlength{\LTright}{#1}} \define@key{opt}{width}{\setlength{\tms@tablewidth}{#1}} \define@key{opt}{title}{\def\tms@title{#1}} \define@key{opt}{start}{\@settime\tms@start#1{}} \define@key{opt}{end}{\@settime\tms@end#1{}} \define@key{opt}{blockminutes}{\tms@minuteblocks=#1\relax} \define@key{opt}{blockgroup}{\tms@groupblocks=#1\relax} \define@key{opt}{leftright}{\tms@extractprops#1{}} \define@key{opt}{titletype}{\def\tms@titletype##1{{#1{##1}}}} \define@key{opt}{labeltype}{\def\tms@labeltype##1{{#1{##1}}}} \define@key{opt}{timelabeltype}{\def\tms@timelabeltype##1{{#1{##1}}}} \define@key{opt}{timeitemtype}{\def\tms@timeitemtype##1{{#1{##1}}}} \define@key{opt}{itemtype}{\def\tms@itemtype##1{{#1{##1}}}} \define@key{opt}{notimes}[f]{\tms@usetimesfalse} % \end{macrocode} % % Before setting default values, % provide a set of parsing macros for use in scanning % some of the options fed to the "keyval" parser. % Doing this here allows us to specify the defaults in a % human readable syntax. % % \begin{macrocode} \def\tms@extractprops#1/#2#{% \tms@leftprop=#1\tms@rightprop=#2} \def\@settime#1#2:#3#{% \tms@tempcount=#2% \multiply\tms@tempcount by60% \advance\tms@tempcount by#3% \global#1\tms@tempcount} \def\@splitblocks#1-#2#{% \def\@blockstarttext{#1}% \def\@blockendtext{#2}} \def\@setblocks#1,#2#{% \ifcat$#1$% \let\next\@gobble% \else% \let\next\@setblocks% \global\advance\tms@blocks by 1% \@splitblocks#1{}% \expandafter\@settime% \expandafter\tms@time@start\@blockstarttext{}% \expandafter\@settime% \expandafter\tms@time@end\@blockendtext{}% \let\tms@tempmac\tms@blocklist% \edef\tms@blocklist{% \tms@tempmac\the\tms@time@start-\the\tms@time@end,}% \fi% \next#2{}} \def\tms@chopblock#1-#2,#3#{% \global\tms@time@start=#1% \global\tms@time@end=#2% \gdef\tms@blocklist{#3}}% \def\tms@labellist{}% \def\@extractlabels#1,#2#{% \ifcat$#1$% \tms@tempreg@a=\expandafter{\tms@labellist}% \edef\tms@label##1{% \noexpand\ifcase##1\the\tms@tempreg@a\noexpand\fi}% \let\next\@gobble% \else% \let\next\@extractlabels% \let\tms@tempmac\tms@labellist% \expandafter\def% \expandafter\tms@labellist% \expandafter{% \tms@tempmac\or #1}% \fi% \next#2{}} % \end{macrocode} % % Set up default values for the "keyval" options. % % \begin{macrocode} \def\tms@titletype#1{{\Large\bfseries#1}}% \def\tms@labeltype#1{{\large\bfseries#1}}% \def\tms@timelabeltype#1{{\bfseries#1}} \def\tms@timeitemtype#1{{\large#1}} \def\tms@itemtype#1{{\small#1}} \def\tms@title{\themonth\space\theday,\space\theyear} \@settime\tms@start8:00{} \@settime\tms@end17:00{} \tms@minuteblocks=15\relax% \def\tms@blocklist{}% \def\tms@label#1{\themonth\space\theday}% \tms@groupblocks=4\relax% \tms@extractprops4/5{} % \end{macrocode} % % % Define the calendar. As for all Calendar styles, % this is done using "\newcalendar" with 17 arguments. % % \begin{macrocode} \newcalendar% % \end{macrocode} % % Name the new calendar environment. % % \begin{macrocode} {timesheet} % \end{macrocode} % % Select an off-the-shelf macro for printing % that will dump printable % items on DVI. % % \begin{macrocode} {\cal@insert} % \end{macrocode} % % Be indifferent to the starting day of the week. % ("0" through "6" specify Sunday through Saturday). % % \begin{macrocode} {7} % \end{macrocode} % % Set the number of items in a group (time blocks) % % \begin{macrocode} {\tms@blocks} % \end{macrocode} % % Set the number of items in a subgroup (one block). % % \begin{macrocode} {1} % \end{macrocode} % % Use ampersand table separator before all items % but the first in a subgroup (never used, b/c only one item). % % \begin{macrocode} {&} % \end{macrocode} % % Increment the date at the end of every group, and sneak % in a post-increment recalculation for the time labels. % % \begin{macrocode} {G\tms@gettimes} % \end{macrocode} % % Specify the header. This has to be built on the fly % in the Timesheet style, to give control over width % to the user. So just give the % name of the macro here. % \begin{macrocode} {\tms@header} % \end{macrocode} % % Specify the tail of the table. % % \begin{macrocode} {&% \global\tms@groupblockcount=1\relax% \\\hline% \end{longtable}}% % \end{macrocode} % % How to end a group. % % \begin{macrocode} {\cal@footer\newpage\cal@header} % \end{macrocode} % % Specify how to break the end of a subgroup. % In this case, we end the table line and add % a time block that must be generated on the fly. % % The new "\\*" form in "longtable" seems to have no % impact here. Rats. % % \begin{macrocode} {&% \ifnum\tms@groupblockcount<\tms@groupblocks% \\*\cline{1-4}% \global\advance\tms@groupblockcount by1\relax% \else% \\\hline% \global\tms@groupblockcount=1\relax% \fi% \tms@timecoltext} % \end{macrocode} % Next is code to be run before the calendar options % are digested and the controlling date is read. % % \textit{Set a couple of Calendar toggles before % scanning the date contained in the "timesheet" % environment.} % \begin{macrocode} {\dates@requiremonthtrue\dates@requiredaytrue % \end{macrocode} % \textit{Set default width of table.} % \begin{macrocode} \setlength{\tms@tablewidth}{\textwidth} % \end{macrocode} % \textit{Initialize \cs{tms@blocklist} to \texttt{nil}.} % \begin{macrocode} \def\tms@blocklist{}} % \end{macrocode} % % "\cal@range@start", "\cal@range@end" and "\dates@date" % are all set internally, so we just provide information % here. Remember to adjust human-readable dates with % "\caldate" when changing "\dates@date", and % long dates with "\dates@fix" when adjusting % the human readable stuff. % % \begin{macrocode} {\message{^^JStart: \theshortweekday\space% \theday\space\theshortmonth\space\theyear}% \dates@date\cal@range@end% \caldate% \message{^^JEnd: \theshortweekday\space% \theday\space\theshortmonth\space\theyear}% \dates@date\cal@range@start% \caldate% % \end{macrocode} % % \textit{Set the number of blocks and the number of blocks in a group.} % % \begin{macrocode} \relax% \tms@blocks\tms@end% \advance\tms@blocks by-\tms@start% \divide\tms@blocks by\tms@minuteblocks% % \end{macrocode} % % \textit{Prepare an algorithm to derive the start and % end time of a block from the value of the % counter \texttt{cal@group@count} and set values in % \texttt{tms@time@start}, \texttt{tms@time@end} % and \texttt{tms@timecoltext}.} % % \begin{macrocode} \def\tms@gettimes{% \ifcat$\tms@blocklist$% \tms@time@start\cal@group@count% \multiply\tms@time@start by\tms@minuteblocks% \global\advance\tms@time@start by\tms@start% \tms@time@end\tms@time@start% \global\advance\tms@time@end by\tms@minuteblocks% \else% \expandafter\tms@chopblock\tms@blocklist-,{}% \fi% \mod{60}\tms@time@start\tms@minutes@start% \tms@hours@start\dates@three% \divide\tms@hours@start by60% \mod{60}\tms@time@end\tms@minutes@end% \tms@hours@end\dates@three% \divide\tms@hours@end by60% \ifnum\tms@minutes@start<10% \edef\tms@minutes@start@mac{0\the\tms@minutes@start}% \else% \edef\tms@minutes@start@mac{\the\tms@minutes@start}% \fi% \ifnum\tms@minutes@end<10% \edef\tms@minutes@end@mac{0\the\tms@minutes@end}% \else% \edef\tms@minutes@end@mac{\the\tms@minutes@end}% \fi% \xdef\tms@timecoltext{% \noexpand\tms@timelabeltype{\the\tms@hours@start}&% \noexpand\tms@timelabeltype{\tms@minutes@start@mac}&% \noexpand\tms@timelabeltype{\the\tms@hours@end}&% \noexpand\tms@timelabeltype{\tms@minutes@end@mac}&}}% % \end{macrocode} % % \textit{Set the dimensions of the table. We don't have % to worry about the vertical dimensions; we leave that % to longtable.} % % \textit{First let the user know what we're planning to do.} % % \begin{macrocode} \message{Package Timesheet: % setting table \the\tms@tablewidth\space in width.^^J}% % \end{macrocode} % % \textit{The rules surrounding the first (time) column.} % % \begin{macrocode} \setlength{\tms@widthlessboxes}{2\arrayrulewidth}% % \end{macrocode} % % \textit{The rules at the end of the text columns.} % % \begin{macrocode} \addtolength{\tms@widthlessboxes}{3\arrayrulewidth}% \addtolength{\tms@widthlessboxes}{\doublerulesep}% % \end{macrocode} % % \textit{The space between the rules and the neighbouring text.} % % \begin{macrocode} \addtolength{\tms@widthlessboxes}{6\tabcolsep}% % \end{macrocode} % % \textit{The width of the time text.} % % \begin{macrocode} \settowidth{\tms@numlen}{\tms@timelabeltype{99}}% \settowidth{\tms@colonlen}{\tms@timelabeltype{:}}% \settowidth{\tms@dashlen}{\tms@timelabeltype{\ --\ }}% \addtolength{\tms@widthlessboxes}{4\tms@numlen}% \addtolength{\tms@widthlessboxes}{2\tms@colonlen}% \addtolength{\tms@widthlessboxes}{\tms@dashlen}% % \end{macrocode} % % \textit{Everything else is for the text columns.} % % \begin{macrocode} \tms@tempcount\tms@leftprop% \advance\tms@tempcount by\tms@rightprop% % \setlength{\tms@templen}{\tms@tablewidth}% \addtolength{\tms@templen}{-\tms@widthlessboxes}% % \tms@leftlen\tms@templen% \divide\tms@leftlen by\tms@tempcount% \global\multiply\tms@leftlen by\tms@leftprop% % \tms@rightlen\tms@templen% \divide\tms@rightlen by\tms@tempcount% \global\multiply\tms@rightlen by\tms@rightprop% % \end{macrocode} % % \textit{Prepare the macro that will generate a table % header with an appropriate number of columns % in appropriate sizes.} % % \begin{macrocode} \tms@tempcount\tms@days% \advance\tms@tempcount by1% \protected@edef\tms@header{% \noexpand\begin{longtable}{% |>{\hfill}% m{\the\tms@numlen}% @{\tms@timelabeltype{:}}% m{\the\tms@numlen}% @{\tms@timelabeltype{\ --\ }}% >{\hfill}% m{\the\tms@numlen}% @{\tms@timelabeltype{:}}% m{\the\tms@numlen}% |% m{\the\tms@leftlen}||% m{\the\tms@rightlen}|}% \noexpand\multicolumn{6}{c}% {\tms@titletype{\noexpand\tms@title}}% \\% \noexpand\multicolumn{4}{l}{}% &% \noexpand\multicolumn{1}{c}{\textbf{Plan}}&% \noexpand\multicolumn{1}{c}{\textbf{Action}}% \noexpand\\\noexpand\hline% \noexpand\endhead% \noexpand\tms@timecoltext}% \extrarowheight=3pt} % \end{macrocode} % % Specify the divider to be placed between entries % within a timesheet box. % % \begin{macrocode} {\par\smallskip}% % \end{macrocode} % % Use the standard Calendar item-fetching macros to % grab classes of items. We only need appointments % (things with a time associated with them) in this case, % and we specify the range of the current box to % limit the entries that are grabbed for current use. % % \begin{macrocode} {\cal@get@appointments[\tms@time@start/\tms@time@end]}% % \end{macrocode} % % Prepare macro text that will set the text to % "\longtext" on the first entry, and "\shorttext" % with braces thereafter. % % \begin{macrocode} {\relax% \ifnum\dates@time@start>0\relax% % \end{macrocode} % % \textit{We print a short entry for anything that starts % outside the slot we are dealing with.} % % \begin{macrocode} \ifnum\dates@time@start<\tms@time@start% \protected@edef\cal@entry@text{% \noexpand\parbox{\the\tms@leftlen}{\noexpand\raggedright% \noexpand\tms@itemtype{% \noexpand$\noexpand<\noexpand$% \theshorttext, to \cal@appt@end@text% \noexpand$\noexpand>\noexpand$}}}% % \end{macrocode} % % \textit{All other conforming entries get the long text.} % % \begin{macrocode} \else% \ifnum\dates@time@start<\dates@time@end% \protected@edef\cal@entry@text{% \noexpand\parbox{\the\tms@leftlen}{\noexpand\raggedright% \iftms@usetimes% \noexpand\tms@timeitemtype{% \cal@appt@start@text% --% \cal@appt@end@text}% \space% \fi% \noexpand\tms@itemtype{% \thelongtext}}}% \else% \protected@edef\cal@entry@text{% \noexpand\parbox{\the\tms@leftlen}{\noexpand\raggedright% \iftms@usetimes% \noexpand\tms@timeitemtype{% \cal@appt@start@text}% \space% \fi% \tms@itemtype{\thelongtext}}}% \fi% \fi% \fi}% % \end{macrocode} % % Chuck the assembled stack of appointments into % the box. % % \begin{macrocode} {\theappointments} \message{Done loading style} % \end{macrocode} % % \Finale \PrintChanges