1 ;;; cal-tex.el --- calendar functions for printing calendars with LaTeX.
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;; Author: Steve Fisk <fisk@bowdoin.edu>
6 ;; Edward M. Reingold <reingold@cs.uiuc.edu>
8 ;; Human-Keywords: Calendar, LaTeX
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
29 ;; This collection of functions implements the creation of LaTeX calendars
30 ;; based on the user's holiday choices and diary file.
34 ;; (*) Add holidays and diary entries to daily calendar.
36 ;; (*) Add diary entries to weekly calendar functions.
38 ;; (*) Make calendar styles for A4 paper.
40 ;; (*) Make daily and monthly styles Filofax paper.
46 (autoload 'list-diary-entries
"diary-lib" nil t
)
47 (autoload 'calendar-holiday-list
"holidays" nil t
)
48 (autoload 'calendar-iso-from-absolute
"cal-iso" nil t
)
51 ;;; Customizable variables
54 (defcustom cal-tex-which-days
'(0 1 2 3 4 5 6)
55 "*The days of the week that are displayed on the portrait monthly calendar.
56 Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to
57 Saturday. For example, use
59 (setq cal-tex-which-days '(1 3 5))
61 to only print Monday, Wednesday, Friday."
62 :type
'(repeat integer
)
65 (defcustom cal-tex-holidays t
66 "*If t (default), then the holidays are also printed.
67 If finding the holidays is too slow, set this to nil."
71 (defcustom cal-tex-diary nil
72 "*If t, the diary entries are printed in the calendar."
76 (defcustom cal-tex-daily-string
77 '(let* ((year (extract-calendar-year date
))
78 (day (calendar-day-number date
))
79 (days-remaining (- (calendar-day-number (list 12 31 year
)) day
)))
80 (format "%d/%d" day days-remaining
))
81 "*An expression in the variable `date' whose value is placed on date.
82 The string resulting from evaluating this expression is placed at the bottom
83 center of `date' on the monthly calendar, next to the date in the weekly
84 calendars, and in the top center of daily calendars.
86 Default is ordinal day number of the year and the number of days remaining.
87 As an example of what you do, setting this to
91 (calendar-hebrew-date-string date))
93 will put the Hebrew date at the bottom of each day."
97 (defcustom cal-tex-buffer
"calendar.tex"
98 "*The name for the tex-ed calendar."
100 :group
'calendar-tex
)
102 (defcustom cal-tex-24 nil
103 "*If t, use a 24 hour clock in the daily calendar."
105 :group
'calendar-tex
)
107 (defcustom cal-tex-daily-start
8
108 "*The first hour of the daily calendar page."
110 :group
'calendar-tex
)
112 (defcustom cal-tex-daily-end
20
113 "*The last hour of the daily calendar page."
115 :group
'calendar-tex
)
118 ;;; Definitions for LaTeX code
121 (defvar cal-tex-day-prefix
"\\caldate{%s}{%s}"
122 "The initial LaTeX code for a day.
123 The holidays, diary entries, bottom string, and the text follow.")
125 (defvar cal-tex-day-name-format
"\\myday{%s}%%"
126 "The format for LaTeX code for a day name. The names are taken from
127 calendar-day-name-array.")
129 (defvar cal-tex-cal-one-month
130 "\\def\\calmonth#1#2%
132 \\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]%
137 "LaTeX code for the month header")
139 (defvar cal-tex-cal-multi-month
140 "\\def\\calmonth#1#2#3#4%
142 \\Huge\\bf #1 #2---#3 #4\\\\[1cm]%
147 "LaTeX code for the month header")
149 (defvar cal-tex-myday
150 "\\renewcommand{\\myday}[1]%
151 {\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}}
154 "LaTeX code for a day heading")
156 (defvar cal-tex-caldate
158 \\long\\def\\caldate#1#2#3#4#5#6{%
159 \\fbox{\\hbox to\\cellwidth{%
160 \\vbox to\\cellheight{%
161 \\hbox to\\cellwidth{%
162 {\\hspace*{1mm}\\Large \\bf \\strut #2}\\hspace{.05\\cellwidth}%
163 \\raisebox{\\holidaymult\\cellheight}%
164 {\\parbox[t]{.75\\cellwidth}{\\tiny \\raggedright #4}}}
165 \\hbox to\\cellwidth{%
166 \\hspace*{1mm}\\parbox{.95\\cellwidth}{\\tiny \\raggedright #3}}
168 \\hbox to\\cellwidth{#6}%
170 \\hbox to\\cellwidth{\\hfill \\tiny #5 \\hfill}%
174 "LaTeX code to insert one box with date info in calendar.
175 This definition is the heart of the calendar!")
177 (defun cal-tex-list-holidays (d1 d2
)
178 "Generate a list of all holidays from absolute date D1 to D2."
180 (start (calendar-gregorian-from-absolute d1
))
181 (start-month (extract-calendar-month start
))
182 (start-year (extract-calendar-year start
)))
183 (increment-calendar-month start-month start-year
1)
184 (let* ((end (calendar-gregorian-from-absolute d2
))
185 (end-month (extract-calendar-month end
))
186 (end-year (extract-calendar-year end
)))
187 (if (= (extract-calendar-day end
) 1)
188 (increment-calendar-month end-month end-year -
1))
189 (let* ((s (calendar-absolute-from-gregorian
190 (list start-month
1 start-year
)))
191 (e (calendar-absolute-from-gregorian
192 (list end-month
1 end-year
)))
195 (displayed-month start-month
)
196 (displayed-year start-year
))
197 (while (or never
(<= d e
))
198 (setq result
(append result
(calendar-holiday-list)))
200 (increment-calendar-month displayed-month displayed-year
3)
201 (setq d
(calendar-absolute-from-gregorian
202 (list displayed-month
1 displayed-year
))))))
207 (let ((a (calendar-absolute-from-gregorian (car (car p
)))))
208 (and (<= d1 a
) (<= a d2
)))
209 (setq in-range
(append (list (car p
)) in-range
)))
213 (defun cal-tex-list-diary-entries (d1 d2
)
214 "Generate a list of all diary-entries from absolute date D1 to D2."
215 (let ((diary-display-hook nil
))
217 (calendar-gregorian-from-absolute d1
)
220 (defun cal-tex-preamble (&optional args
)
221 "Insert the LaTeX preamble.
222 Preamble Includes initial definitions for various LaTeX commands.
223 Optional ARGS are included."
224 (set-buffer (get-buffer-create cal-tex-buffer
))
226 (insert "\\documentstyle")
228 (insert "[" args
"]"))
229 (insert "{article}\n"
236 \\evensidemargin -2cm
241 \\newlength{\\cellwidth}
242 \\newlength{\\cellheight}
243 \\newlength{\\boxwidth}
244 \\newlength{\\boxheight}
245 \\newlength{\\cellsize}
246 \\newcommand{\\myday}[1]{}
247 \\newcommand{\\caldate}[6]{}
248 \\newcommand{\\nocaldate}[6]{}
249 \\newcommand{\\calsmall}[6]{}
257 (defun cal-tex-cursor-year (&optional arg
)
258 "Make a buffer with LaTeX commands for the year cursor is on.
259 Optional prefix argument specifies number of years."
261 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t
))
264 (defun cal-tex-cursor-year-landscape (&optional arg
)
265 "Make a buffer with LaTeX commands for the year cursor is on.
266 Optional prefix argument specifies number of years."
268 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t
))
272 (defun cal-tex-year (year n
&optional landscape
)
273 "Make a one page yearly calendar of YEAR; do this for N years.
274 There are four rows of three months each, unless optional LANDSCAPE is t,
275 in which case the calendar isprinted in landscape mode with three rows of
277 (cal-tex-insert-preamble 1 landscape
"12pt")
279 (cal-tex-vspace "-.6cm")
280 (cal-tex-vspace "-3.1cm"))
281 (calendar-for-loop j from
1 to n do
282 (insert "\\vfill%\n")
284 (cal-tex-Huge (number-to-string year
))
286 (cal-tex-vspace "1cm")
288 (cal-tex-b-parbox "l" (if landscape
"5.9in" "4.3in"))
292 (calendar-for-loop i from
1 to
12 do
293 (insert (cal-tex-mini-calendar i year
"month" "1.1in" "1in"))
295 (cal-tex-hspace "0.5in")
296 (if (zerop (mod i
(if landscape
4 3)))
297 (cal-tex-nl "0.5in")))
300 (insert "\\vfill%\n")
301 (setq year
(1+ year
))
304 (cal-tex-end-document))
305 (run-hooks 'cal-tex-year-hook
))
306 (run-hooks 'cal-tex-hook
))
308 (defun cal-tex-cursor-filofax-year (&optional arg
)
309 "Make a Filofax one page yearly calendar of year indicated by cursor.
310 Optional parameter specifies number of years."
312 (let* ((n (if arg arg
1))
313 (year (extract-calendar-year (calendar-cursor-to-date t
))))
314 (cal-tex-preamble "twoside")
315 (cal-tex-cmd "\\textwidth 3.25in")
316 (cal-tex-cmd "\\textheight 6.5in")
317 (cal-tex-cmd "\\oddsidemargin 1.675in")
318 (cal-tex-cmd "\\evensidemargin 1.675in")
319 (cal-tex-cmd "\\topmargin 0pt")
320 (cal-tex-cmd "\\headheight -0.875in")
321 (cal-tex-cmd "\\fboxsep 0.5mm")
322 (cal-tex-cmd "\\pagestyle{empty}")
324 (cal-tex-cmd "\\vspace*{0.25in}")
325 (calendar-for-loop j from
1 to n do
326 (insert (format "\\hfil {\\Large \\bf %s} \\hfil\\\\\n" year
))
328 (cal-tex-b-parbox "l" "\\textwidth")
332 (calendar-for-loop i from
1 to
12 do
333 (insert (cal-tex-mini-calendar i year
334 (calendar-month-name i
)
335 "1in" ".9in" "tiny" "0.6mm")))
337 "\\noindent\\fbox{\\January}\\fbox{\\February}\\fbox{\\March}\\\\
338 \\noindent\\fbox{\\April}\\fbox{\\May}\\fbox{\\June}\\\\
339 \\noindent\\fbox{\\July}\\fbox{\\August}\\fbox{\\September}\\\\
340 \\noindent\\fbox{\\October}\\fbox{\\November}\\fbox{\\December}
344 (setq year
(1+ year
))
346 (cal-tex-end-document)
348 (cal-tex-cmd "\\vspace*{0.25in}"))
349 (run-hooks 'cal-tex-year-hook
))
350 (run-hooks 'cal-tex-hook
)))
353 ;;; Monthly calendars
356 (defun cal-tex-cursor-month-landscape (&optional arg
)
357 "Make a buffer with LaTeX commands for the month cursor is on.
358 Optional prefix argument specifies number of months to be produced.
359 The output is in landscape format, one month to a page."
361 (let* ((n (if arg arg
1))
362 (date (calendar-cursor-to-date t
))
363 (month (extract-calendar-month date
))
364 (year (extract-calendar-year date
))
367 (cal-tex-which-days '(0 1 2 3 4 5 6)))
368 (increment-calendar-month end-month end-year
(1- n
))
369 (let ((diary-list (if cal-tex-diary
370 (cal-tex-list-diary-entries
371 (calendar-absolute-from-gregorian
373 (calendar-absolute-from-gregorian
375 (calendar-last-day-of-month
378 (holidays (if cal-tex-holidays
379 (cal-tex-list-holidays
380 (calendar-absolute-from-gregorian
382 (calendar-absolute-from-gregorian
384 (calendar-last-day-of-month end-month end-year
)
388 (small-months-at-start))
389 (cal-tex-insert-preamble (cal-tex-number-weeks month year
1) t
"12pt")
390 (cal-tex-cmd cal-tex-cal-one-month
)
391 (calendar-for-loop i from
1 to n do
392 (setq other-month month
)
393 (setq other-year year
)
394 (increment-calendar-month other-month other-year -
1)
395 (insert (cal-tex-mini-calendar other-month other-year
"lastmonth"
396 "\\cellwidth" "\\cellheight"))
397 (increment-calendar-month other-month other-year
2)
398 (insert (cal-tex-mini-calendar other-month other-year
"nextmonth"
399 "\\cellwidth" "\\cellheight"))
400 (cal-tex-insert-month-header 1 month year month year
)
401 (cal-tex-insert-day-names)
403 (setq small-months-at-start
404 (< 1 (mod (- (calendar-day-of-week (list month
1 year
))
405 calendar-week-start-day
)
407 (if small-months-at-start
408 (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}"))
409 (cal-tex-insert-blank-days month year cal-tex-day-prefix
)
410 (cal-tex-insert-days month year diary-list holidays
412 (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix
)
413 (if (and (not small-months-at-start
)
414 (< 1 (mod (- (1- calendar-week-start-day
)
415 (calendar-day-of-week
417 (calendar-last-day-of-month month year
)
420 (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}"
421 "\\lastmonth\\nextmonth"))
424 (run-hooks 'cal-tex-month-hook
)
426 (increment-calendar-month month year
1)
427 (cal-tex-vspace "-2cm")
428 (cal-tex-insert-preamble
429 (cal-tex-number-weeks month year
1) t
"12pt" t
))))
430 (cal-tex-end-document)
431 (run-hooks 'cal-tex-hook
))))
433 (defun cal-tex-cursor-month (arg)
434 "Make a buffer with LaTeX commands for the month cursor is on.
435 Optional prefix argument specifies number of months to be produced.
436 Calendar is condensed onto one page."
438 (let* ((date (calendar-cursor-to-date t
))
439 (month (extract-calendar-month date
))
440 (year (extract-calendar-year date
))
444 (increment-calendar-month end-month end-year
(1- n
))
445 (let ((diary-list (if cal-tex-diary
446 (cal-tex-list-diary-entries
447 (calendar-absolute-from-gregorian
449 (calendar-absolute-from-gregorian
451 (calendar-last-day-of-month
454 (holidays (if cal-tex-holidays
455 (cal-tex-list-holidays
456 (calendar-absolute-from-gregorian
458 (calendar-absolute-from-gregorian
460 (calendar-last-day-of-month end-month end-year
)
464 (cal-tex-insert-preamble (cal-tex-number-weeks month year n
) nil
"12pt")
466 (cal-tex-cmd cal-tex-cal-multi-month
)
467 (cal-tex-cmd cal-tex-cal-one-month
))
468 (cal-tex-insert-month-header n month year end-month end-year
)
469 (cal-tex-insert-day-names)
471 (cal-tex-insert-blank-days month year cal-tex-day-prefix
)
472 (calendar-for-loop i from
1 to n do
473 (setq other-month month
)
474 (setq other-year year
)
475 (cal-tex-insert-days month year diary-list holidays
477 (increment-calendar-month month year
1))
478 (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix
)
479 (cal-tex-end-document)))
480 (run-hooks 'cal-tex-hook
))
482 (defun cal-tex-insert-days (month year diary-list holidays day-format
)
483 "Insert LaTeX commands for a range of days in monthly calendars.
484 LaTeX commands are inserted for the days of the MONTH in YEAR.
485 Diary entries on DIARY-LIST are included. Holidays on HOLIDAYS are included.
486 Each day is formatted using format DAY-FORMAT."
487 (let* ((blank-days;; at start of month
489 (- (calendar-day-of-week (list month
1 year
))
490 calendar-week-start-day
)
493 (last (calendar-last-day-of-month month year
)))
494 (calendar-for-loop i from
1 to last do
495 (setq date
(list month i year
))
496 (if (memq (calendar-day-of-week date
) cal-tex-which-days
)
498 (insert (format day-format
(calendar-month-name month
) i
))
499 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
500 (cal-tex-arg (cal-tex-latexify-list holidays date
))
501 (cal-tex-arg (eval cal-tex-daily-string
))
504 (if (and (zerop (mod (+ i blank-days
) 7))
510 (defun cal-tex-insert-day-names ()
511 "Insert the names of the days at top of a monthly calendar."
512 (calendar-for-loop i from
0 to
6 do
513 (if (memq i cal-tex-which-days
)
514 (insert (format cal-tex-day-name-format
515 (aref calendar-day-name-array
516 (mod (+ calendar-week-start-day i
) 7)))))
519 (defun cal-tex-insert-month-header (n month year end-month end-year
)
520 "Create a title for a calendar.
521 A title is inserted for a calendar with N months starting with
522 MONTH YEAR and ending with END-MONTH END-YEAR."
523 (let ( (month-name (calendar-month-name month
))
524 (end-month-name (calendar-month-name end-month
)))
526 (insert (format "\\calmonth{%s}{%s}\n\\vspace*{-0.5cm}"
528 (insert (format "\\calmonth{%s}{%s}{%s}{%s}\n\\vspace*{-0.5cm}"
529 month-name year end-month-name end-year
))))
532 (defun cal-tex-insert-blank-days (month year day-format
)
533 "Insert code for initial days not in calendar.
534 Insert LaTeX code for the blank days at the beginning of the MONTH in
535 YEAR. The entry is formatted using DAY-FORMAT. If the entire week is
536 blank, no days are inserted."
537 (if (cal-tex-first-blank-p month year
)
538 (let* ((blank-days;; at start of month
540 (- (calendar-day-of-week (list month
1 year
))
541 calendar-week-start-day
)
543 (calendar-for-loop i from
0 to
(1- blank-days
) do
544 (if (memq i cal-tex-which-days
)
545 (insert (format day-format
" " " ") "{}{}{}{}%\n"))))))
547 (defun cal-tex-insert-blank-days-at-end (month year day-format
)
548 "Insert code for final days not in calendar.
549 Insert LaTeX code for the blank days at the end of the MONTH in YEAR.
550 The entry is formatted using DAY-FORMAT."
551 (if (cal-tex-last-blank-p month year
)
552 (let* ((last-day (calendar-last-day-of-month month year
))
553 (blank-days;; at end of month
555 (- (calendar-day-of-week (list month last-day year
))
556 calendar-week-start-day
)
558 (calendar-for-loop i from
(1+ blank-days
) to
6 do
559 (if (memq i cal-tex-which-days
)
560 (insert (format day-format
"" "") "{}{}{}{}%\n"))))))
562 (defun cal-tex-first-blank-p (month year
)
563 "Determine if any days of the first week will be printed.
564 Return t if there will there be any days of the first week printed
565 in the calendar starting in MONTH YEAR."
567 (the-saturday)) ;the day of week of 1st Saturday
568 (calendar-for-loop i from
1 to
7 do
569 (if (= 6 (calendar-day-of-week (list month i year
)))
570 (setq the-saturday i
)))
571 (calendar-for-loop i from
1 to the-saturday do
572 (if (memq (calendar-day-of-week (list month i year
))
577 (defun cal-tex-last-blank-p (month year
)
578 "Determine if any days of the last week will be printed.
579 Return t if there will there be any days of the last week printed
580 in the calendar starting in MONTH YEAR."
582 (last-day (calendar-last-day-of-month month year
))
583 (the-sunday)) ;the day of week of last Sunday
584 (calendar-for-loop i from
(- last-day
6) to last-day do
585 (if (= 0 (calendar-day-of-week (list month i year
)))
586 (setq the-sunday i
)))
587 (calendar-for-loop i from the-sunday to last-day do
588 (if (memq (calendar-day-of-week (list month i year
))
593 (defun cal-tex-number-weeks (month year n
)
594 "Determine the number of weeks in a range of dates.
595 Compute the number of weeks in the calendar starting with MONTH and YEAR,
596 and lasting N months, including only the days in WHICH-DAYS. As it stands,
597 this is only an upper bound."
598 (let ((d (list month
1 year
)))
599 (increment-calendar-month month year
(1- n
))
600 (/ (- (calendar-dayname-on-or-before
601 calendar-week-start-day
602 (+ 7 (calendar-absolute-from-gregorian
603 (list month
(calendar-last-day-of-month month year
) year
))))
604 (calendar-dayname-on-or-before
605 calendar-week-start-day
606 (calendar-absolute-from-gregorian d
)))
613 (defun cal-tex-cursor-week (&optional arg
)
614 "Make a buffer with LaTeX commands for a two-page one-week calendar.
615 It applies to the week that point is in.
616 Optional prefix argument specifies number of weeks.
617 Holidays are included if `cal-tex-holidays' is t."
619 (let* ((n (if arg arg
1))
620 (date (calendar-gregorian-from-absolute
621 (calendar-dayname-on-or-before
622 calendar-week-start-day
623 (calendar-absolute-from-gregorian
624 (calendar-cursor-to-date t
)))))
625 (month (extract-calendar-month date
))
626 (year (extract-calendar-year date
))
627 (holidays (if cal-tex-holidays
628 (cal-tex-list-holidays
629 (calendar-absolute-from-gregorian date
)
631 (calendar-absolute-from-gregorian date
))))))
632 (cal-tex-preamble "11pt")
633 (cal-tex-cmd "\\textwidth 6.5in")
634 (cal-tex-cmd "\\textheight 10.5in")
635 (cal-tex-cmd "\\oddsidemargin 0in")
636 (cal-tex-cmd "\\evensidemargin 0in")
637 (insert cal-tex-LaTeX-hourbox
)
639 (cal-tex-cmd "\\pagestyle{empty}")
640 (calendar-for-loop i from
1 to n do
641 (cal-tex-vspace "-1.5in")
643 (cal-tex-Huge-bf (format "\\uppercase{%s}"
644 (calendar-month-name month
)))
645 (cal-tex-hspace "2em")
646 (cal-tex-Huge-bf (number-to-string year
))
649 (cal-tex-hspace "-.2in")
650 (cal-tex-b-parbox "l" "7in")
651 (calendar-for-loop j from
1 to
7 do
652 (cal-tex-week-hours date holidays
"3.1")
653 (setq date
(cal-tex-incr-date date
)))
655 (setq month
(extract-calendar-month date
))
656 (setq year
(extract-calendar-year date
))
659 (run-hooks 'cal-tex-week-hook
)
661 (cal-tex-end-document)
662 (run-hooks 'cal-tex-hook
)))
664 (defun cal-tex-cursor-week2 (&optional arg
)
665 "Make a buffer with LaTeX commands for a two-page one-week calendar.
666 It applies to the week that point is in.
667 Optional prefix argument specifies number of weeks.
668 Holidays are included if `cal-tex-holidays' is t."
670 (let* ((n (if arg arg
1))
671 (date (calendar-gregorian-from-absolute
672 (calendar-dayname-on-or-before
673 calendar-week-start-day
674 (calendar-absolute-from-gregorian
675 (calendar-cursor-to-date t
)))))
676 (month (extract-calendar-month date
))
677 (year (extract-calendar-year date
))
679 (holidays (if cal-tex-holidays
680 (cal-tex-list-holidays
681 (calendar-absolute-from-gregorian date
)
683 (calendar-absolute-from-gregorian date
))))))
684 (cal-tex-preamble "12pt")
685 (cal-tex-cmd "\\textwidth 6.5in")
686 (cal-tex-cmd "\\textheight 10.5in")
687 (cal-tex-cmd "\\oddsidemargin 0in")
688 (cal-tex-cmd "\\evensidemargin 0in")
689 (insert cal-tex-LaTeX-hourbox
)
691 (cal-tex-cmd "\\pagestyle{empty}")
692 (calendar-for-loop i from
1 to n do
693 (cal-tex-vspace "-1.5in")
695 (cal-tex-Huge-bf (format "\\uppercase{%s}"
696 (calendar-month-name month
)))
697 (cal-tex-hspace "2em")
698 (cal-tex-Huge-bf (number-to-string year
))
701 (cal-tex-hspace "-.2in")
702 (cal-tex-b-parbox "l" "\\textwidth")
703 (calendar-for-loop j from
1 to
3 do
704 (cal-tex-week-hours date holidays
"5")
705 (setq date
(cal-tex-incr-date date
)))
708 (insert (cal-tex-mini-calendar
709 (extract-calendar-month (cal-tex-previous-month date
))
710 (extract-calendar-year (cal-tex-previous-month date
))
711 "lastmonth" "1.1in" "1in"))
712 (insert (cal-tex-mini-calendar
713 (extract-calendar-month date
)
714 (extract-calendar-year date
)
715 "thismonth" "1.1in" "1in"))
716 (insert (cal-tex-mini-calendar
717 (extract-calendar-month (cal-tex-next-month date
))
718 (extract-calendar-year (cal-tex-next-month date
))
719 "nextmonth" "1.1in" "1in"))
720 (insert "\\hbox to \\textwidth{")
722 (insert "\\lastmonth")
724 (insert "\\thismonth")
726 (insert "\\nextmonth")
730 (cal-tex-b-parbox "l" "\\textwidth")
731 (calendar-for-loop j from
4 to
7 do
732 (cal-tex-week-hours date holidays
"5")
733 (setq date
(cal-tex-incr-date date
)))
735 (setq month
(extract-calendar-month date
))
736 (setq year
(extract-calendar-year date
))
739 (run-hooks 'cal-tex-week-hook
)
741 (cal-tex-end-document)
742 (run-hooks 'cal-tex-hook
)))
744 (defun cal-tex-cursor-week-iso (&optional arg
)
745 "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar.
746 Optional prefix argument specifies number of weeks.
747 Diary entries are included if `cal-tex-diary' is t.
748 Holidays are included if `cal-tex-holidays' is t."
750 (let* ((n (if arg arg
1))
751 (date (calendar-gregorian-from-absolute
752 (calendar-dayname-on-or-before
754 (calendar-absolute-from-gregorian
755 (calendar-cursor-to-date t
)))))
756 (month (extract-calendar-month date
))
757 (year (extract-calendar-year date
))
758 (day (extract-calendar-day date
))
759 (holidays (if cal-tex-holidays
760 (cal-tex-list-holidays
761 (calendar-absolute-from-gregorian date
)
763 (calendar-absolute-from-gregorian date
)))))
764 (diary-list (if cal-tex-diary
765 (cal-tex-list-diary-entries
766 (calendar-absolute-from-gregorian
769 (calendar-absolute-from-gregorian date
))))))
770 (cal-tex-preamble "11pt")
771 (cal-tex-cmd "\\textwidth 6.5in")
772 (cal-tex-cmd "\\textheight 10.5in")
773 (cal-tex-cmd "\\oddsidemargin 0in")
774 (cal-tex-cmd "\\evensidemargin 0in")
776 (cal-tex-cmd "\\pagestyle{empty}")
777 (calendar-for-loop i from
1 to n do
778 (cal-tex-vspace "-1.5in")
781 (let* ((d (calendar-iso-from-absolute
782 (calendar-absolute-from-gregorian date
))))
783 (format "Week %d of %d"
784 (extract-calendar-month d
)
785 (extract-calendar-year d
))))
788 (cal-tex-b-parbox "l" "\\textwidth")
789 (calendar-for-loop j from
1 to
7 do
790 (cal-tex-b-parbox "t" "\\textwidth")
791 (cal-tex-b-parbox "t" "\\textwidth")
792 (cal-tex-rule "0pt" "\\textwidth" ".2mm")
794 (cal-tex-b-parbox "t" "\\textwidth")
795 (cal-tex-large-bf (calendar-day-name date
))
797 (cal-tex-large-bf (calendar-month-name month
))
799 (cal-tex-large-bf (number-to-string day
))
800 (if (not (string= "" (cal-tex-latexify-list holidays date
)))
803 (cal-tex-large-bf (cal-tex-latexify-list holidays date
"; "))))
805 (insert " " (eval cal-tex-daily-string
))
809 (cal-tex-b-parbox "t" "\\textwidth")
810 (if (not (string= "" (cal-tex-latexify-list diary-list date
)))
812 (insert "\\vbox to 0pt{")
814 (cal-tex-latexify-list diary-list date
))
818 (setq date
(cal-tex-incr-date date
))
819 (setq month
(extract-calendar-month date
))
820 (setq day
(extract-calendar-day date
))
822 (cal-tex-e-parbox "2cm")
824 (setq month
(extract-calendar-month date
))
825 (setq year
(extract-calendar-year date
)))
829 (run-hooks 'cal-tex-week-hook
)
831 (cal-tex-end-document)
832 (run-hooks 'cal-tex-hook
)))
834 (defvar cal-tex-LaTeX-hourbox
835 "\\newcommand{\\hourbox}[2]%
836 {\\makebox[2em]{\\rule{0cm}{#2ex}#1}\\rule{3in}{.15mm}}\n"
837 "One hour and a line on the right.")
839 (defun cal-tex-week-hours (date holidays height
)
840 "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT."
841 (let ((month (extract-calendar-month date
))
842 (day (extract-calendar-day date
))
843 (year (extract-calendar-year date
))
845 (cal-tex-comment "begin cal-tex-week-hours")
846 (cal-tex-cmd "\\ \\\\[-.2cm]")
847 (cal-tex-cmd "\\noindent")
848 (cal-tex-b-parbox "l" "6.8in")
849 (cal-tex-large-bf (calendar-day-name date
))
851 (cal-tex-large-bf (calendar-month-name month
))
853 (cal-tex-large-bf (number-to-string day
))
854 (if (not (string= "" (cal-tex-latexify-list holidays date
)))
857 (cal-tex-large-bf (cal-tex-latexify-list holidays date
"; "))))
859 (insert " " (eval cal-tex-daily-string
))
862 (cal-tex-rule "0pt" "6.8in" ".2mm")
864 (calendar-for-loop i from
8 to
12 do
866 (setq afternoon
(+ i
5))
867 (setq afternoon
(- i
7)))
868 (cal-tex-cmd "\\hourbox" (number-to-string i
))
870 (cal-tex-hspace ".4cm")
871 (cal-tex-cmd "\\hourbox" (number-to-string afternoon
))
875 (defun cal-tex-cursor-week-monday (&optional arg
)
876 "Make a buffer with LaTeX commands for a two-page one-week calendar.
877 It applies to the week that point is in, and starts on Monday.
878 Optional prefix argument specifies number of weeks.
879 Holidays are included if `cal-tex-holidays' is t."
881 (let* ((n (if arg arg
1))
882 (date (calendar-gregorian-from-absolute
883 (calendar-dayname-on-or-before
885 (calendar-absolute-from-gregorian
886 (calendar-cursor-to-date t
))))))
887 (cal-tex-preamble "11pt")
888 (cal-tex-cmd "\\textwidth 6.5in")
889 (cal-tex-cmd "\\textheight 10.5in")
890 (cal-tex-cmd "\\oddsidemargin 0in")
891 (cal-tex-cmd "\\evensidemargin 0in")
893 (calendar-for-loop i from
1 to n do
894 (cal-tex-vspace "-1cm")
895 (insert "\\noindent ")
896 (cal-tex-weekly4-box (cal-tex-incr-date date
) nil
)
897 (cal-tex-weekly4-box (cal-tex-incr-date date
4) nil
)
899 (cal-tex-weekly4-box (cal-tex-incr-date date
2) nil
)
900 (cal-tex-weekly4-box (cal-tex-incr-date date
5) nil
)
902 (cal-tex-weekly4-box (cal-tex-incr-date date
3) nil
)
903 (cal-tex-weekly4-box (cal-tex-incr-date date
6) t
)
906 (run-hooks 'cal-tex-week-hook
)
907 (setq date
(cal-tex-incr-date date
7))
909 (cal-tex-end-document)
910 (run-hooks 'cal-tex-hook
)))
912 (defun cal-tex-weekly4-box (date weekend
)
913 "Make one box for DATE, different if WEEKEND."
915 (day (extract-calendar-day date
))
916 (month (extract-calendar-month date
))
917 (year (extract-calendar-year date
))
918 (dayname (calendar-day-name date
))
919 (date1 (cal-tex-incr-date date
))
920 (day1 (extract-calendar-day date1
))
921 (month1 (extract-calendar-month date1
))
922 (year1 (extract-calendar-year date1
))
923 (dayname1 (calendar-day-name date1
))
925 (cal-tex-b-framebox "8cm" "l")
926 (cal-tex-b-parbox "b" "7.5cm")
927 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year
))
928 (cal-tex-rule "0pt" "7.5cm" ".5mm")
932 (calendar-for-loop i from
8 to
12 do
933 (insert (format "{\\large\\sf %d}\\\\\n" i
)))
934 (calendar-for-loop i from
1 to
5 do
935 (insert (format "{\\large\\sf %d}\\\\\n" i
)))))
939 (cal-tex-vspace "1cm")
940 (insert "\\ \\vfill")
941 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n"
942 dayname1 month1 day1 year1
))
943 (cal-tex-rule "0pt" "7.5cm" ".5mm")
945 (cal-tex-vspace "1cm")))
948 (cal-tex-hspace "1cm")))
950 (defun cal-tex-cursor-filofax-2week (&optional arg
)
951 "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor.
952 Optional prefix argument specifies number of weeks.
953 Diary entries are included if `cal-tex-diary' is t.
954 Holidays are included if `cal-tex-holidays' is t."
956 (let* ((n (if arg arg
1))
957 (date (calendar-gregorian-from-absolute
958 (calendar-dayname-on-or-before
959 calendar-week-start-day
960 (calendar-absolute-from-gregorian
961 (calendar-cursor-to-date t
)))))
962 (month (extract-calendar-month date
))
963 (year (extract-calendar-year date
))
964 (day (extract-calendar-day date
))
965 (holidays (if cal-tex-holidays
966 (cal-tex-list-holidays
967 (calendar-absolute-from-gregorian date
)
969 (calendar-absolute-from-gregorian date
)))))
970 (diary-list (if cal-tex-diary
971 (cal-tex-list-diary-entries
972 (calendar-absolute-from-gregorian
975 (calendar-absolute-from-gregorian date
))))))
976 (cal-tex-preamble "twoside")
977 (cal-tex-cmd "\\textwidth 3.25in")
978 (cal-tex-cmd "\\textheight 6.5in")
979 (cal-tex-cmd "\\oddsidemargin 1.75in")
980 (cal-tex-cmd "\\evensidemargin 1.5in")
981 (cal-tex-cmd "\\topmargin 0pt")
982 (cal-tex-cmd "\\headheight -0.875in")
983 (cal-tex-cmd "\\headsep 0.125in")
984 (cal-tex-cmd "\\footskip .125in")
985 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
986 \\long\\def\\rightday#1#2#3#4#5{%
987 \\rule{\\textwidth}{0.3pt}\\\\%
988 \\hbox to \\textwidth{%
991 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
992 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
993 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
994 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
995 \\long\\def\\leftday#1#2#3#4#5{%
996 \\rule{\\textwidth}{0.3pt}\\\\%
997 \\hbox to \\textwidth{%
1000 \\hbox to \\textwidth{\\noindent {\\normalsize \\bf #2} \\small #1 \\hfill #5}%
1001 \\hbox to \\textwidth{\\vbox {\\noindent \\footnotesize \\em #4}}%
1002 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1004 (cal-tex-b-document)
1005 (cal-tex-cmd "\\pagestyle{empty}")
1006 (calendar-for-loop i from
1 to n do
1008 (insert "\\righthead")
1009 (insert "\\lefthead"))
1011 (let ((d (cal-tex-incr-date date
6)))
1012 (if (= (extract-calendar-month date
)
1013 (extract-calendar-month d
))
1015 (calendar-month-name
1016 (extract-calendar-month date
))
1017 (extract-calendar-year date
))
1018 (if (= (extract-calendar-year date
)
1019 (extract-calendar-year d
))
1020 (format "%s---%s %s"
1021 (calendar-month-name
1022 (extract-calendar-month date
))
1023 (calendar-month-name
1024 (extract-calendar-month d
))
1025 (extract-calendar-year date
))
1026 (format "%s %s---%s %s"
1027 (calendar-month-name
1028 (extract-calendar-month date
))
1029 (extract-calendar-year date
)
1030 (calendar-month-name (extract-calendar-month d
))
1031 (extract-calendar-year d
))))))
1033 (calendar-for-loop j from
1 to
7 do
1035 (insert "\\rightday")
1036 (insert "\\leftday"))
1037 (cal-tex-arg (calendar-day-name date
))
1038 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1039 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1040 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1041 (cal-tex-arg (eval cal-tex-daily-string
))
1043 (setq date
(cal-tex-incr-date date
)))
1046 (run-hooks 'cal-tex-week-hook
)
1047 (cal-tex-newpage))))
1048 (cal-tex-end-document)
1049 (run-hooks 'cal-tex-hook
)))
1051 (defun cal-tex-cursor-filofax-week (&optional arg
)
1052 "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
1053 Optional prefix argument specifies number of weeks.
1054 Weeks start on Monday.
1055 Diary entries are included if `cal-tex-diary' is t.
1056 Holidays are included if `cal-tex-holidays' is t."
1058 (let* ((n (if arg arg
1))
1059 (date (calendar-gregorian-from-absolute
1060 (calendar-dayname-on-or-before
1062 (calendar-absolute-from-gregorian
1063 (calendar-cursor-to-date t
)))))
1064 (month (extract-calendar-month date
))
1065 (year (extract-calendar-year date
))
1066 (day (extract-calendar-day date
))
1067 (holidays (if cal-tex-holidays
1068 (cal-tex-list-holidays
1069 (calendar-absolute-from-gregorian date
)
1071 (calendar-absolute-from-gregorian date
)))))
1072 (diary-list (if cal-tex-diary
1073 (cal-tex-list-diary-entries
1074 (calendar-absolute-from-gregorian
1075 (list month
1 year
))
1077 (calendar-absolute-from-gregorian date
))))))
1078 (cal-tex-preamble "twoside")
1079 (cal-tex-cmd "\\textwidth 3.25in")
1080 (cal-tex-cmd "\\textheight 6.5in")
1081 (cal-tex-cmd "\\oddsidemargin 1.75in")
1082 (cal-tex-cmd "\\evensidemargin 1.5in")
1083 (cal-tex-cmd "\\topmargin 0pt")
1084 (cal-tex-cmd "\\headheight -0.875in")
1085 (cal-tex-cmd "\\headsep 0.125in")
1086 (cal-tex-cmd "\\footskip .125in")
1087 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
1088 \\long\\def\\rightday#1#2#3#4#5{%
1089 \\rule{\\textwidth}{0.3pt}\\\\%
1090 \\hbox to \\textwidth{%
1093 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
1094 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
1095 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1096 \\long\\def\\weekend#1#2#3#4#5{%
1097 \\rule{\\textwidth}{0.3pt}\\\\%
1098 \\hbox to \\textwidth{%
1101 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
1102 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
1103 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1104 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
1105 \\long\\def\\leftday#1#2#3#4#5{%
1106 \\rule{\\textwidth}{0.3pt}\\\\%
1107 \\hbox to \\textwidth{%
1110 \\hbox to \\textwidth{\\noindent {\\normalsize \\bf #2} \\small #1 \\hfill #5}%
1111 \\hbox to \\textwidth{\\vbox {\\noindent \\footnotesize \\em #4}}%
1112 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1114 (cal-tex-b-document)
1115 (cal-tex-cmd "\\pagestyle{empty}\\ ")
1117 (calendar-for-loop i from
1 to n do
1118 (insert "\\lefthead")
1120 (let ((d (cal-tex-incr-date date
2)))
1121 (if (= (extract-calendar-month date
)
1122 (extract-calendar-month d
))
1124 (calendar-month-name
1125 (extract-calendar-month date
))
1126 (extract-calendar-year date
))
1127 (if (= (extract-calendar-year date
)
1128 (extract-calendar-year d
))
1129 (format "%s---%s %s"
1130 (calendar-month-name
1131 (extract-calendar-month date
))
1132 (calendar-month-name
1133 (extract-calendar-month d
))
1134 (extract-calendar-year date
))
1135 (format "%s %s---%s %s"
1136 (calendar-month-name
1137 (extract-calendar-month date
))
1138 (extract-calendar-year date
)
1139 (calendar-month-name (extract-calendar-month d
))
1140 (extract-calendar-year d
))))))
1142 (calendar-for-loop j from
1 to
3 do
1143 (insert "\\leftday")
1144 (cal-tex-arg (calendar-day-name date
))
1145 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1146 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1147 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1148 (cal-tex-arg (eval cal-tex-daily-string
))
1150 (setq date
(cal-tex-incr-date date
)))
1151 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")
1153 (insert "\\righthead")
1155 (let ((d (cal-tex-incr-date date
3)))
1156 (if (= (extract-calendar-month date
)
1157 (extract-calendar-month d
))
1159 (calendar-month-name
1160 (extract-calendar-month date
))
1161 (extract-calendar-year date
))
1162 (if (= (extract-calendar-year date
)
1163 (extract-calendar-year d
))
1164 (format "%s---%s %s"
1165 (calendar-month-name
1166 (extract-calendar-month date
))
1167 (calendar-month-name
1168 (extract-calendar-month d
))
1169 (extract-calendar-year date
))
1170 (format "%s %s---%s %s"
1171 (calendar-month-name
1172 (extract-calendar-month date
))
1173 (extract-calendar-year date
)
1174 (calendar-month-name (extract-calendar-month d
))
1175 (extract-calendar-year d
))))))
1177 (calendar-for-loop j from
1 to
2 do
1178 (insert "\\rightday")
1179 (cal-tex-arg (calendar-day-name date
))
1180 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1181 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1182 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1183 (cal-tex-arg (eval cal-tex-daily-string
))
1185 (setq date
(cal-tex-incr-date date
)))
1186 (calendar-for-loop j from
1 to
2 do
1187 (insert "\\weekend")
1188 (cal-tex-arg (calendar-day-name date
))
1189 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1190 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1191 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1192 (cal-tex-arg (eval cal-tex-daily-string
))
1194 (setq date
(cal-tex-incr-date date
)))
1197 (run-hooks 'cal-tex-week-hook
)
1198 (cal-tex-newpage))))
1199 (cal-tex-end-document)
1200 (run-hooks 'cal-tex-hook
)))
1205 (defun cal-tex-cursor-day (&optional arg
)
1206 "Make a buffer with LaTeX commands for the day cursor is on.
1207 Optional prefix argument specifies number of days."
1209 (let ((n (if arg arg
1))
1210 (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t
))))
1211 (cal-tex-preamble "12pt")
1212 (cal-tex-cmd "\\textwidth 6.5in")
1213 (cal-tex-cmd "\\textheight 10.5in")
1214 (cal-tex-b-document)
1215 (cal-tex-cmd "\\pagestyle{empty}")
1216 (calendar-for-loop i from
1 to n do
1217 (cal-tex-vspace "-1.7in")
1218 (cal-tex-daily-page (calendar-gregorian-from-absolute date
))
1219 (setq date
(1+ date
))
1223 (run-hooks 'cal-tex-daily-hook
))))
1224 (cal-tex-end-document)
1225 (run-hooks 'cal-tex-hook
)))
1227 (defun cal-tex-daily-page (date)
1228 "Make a calendar page for Gregorian DATE on 8.5 by 11 paper."
1230 (month-name (calendar-month-name (extract-calendar-month date
))))
1231 (cal-tex-banner "cal-tex-daily-page")
1232 (cal-tex-b-makebox "4cm" "l")
1233 (cal-tex-b-parbox "b" "3.8cm")
1234 (cal-tex-rule "0mm" "0mm" "2cm")
1235 (cal-tex-Huge (number-to-string (extract-calendar-day date
)))
1237 (cal-tex-bf month-name
)
1239 (cal-tex-hspace "1cm")
1240 (cal-tex-scriptsize (eval cal-tex-daily-string
))
1241 (cal-tex-hspace "3.5cm")
1244 (cal-tex-b-makebox "4cm" "r")
1245 (cal-tex-bf (calendar-day-name date
))
1248 (cal-tex-hspace ".4cm")
1249 (cal-tex-rule "0mm" "16.1cm" "1mm")
1251 (calendar-for-loop i from cal-tex-daily-start to cal-tex-daily-end do
1252 (cal-tex-cmd "\\noindent")
1253 (setq hour
(if cal-tex-24
1256 (if (= 0 hour
) (setq hour
12))
1257 (cal-tex-b-makebox "1cm" "c")
1258 (cal-tex-arg (number-to-string hour
))
1260 (cal-tex-rule "0mm" "15.5cm" ".2mm")
1262 (cal-tex-b-makebox "1cm" "c")
1263 (cal-tex-arg "$\\diamond$" )
1265 (cal-tex-rule "0mm" "15.5cm" ".2mm")
1266 (cal-tex-nl ".2cm"))
1268 (insert (cal-tex-mini-calendar
1269 (extract-calendar-month (cal-tex-previous-month date
))
1270 (extract-calendar-year (cal-tex-previous-month date
))
1271 "lastmonth" "1.1in" "1in"))
1272 (insert (cal-tex-mini-calendar
1273 (extract-calendar-month date
)
1274 (extract-calendar-year date
)
1275 "thismonth" "1.1in" "1in"))
1276 (insert (cal-tex-mini-calendar
1277 (extract-calendar-month (cal-tex-next-month date
))
1278 (extract-calendar-year (cal-tex-next-month date
))
1279 "nextmonth" "1.1in" "1in"))
1280 (insert "\\hbox to \\textwidth{")
1282 (insert "\\lastmonth")
1284 (insert "\\thismonth")
1286 (insert "\\nextmonth")
1289 (cal-tex-banner "end of cal-tex-daily-page")))
1295 (defun cal-tex-mini-calendar (month year name width height
&optional ptsize colsep
)
1296 "Produce mini-calendar for MONTH, YEAR in macro NAME with WIDTH and HEIGHT.
1297 Optional PTSIZE gives the point ptsize; scriptsize is the default. Optional
1298 COLSEP gives the column separation; 1mm is the default."
1299 (let* ((blank-days;; at start of month
1301 (- (calendar-day-of-week (list month
1 year
))
1302 calendar-week-start-day
)
1304 (last (calendar-last-day-of-month month year
))
1305 (colsep (if colsep colsep
"1mm"))
1306 (str (concat "\\def\\" name
"{\\hbox to" width
"{%\n"
1307 "\\vbox to" height
"{%\n"
1308 "\\vfil \\hbox to" width
"{%\n"
1310 (if ptsize ptsize
"scriptsize")
1312 "{@{\\hspace{0mm}}r@{\\hspace{" colsep
1313 "}}r@{\\hspace{" colsep
"}}r@{\\hspace{" colsep
1314 "}}r@{\\hspace{" colsep
"}}r@{\\hspace{" colsep
1315 "}}r@{\\hspace{" colsep
"}}r@{\\hspace{0mm}}}%\n"
1316 "\\multicolumn{7}{c}{"
1317 (calendar-month-name month
)
1319 (int-to-string year
)
1321 (calendar-for-loop i from
0 to
6 do
1322 (setq str
(concat str
1323 (substring (aref calendar-day-name-array
1324 (mod (+ calendar-week-start-day i
) 7))
1329 (calendar-for-loop i from
1 to blank-days do
1330 (setq str
(concat str
" & ")))
1331 (calendar-for-loop i from
1 to last do
1332 (setq str
(concat str
(int-to-string i
)))
1333 (setq str
(concat str
(if (zerop (mod (+ i blank-days
) 7))
1334 (if (/= i last
) "\\\\[0.5mm]\n" "")
1336 (setq str
(concat str
"\n\\end{tabular}\\hfil}\\vfil}}}%\n"))
1340 ;;; Various calendar functions
1343 (defun cal-tex-incr-date (date &optional n
)
1344 "The date of the day following DATE.
1345 If optional N is given, the date of N days after DATE."
1346 (calendar-gregorian-from-absolute
1347 (+ (if n n
1) (calendar-absolute-from-gregorian date
))))
1349 (defun cal-tex-latexify-list (date-list date
&optional separator
)
1350 "Return string with concatenated, LaTeXified entries in DATE_LIST for DATE.
1351 Use double backslash as a separator unless optional SEPARATOR is given."
1352 (mapconcat '(lambda (x) (cal-tex-LaTeXify-string x
))
1357 (calendar-date-equal date
(car (car p
)))
1358 (setq result
(append (cdr (car p
)) result
)))
1361 (if separator separator
"\\\\")))
1363 (defun cal-tex-previous-month (date)
1364 "Return the date of the first day in the month previous to DATE."
1365 (let* ((month (extract-calendar-month date
))
1366 (year (extract-calendar-year date
)))
1367 (increment-calendar-month month year -
1)
1368 (list month
1 year
)))
1370 (defun cal-tex-next-month (date)
1371 "Return the date of the first day in the month following DATE."
1372 (let* ((month (extract-calendar-month date
))
1373 (year (extract-calendar-year date
)))
1374 (increment-calendar-month month year
1)
1375 (list month
1 year
)))
1381 (defun cal-tex-end-document ()
1382 "Finish the LaTeX document.
1383 Insert the trailer to LaTeX document, pop to LaTeX buffer, add
1384 informative header, and run HOOK."
1385 (cal-tex-e-document)
1387 (pop-to-buffer cal-tex-buffer
)
1388 (goto-char (point-min))
1389 (cal-tex-comment " This buffer was produced by cal-tex.el.")
1390 (cal-tex-comment " To print a calendar, type")
1391 (cal-tex-comment " M-x tex-buffer RET")
1392 (cal-tex-comment " M-x tex-print RET")
1393 (goto-char (point-min)))
1395 (defun cal-tex-insert-preamble (weeks landscape size
&optional append
)
1396 "Initialize the output buffer.
1397 Select the output buffer, and insert the preamble for a calendar of
1398 WEEKS weeks. Insert code for landscape mode if LANDSCAPE is true.
1399 Use pointsize SIZE. Optional argument APPEND, if t, means add to end of
1400 without erasing current contents."
1401 (let ((width "18cm")
1406 (setq height
"18cm")))
1409 (cal-tex-preamble size
)
1412 (cal-tex-cmd "\\oddsidemargin -1.75cm")
1413 (cal-tex-cmd "\\def\\holidaymult{.06}"))
1414 (cal-tex-cmd "\\special{landscape}")
1415 (cal-tex-cmd "\\textwidth 9.5in")
1416 (cal-tex-cmd "\\textheight 7in")
1418 (cal-tex-cmd "\\def\\holidaymult{.08}"))
1419 (cal-tex-cmd cal-tex-caldate
)
1420 (cal-tex-cmd cal-tex-myday
)
1421 (cal-tex-b-document)
1422 (cal-tex-cmd "\\pagestyle{empty}")))
1423 (cal-tex-cmd "\\setlength{\\cellwidth}" width
)
1424 (insert (format "\\setlength{\\cellwidth}{%f\\cellwidth}\n"
1425 (/ 1.1 (length cal-tex-which-days
))))
1426 (cal-tex-cmd "\\setlength{\\cellheight}" height
)
1427 (insert (format "\\setlength{\\cellheight}{%f\\cellheight}\n"
1429 (cal-tex-cmd "\\ \\par")
1430 (cal-tex-vspace "-3cm")))
1432 (defvar cal-tex-LaTeX-subst-list
1434 ("\"".
"''");; Quote changes meaning when list is reversed.
1445 ("\n" .
"\\ \\\\")) ;\\ needed for e.g \begin{center}\n AA\end{center}
1446 "List of symbols and their replacements.")
1448 (defun cal-tex-LaTeXify-string (string)
1449 "Protect special characters in STRING from LaTeX."
1454 (list cal-tex-LaTeX-subst-list
))
1455 (while (not (string-equal tail
""))
1456 (let* ((ch (substring tail
0 1))
1457 (pair (assoc ch list
)))
1458 (if (and pair
(string-equal ch
"\""))
1459 (setq list
(reverse list
)));; Quote changes meaning each time.
1460 (setq tail
(substring tail
1))
1461 (setq head
(concat head
(if pair
(cdr pair
) ch
)))))
1464 (defun cal-tex-hfill () "Insert hfill." (insert "\\hfill"))
1466 (defun cal-tex-newpage () "Insert newpage." (insert "\\newpage%\n"))
1468 (defun cal-tex-noindent () "Insert noindent." (insert "\\noindent"))
1470 (defun cal-tex-vspace (space)
1471 "Insert vspace command to move SPACE vertically."
1472 (insert "\\vspace*{" space
"}")
1475 (defun cal-tex-hspace (space)
1476 "Insert hspace command to move SPACE horizontally."
1477 (insert "\\hspace*{" space
"}")
1480 (defun cal-tex-comment (&optional comment
)
1481 "Insert % at end of line, include COMMENT if present, and move
1488 (defun cal-tex-banner (comment)
1489 "Insert the COMMENT separated by blank lines."
1492 (cal-tex-comment (concat "\t\t\t" comment
))
1496 (defun cal-tex-nl (&optional skip comment
)
1497 "End a line with \\. If SKIP, then add that much spacing.
1498 Add COMMENT if present"
1501 (insert "[" skip
"]"))
1502 (cal-tex-comment comment
))
1504 (defun cal-tex-arg (&optional text
)
1505 "Insert optional TEXT surrounded by braces."
1507 (if text
(insert text
))
1510 (defun cal-tex-cmd (cmd &optional arg
)
1511 "Insert LaTeX CMD, with optional ARG, and end with %"
1520 (defun cal-tex-b-document ()
1521 "Insert beginning of document."
1522 (cal-tex-cmd "\\begin{document}"))
1524 (defun cal-tex-e-document ()
1525 "Insert end of document."
1526 (cal-tex-cmd "\\end{document}"))
1528 (defun cal-tex-b-center ()
1529 "Insert beginning of centered block."
1530 (cal-tex-cmd "\\begin{center}"))
1532 (defun cal-tex-e-center ()
1533 "Insert end of centered block."
1535 (cal-tex-cmd "\\end{center}"))
1543 (defun cal-tex-b-parbox (position width
)
1544 "Insert parbox with parameters POSITION and WIDTH."
1545 (insert "\\parbox[" position
"]{" width
"}{")
1548 (defun cal-tex-e-parbox (&optional height
)
1549 "Insert end of parbox. Force it to be a given HEIGHT."
1552 (cal-tex-rule "0mm" "0mm" height
))
1554 (cal-tex-comment "end parbox"))
1556 (defun cal-tex-b-framebox ( width position
)
1557 "Insert framebox with parameters WIDTH and POSITION (clr)."
1558 (insert "\\framebox[" width
"][" position
"]{" )
1561 (defun cal-tex-e-framebox ()
1562 "Insert end of framebox."
1565 (cal-tex-comment "end framebox"))
1568 (defun cal-tex-b-makebox ( width position
)
1569 "Insert makebox with parameters WIDTH and POSITION (clr)."
1570 (insert "\\makebox[" width
"][" position
"]{" )
1573 (defun cal-tex-e-makebox ()
1574 "Insert end of makebox."
1577 (cal-tex-comment "end makebox"))
1580 (defun cal-tex-rule (lower width height
)
1581 "Insert a rule with parameters LOWER WIDTH HEIGHT."
1582 (insert "\\rule[" lower
"]{" width
"}{" height
"}"))
1588 (defun cal-tex-em (string)
1589 "Insert STRING in bf font."
1590 (insert "{\\em " string
"}"))
1592 (defun cal-tex-bf (string)
1593 "Insert STRING in bf font."
1594 (insert "{\\bf " string
"}"))
1596 (defun cal-tex-scriptsize (string)
1597 "Insert STRING in scriptsize font."
1598 (insert "{\\scriptsize " string
"}"))
1600 (defun cal-tex-huge (string)
1601 "Insert STRING in huge size."
1602 (insert "{\\huge " string
"}"))
1604 (defun cal-tex-Huge (string)
1605 "Insert STRING in Huge size."
1606 (insert "{\\Huge " string
"}"))
1608 (defun cal-tex-Huge-bf (string)
1609 "Insert STRING in Huge bf size."
1610 (insert "{\\Huge\\bf " string
"}"))
1612 (defun cal-tex-large (string)
1613 "Insert STRING in large size."
1614 (insert "{\\large " string
"}"))
1616 (defun cal-tex-large-bf (string)
1617 "Insert STRING in large bf size."
1618 (insert "{\\large\\bf " string
"}"))
1622 ;;; cal-tex.el ends here