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.
42 ;; (*) Improve the LaTeX command that produces the boxes in the monthly
43 ;; calendar to eliminate slight gap--what causes it?!
49 (autoload 'list-diary-entries
"diary-lib" nil t
)
50 (autoload 'calendar-holiday-list
"holidays" nil t
)
51 (autoload 'calendar-iso-from-absolute
"cal-iso" nil t
)
54 ;;; Customizable variables
57 (defvar cal-tex-which-days
'(0 1 2 3 4 5 6)
58 "*The days of the week that are displayed on the portrait monthly calendar.
59 Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to
60 Saturday. For example, use
62 (setq cal-tex-which-days '(1 3 5))
64 to only print Monday, Wednesday, Friday.")
66 (defvar cal-tex-holidays t
67 "*If t (default), then the holidays are also printed.
68 If finding the holidays is too slow, set this to nil.")
70 (defvar cal-tex-diary nil
71 "*If t, the diary entries are printed in the calendar.")
73 (defvar cal-tex-daily-string
74 '(let* ((year (extract-calendar-year date
))
75 (day (calendar-day-number date
))
76 (days-remaining (- (calendar-day-number (list 12 31 year
)) day
)))
77 (format "%d/%d" day days-remaining
))
78 "*An expression in the variable `date' whose value is placed on date.
79 The string resulting from evaluating this expression is placed at the bottom
80 center of `date' on the monthly calendar, next to the date in the weekly
81 calendars, and in the top center of daily calendars.
83 Default is ordinal day number of the year and the number of days remaining.
84 As an example of what you do, setting this to
88 (calendar-hebrew-date-string date))
90 will put the Hebrew date at the bottom of each day.")
92 (defvar cal-tex-buffer
"calendar.tex"
93 "*The name for the tex-ed calendar.")
95 (defvar cal-tex-24 nil
96 "*If t, use a 24 hour clock in the daily calendar.")
98 (defvar cal-tex-daily-start
8
99 "*The first hour of the daily calendar page.")
101 (defvar cal-tex-daily-end
20
102 "*The last hour of the daily calendar page.")
105 ;;; Definitions for LaTeX code
108 (defvar cal-tex-day-prefix
"\\caldate{%s}{%s}"
109 "The initial LaTeX code for a day.
110 The holidays, diary entries, bottom string, and the text follow.")
112 (defvar cal-tex-day-name-format
"\\myday{%s}%%"
113 "The format for LaTeX code for a day name. The names are taken from
114 calendar-day-name-array.")
116 (defvar cal-tex-cal-one-month
117 "\\def\\calmonth#1#2%
119 \\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]%
124 "LaTeX code for the month header")
126 (defvar cal-tex-cal-multi-month
127 "\\def\\calmonth#1#2#3#4%
129 \\Huge\\bf #1 #2---#3 #4\\\\[1cm]%
134 "LaTeX code for the month header")
136 (defvar cal-tex-myday
137 "\\renewcommand{\\myday}[1]%
138 {\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}}
141 "LaTeX code for a day heading")
143 (defvar cal-tex-caldate
145 \\long\\def\\caldate#1#2#3#4#5#6{%
146 \\fbox{\\hbox to\\cellwidth{%
147 \\vbox to\\cellheight{%
148 \\hbox to\\cellwidth{%
149 {\\hspace*{1mm}\\Large \\bf \\strut #2}\\hspace{.05\\cellwidth}%
150 \\raisebox{\\holidaymult\\cellheight}%
151 {\\parbox[t]{.75\\cellwidth}{\\tiny \\raggedright #4}}}
152 \\hbox to\\cellwidth{%
153 \\hspace*{1mm}\\parbox{.95\\cellwidth}{\\tiny \\raggedright #3}}
155 \\hbox to\\cellwidth{#6}%
157 \\hbox to\\cellwidth{\\hfill \\tiny #5 \\hfill}%
161 "LaTeX code to insert one box with date info in calendar.
162 This definition is the heart of the calendar!")
164 (defun cal-tex-list-holidays (d1 d2
)
165 "Generate a list of all holidays from absolute date D1 to D2."
167 (start (calendar-gregorian-from-absolute d1
))
168 (start-month (extract-calendar-month start
))
169 (start-year (extract-calendar-year start
)))
170 (increment-calendar-month start-month start-year
1)
171 (let* ((end (calendar-gregorian-from-absolute d2
))
172 (end-month (extract-calendar-month end
))
173 (end-year (extract-calendar-year end
)))
174 (if (= (extract-calendar-day end
) 1)
175 (increment-calendar-month end-month end-year -
1))
176 (let* ((s (calendar-absolute-from-gregorian
177 (list start-month
1 start-year
)))
178 (e (calendar-absolute-from-gregorian
179 (list end-month
1 end-year
)))
182 (displayed-month start-month
)
183 (displayed-year start-year
))
184 (while (or never
(<= d e
))
185 (setq result
(append result
(calendar-holiday-list)))
187 (increment-calendar-month displayed-month displayed-year
3)
188 (setq d
(calendar-absolute-from-gregorian
189 (list displayed-month
1 displayed-year
))))))
194 (let ((a (calendar-absolute-from-gregorian (car (car p
)))))
195 (and (<= d1 a
) (<= a d2
)))
196 (setq in-range
(append (list (car p
)) in-range
)))
200 (defun cal-tex-list-diary-entries (d1 d2
)
201 "Generate a list of all diary-entries from absolute date D1 to D2."
202 (let ((diary-display-hook nil
))
204 (calendar-gregorian-from-absolute d1
)
207 (defun cal-tex-preamble (&optional args
)
208 "Insert the LaTeX preamble.
209 Preamble Includes initial definitions for various LaTeX commands.
210 Optional ARGS are included."
211 (set-buffer (get-buffer-create cal-tex-buffer
))
213 (insert "\\documentstyle")
215 (insert "[" args
"]"))
216 (insert "{article}\n"
222 \\evensidemargin -2cm
227 \\newlength{\\cellwidth}
228 \\newlength{\\cellheight}
229 \\newlength{\\boxwidth}
230 \\newlength{\\boxheight}
231 \\newlength{\\cellsize}
232 \\newcommand{\\myday}[1]{}
233 \\newcommand{\\caldate}[6]{}
234 \\newcommand{\\nocaldate}[6]{}
235 \\newcommand{\\calsmall}[6]{}
243 (defun cal-tex-cursor-year (&optional arg
)
244 "Make a buffer with LaTeX commands for the year cursor is on.
245 Optional prefix argument specifies number of years."
247 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t
))
250 (defun cal-tex-cursor-year-landscape (&optional arg
)
251 "Make a buffer with LaTeX commands for the year cursor is on.
252 Optional prefix argument specifies number of years."
254 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t
))
258 (defun cal-tex-year (year n
&optional landscape
)
259 "Make a one page yearly calendar of YEAR; do this for N years.
260 There are four rows of three months each, unless optional LANDSCAPE is t,
261 in which case the calendar isprinted in landscape mode with three rows of
263 (cal-tex-insert-preamble 1 landscape
"12pt")
265 (cal-tex-vspace "-.6cm")
266 (cal-tex-vspace "-3.1cm"))
267 (calendar-for-loop j from
1 to n do
268 (insert "\\vfill%\n")
270 (cal-tex-Huge (number-to-string year
))
272 (cal-tex-vspace "1cm")
274 (cal-tex-b-parbox "l" (if landscape
"5.9in" "4.3in"))
278 (calendar-for-loop i from
1 to
12 do
279 (insert (cal-tex-mini-calendar i year
"month" "1.1in" "1in"))
281 (cal-tex-hspace "0.5in")
282 (if (zerop (mod i
(if landscape
4 3)))
283 (cal-tex-nl "0.5in")))
286 (insert "\\vfill%\n")
287 (setq year
(1+ year
))
290 (cal-tex-end-document))
291 (run-hooks 'cal-tex-year-hook
))
292 (run-hooks 'cal-tex-hook
))
294 (defun cal-tex-cursor-filofax-year (&optional arg
)
295 "Make a Filofax one page yearly calendar of year indicated by cursor.
296 Optional parameter specifies number of years."
298 (let* ((n (if arg arg
1))
299 (year (extract-calendar-year (calendar-cursor-to-date t
))))
300 (cal-tex-preamble "twoside")
301 (cal-tex-cmd "\\textwidth 3.25in")
302 (cal-tex-cmd "\\textheight 6.5in")
303 (cal-tex-cmd "\\oddsidemargin 1.675in")
304 (cal-tex-cmd "\\evensidemargin 1.675in")
305 (cal-tex-cmd "\\topmargin 0pt")
306 (cal-tex-cmd "\\headheight -0.875in")
307 (cal-tex-cmd "\\fboxsep 0.5mm")
308 (cal-tex-cmd "\\pagestyle{empty}")
310 (cal-tex-cmd "\\vspace*{0.25in}")
311 (calendar-for-loop j from
1 to n do
312 (insert (format "\\hfil {\\Large \\bf %s} \\hfil\\\\\n" year
))
314 (cal-tex-b-parbox "l" "\\textwidth")
318 (calendar-for-loop i from
1 to
12 do
319 (insert (cal-tex-mini-calendar i year
320 (calendar-month-name i
)
321 "1in" ".9in" "tiny" "0.6mm")))
323 "\\noindent\\fbox{\\January}\\fbox{\\February}\\fbox{\\March}\\\\
324 \\noindent\\fbox{\\April}\\fbox{\\May}\\fbox{\\June}\\\\
325 \\noindent\\fbox{\\July}\\fbox{\\August}\\fbox{\\September}\\\\
326 \\noindent\\fbox{\\October}\\fbox{\\November}\\fbox{\\December}
330 (setq year
(1+ year
))
332 (cal-tex-end-document)
334 (cal-tex-cmd "\\vspace*{0.25in}"))
335 (run-hooks 'cal-tex-year-hook
))
336 (run-hooks 'cal-tex-hook
)))
339 ;;; Monthly calendars
342 (defun cal-tex-cursor-month-landscape (&optional arg
)
343 "Make a buffer with LaTeX commands for the month cursor is on.
344 Optional prefix argument specifies number of months to be produced.
345 The output is in landscape format, one month to a page."
347 (let* ((n (if arg arg
1))
348 (date (calendar-cursor-to-date t
))
349 (month (extract-calendar-month date
))
350 (year (extract-calendar-year date
))
353 (cal-tex-which-days '(0 1 2 3 4 5 6)))
354 (increment-calendar-month end-month end-year
(1- n
))
355 (let ((diary-list (if cal-tex-diary
356 (cal-tex-list-diary-entries
357 (calendar-absolute-from-gregorian
359 (calendar-absolute-from-gregorian
361 (calendar-last-day-of-month
364 (holidays (if cal-tex-holidays
365 (cal-tex-list-holidays
366 (calendar-absolute-from-gregorian
368 (calendar-absolute-from-gregorian
370 (calendar-last-day-of-month end-month end-year
)
374 (small-months-at-start))
375 (cal-tex-insert-preamble (cal-tex-number-weeks month year
1) t
"12pt")
376 (cal-tex-cmd cal-tex-cal-one-month
)
377 (calendar-for-loop i from
1 to n do
378 (setq other-month month
)
379 (setq other-year year
)
380 (increment-calendar-month other-month other-year -
1)
381 (insert (cal-tex-mini-calendar other-month other-year
"lastmonth"
382 "\\cellwidth" "\\cellheight"))
383 (increment-calendar-month other-month other-year
2)
384 (insert (cal-tex-mini-calendar other-month other-year
"nextmonth"
385 "\\cellwidth" "\\cellheight"))
386 (cal-tex-insert-month-header 1 month year month year
)
387 (cal-tex-insert-day-names)
389 (setq small-months-at-start
390 (< 1 (mod (- (calendar-day-of-week (list month
1 year
))
391 calendar-week-start-day
)
393 (if small-months-at-start
394 (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}"))
395 (cal-tex-insert-blank-days month year cal-tex-day-prefix
)
396 (cal-tex-insert-days month year diary-list holidays
398 (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix
)
399 (if (and (not small-months-at-start
)
400 (< 1 (mod (- (1- calendar-week-start-day
)
401 (calendar-day-of-week
403 (calendar-last-day-of-month month year
)
406 (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}"
407 "\\lastmonth\\nextmonth"))
410 (run-hooks 'cal-tex-month-hook
)
412 (increment-calendar-month month year
1)
413 (cal-tex-vspace "-2cm")
414 (cal-tex-insert-preamble
415 (cal-tex-number-weeks month year
1) t
"12pt" t
))))
416 (cal-tex-end-document)
417 (run-hooks 'cal-tex-hook
))))
419 (defun cal-tex-cursor-month (arg)
420 "Make a buffer with LaTeX commands for the month cursor is on.
421 Optional prefix argument specifies number of months to be produced.
422 Calendar is condensed onto one page."
424 (let* ((date (calendar-cursor-to-date t
))
425 (month (extract-calendar-month date
))
426 (year (extract-calendar-year date
))
430 (increment-calendar-month end-month end-year
(1- n
))
431 (let ((diary-list (if cal-tex-diary
432 (cal-tex-list-diary-entries
433 (calendar-absolute-from-gregorian
435 (calendar-absolute-from-gregorian
437 (calendar-last-day-of-month
440 (holidays (if cal-tex-holidays
441 (cal-tex-list-holidays
442 (calendar-absolute-from-gregorian
444 (calendar-absolute-from-gregorian
446 (calendar-last-day-of-month end-month end-year
)
450 (cal-tex-insert-preamble (cal-tex-number-weeks month year n
) nil
"12pt")
452 (cal-tex-cmd cal-tex-cal-multi-month
)
453 (cal-tex-cmd cal-tex-cal-one-month
))
454 (cal-tex-insert-month-header n month year end-month end-year
)
455 (cal-tex-insert-day-names)
457 (cal-tex-insert-blank-days month year cal-tex-day-prefix
)
458 (calendar-for-loop i from
1 to n do
459 (setq other-month month
)
460 (setq other-year year
)
461 (cal-tex-insert-days month year diary-list holidays
463 (increment-calendar-month month year
1))
464 (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix
)
465 (cal-tex-end-document)))
466 (run-hooks 'cal-tex-hook
))
468 (defun cal-tex-insert-days (month year diary-list holidays day-format
)
469 "Insert LaTeX commands for a range of days in monthly calendars.
470 LaTeX commands are inserted for the days of the MONTH in YEAR.
471 Diary entries on DIARY-LIST are included. Holidays on HOLIDAYS are included.
472 Each day is formatted using format DAY-FORMAT."
473 (let* ((blank-days;; at start of month
475 (- (calendar-day-of-week (list month
1 year
))
476 calendar-week-start-day
)
479 (last (calendar-last-day-of-month month year
)))
480 (calendar-for-loop i from
1 to last do
481 (setq date
(list month i year
))
482 (if (memq (calendar-day-of-week date
) cal-tex-which-days
)
484 (insert (format day-format
(calendar-month-name month
) i
))
485 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
486 (cal-tex-arg (cal-tex-latexify-list holidays date
))
487 (cal-tex-arg (eval cal-tex-daily-string
))
490 (if (and (zerop (mod (+ i blank-days
) 7))
496 (defun cal-tex-insert-day-names ()
497 "Insert the names of the days at top of a monthly calendar."
498 (calendar-for-loop i from
0 to
6 do
499 (if (memq i cal-tex-which-days
)
500 (insert (format cal-tex-day-name-format
501 (aref calendar-day-name-array
502 (mod (+ calendar-week-start-day i
) 7)))))
505 (defun cal-tex-insert-month-header (n month year end-month end-year
)
506 "Create a title for a calendar.
507 A title is inserted for a calendar with N months starting with
508 MONTH YEAR and ending with END-MONTH END-YEAR."
509 (let ( (month-name (calendar-month-name month
))
510 (end-month-name (calendar-month-name end-month
)))
512 (insert (format "\\calmonth{%s}{%s}\n\\vspace*{-0.5cm}"
514 (insert (format "\\calmonth{%s}{%s}{%s}{%s}\n\\vspace*{-0.5cm}"
515 month-name year end-month-name end-year
))))
518 (defun cal-tex-insert-blank-days (month year day-format
)
519 "Insert code for initial days not in calendar.
520 Insert LaTeX code for the blank days at the beginning of the MONTH in
521 YEAR. The entry is formatted using DAY-FORMAT. If the entire week is
522 blank, no days are inserted."
523 (if (cal-tex-first-blank-p month year
)
524 (let* ((blank-days;; at start of month
526 (- (calendar-day-of-week (list month
1 year
))
527 calendar-week-start-day
)
529 (calendar-for-loop i from
0 to
(1- blank-days
) do
530 (if (memq i cal-tex-which-days
)
531 (insert (format day-format
" " " ") "{}{}{}{}%\n"))))))
533 (defun cal-tex-insert-blank-days-at-end (month year day-format
)
534 "Insert code for final days not in calendar.
535 Insert LaTeX code for the blank days at the end of the MONTH in YEAR.
536 The entry is formatted using DAY-FORMAT."
537 (if (cal-tex-last-blank-p month year
)
538 (let* ((last-day (calendar-last-day-of-month month year
))
539 (blank-days;; at end of month
541 (- (calendar-day-of-week (list month last-day year
))
542 calendar-week-start-day
)
544 (calendar-for-loop i from
(1+ blank-days
) to
6 do
545 (if (memq i cal-tex-which-days
)
546 (insert (format day-format
"" "") "{}{}{}{}%\n"))))))
548 (defun cal-tex-first-blank-p (month year
)
549 "Determine if any days of the first week will be printed.
550 Return t if there will there be any days of the first week printed
551 in the calendar starting in MONTH YEAR."
553 (the-saturday)) ;the day of week of 1st Saturday
554 (calendar-for-loop i from
1 to
7 do
555 (if (= 6 (calendar-day-of-week (list month i year
)))
556 (setq the-saturday i
)))
557 (calendar-for-loop i from
1 to the-saturday do
558 (if (memq (calendar-day-of-week (list month i year
))
563 (defun cal-tex-last-blank-p (month year
)
564 "Determine if any days of the last week will be printed.
565 Return t if there will there be any days of the last week printed
566 in the calendar starting in MONTH YEAR."
568 (last-day (calendar-last-day-of-month month year
))
569 (the-sunday)) ;the day of week of last Sunday
570 (calendar-for-loop i from
(- last-day
6) to last-day do
571 (if (= 0 (calendar-day-of-week (list month i year
)))
572 (setq the-sunday i
)))
573 (calendar-for-loop i from the-sunday to last-day do
574 (if (memq (calendar-day-of-week (list month i year
))
579 (defun cal-tex-number-weeks (month year n
)
580 "Determine the number of weeks in a range of dates.
581 Compute the number of weeks in the calendar starting with MONTH and YEAR,
582 and lasting N months, including only the days in WHICH-DAYS. As it stands,
583 this is only an upper bound."
584 (let ((d (list month
1 year
)))
585 (increment-calendar-month month year
(1- n
))
586 (/ (- (calendar-dayname-on-or-before
587 calendar-week-start-day
588 (+ 7 (calendar-absolute-from-gregorian
589 (list month
(calendar-last-day-of-month month year
) year
))))
590 (calendar-dayname-on-or-before
591 calendar-week-start-day
592 (calendar-absolute-from-gregorian d
)))
599 (defun cal-tex-cursor-week (&optional arg
)
600 "Make a buffer with LaTeX commands for a two-page one-week calendar.
601 It applies to the week that point is in.
602 Optional prefix argument specifies number of weeks.
603 Holidays are included if `cal-tex-holidays' is t."
605 (let* ((n (if arg arg
1))
606 (date (calendar-gregorian-from-absolute
607 (calendar-dayname-on-or-before
608 calendar-week-start-day
609 (calendar-absolute-from-gregorian
610 (calendar-cursor-to-date t
)))))
611 (month (extract-calendar-month date
))
612 (year (extract-calendar-year date
))
613 (holidays (if cal-tex-holidays
614 (cal-tex-list-holidays
615 (calendar-absolute-from-gregorian date
)
617 (calendar-absolute-from-gregorian date
))))))
618 (cal-tex-preamble "11pt")
619 (cal-tex-cmd "\\textwidth 6.5in")
620 (cal-tex-cmd "\\textheight 10.5in")
621 (cal-tex-cmd "\\oddsidemargin 0in")
622 (cal-tex-cmd "\\evensidemargin 0in")
623 (insert cal-tex-LaTeX-hourbox
)
625 (cal-tex-cmd "\\pagestyle{empty}")
626 (calendar-for-loop i from
1 to n do
627 (cal-tex-vspace "-1.5in")
629 (cal-tex-Huge-bf (format "\\uppercase{%s}"
630 (calendar-month-name month
)))
631 (cal-tex-hspace "2em")
632 (cal-tex-Huge-bf (number-to-string year
))
635 (cal-tex-hspace "-.2in")
636 (cal-tex-b-parbox "l" "7in")
637 (calendar-for-loop j from
1 to
7 do
638 (cal-tex-week-hours date holidays
"3.1")
639 (setq date
(cal-tex-incr-date date
)))
641 (setq month
(extract-calendar-month date
))
642 (setq year
(extract-calendar-year date
))
645 (run-hooks 'cal-tex-week-hook
)
647 (cal-tex-end-document)
648 (run-hooks 'cal-tex-hook
)))
650 (defun cal-tex-cursor-week2 (&optional arg
)
651 "Make a buffer with LaTeX commands for a two-page one-week calendar.
652 It applies to the week that point is in.
653 Optional prefix argument specifies number of weeks.
654 Holidays are included if `cal-tex-holidays' is t."
656 (let* ((n (if arg arg
1))
657 (date (calendar-gregorian-from-absolute
658 (calendar-dayname-on-or-before
659 calendar-week-start-day
660 (calendar-absolute-from-gregorian
661 (calendar-cursor-to-date t
)))))
662 (month (extract-calendar-month date
))
663 (year (extract-calendar-year date
))
665 (holidays (if cal-tex-holidays
666 (cal-tex-list-holidays
667 (calendar-absolute-from-gregorian date
)
669 (calendar-absolute-from-gregorian date
))))))
670 (cal-tex-preamble "12pt")
671 (cal-tex-cmd "\\textwidth 6.5in")
672 (cal-tex-cmd "\\textheight 10.5in")
673 (cal-tex-cmd "\\oddsidemargin 0in")
674 (cal-tex-cmd "\\evensidemargin 0in")
675 (insert cal-tex-LaTeX-hourbox
)
677 (cal-tex-cmd "\\pagestyle{empty}")
678 (calendar-for-loop i from
1 to n do
679 (cal-tex-vspace "-1.5in")
681 (cal-tex-Huge-bf (format "\\uppercase{%s}"
682 (calendar-month-name month
)))
683 (cal-tex-hspace "2em")
684 (cal-tex-Huge-bf (number-to-string year
))
687 (cal-tex-hspace "-.2in")
688 (cal-tex-b-parbox "l" "\\textwidth")
689 (calendar-for-loop j from
1 to
3 do
690 (cal-tex-week-hours date holidays
"5")
691 (setq date
(cal-tex-incr-date date
)))
694 (insert (cal-tex-mini-calendar
695 (extract-calendar-month (cal-tex-previous-month date
))
696 (extract-calendar-year (cal-tex-previous-month date
))
697 "lastmonth" "1.1in" "1in"))
698 (insert (cal-tex-mini-calendar
699 (extract-calendar-month date
)
700 (extract-calendar-year date
)
701 "thismonth" "1.1in" "1in"))
702 (insert (cal-tex-mini-calendar
703 (extract-calendar-month (cal-tex-next-month date
))
704 (extract-calendar-year (cal-tex-next-month date
))
705 "nextmonth" "1.1in" "1in"))
706 (insert "\\hbox to \\textwidth{")
708 (insert "\\lastmonth")
710 (insert "\\thismonth")
712 (insert "\\nextmonth")
716 (cal-tex-b-parbox "l" "\\textwidth")
717 (calendar-for-loop j from
4 to
7 do
718 (cal-tex-week-hours date holidays
"5")
719 (setq date
(cal-tex-incr-date date
)))
721 (setq month
(extract-calendar-month date
))
722 (setq year
(extract-calendar-year date
))
725 (run-hooks 'cal-tex-week-hook
)
727 (cal-tex-end-document)
728 (run-hooks 'cal-tex-hook
)))
730 (defun cal-tex-cursor-week-iso (&optional arg
)
731 "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar.
732 Optional prefix argument specifies number of weeks.
733 Diary entries are included if `cal-tex-diary' is t.
734 Holidays are included if `cal-tex-holidays' is t."
736 (let* ((n (if arg arg
1))
737 (date (calendar-gregorian-from-absolute
738 (calendar-dayname-on-or-before
740 (calendar-absolute-from-gregorian
741 (calendar-cursor-to-date t
)))))
742 (month (extract-calendar-month date
))
743 (year (extract-calendar-year date
))
744 (day (extract-calendar-day date
))
745 (holidays (if cal-tex-holidays
746 (cal-tex-list-holidays
747 (calendar-absolute-from-gregorian date
)
749 (calendar-absolute-from-gregorian date
)))))
750 (diary-list (if cal-tex-diary
751 (cal-tex-list-diary-entries
752 (calendar-absolute-from-gregorian
755 (calendar-absolute-from-gregorian date
))))))
756 (cal-tex-preamble "11pt")
757 (cal-tex-cmd "\\textwidth 6.5in")
758 (cal-tex-cmd "\\textheight 10.5in")
759 (cal-tex-cmd "\\oddsidemargin 0in")
760 (cal-tex-cmd "\\evensidemargin 0in")
762 (cal-tex-cmd "\\pagestyle{empty}")
763 (calendar-for-loop i from
1 to n do
764 (cal-tex-vspace "-1.5in")
767 (let* ((d (calendar-iso-from-absolute
768 (calendar-absolute-from-gregorian date
))))
769 (format "Week %d of %d"
770 (extract-calendar-month d
)
771 (extract-calendar-year d
))))
774 (cal-tex-b-parbox "l" "\\textwidth")
775 (calendar-for-loop j from
1 to
7 do
776 (cal-tex-b-parbox "t" "\\textwidth")
777 (cal-tex-b-parbox "t" "\\textwidth")
778 (cal-tex-rule "0pt" "\\textwidth" ".2mm")
780 (cal-tex-b-parbox "t" "\\textwidth")
781 (cal-tex-large-bf (calendar-day-name date
))
783 (cal-tex-large-bf (calendar-month-name month
))
785 (cal-tex-large-bf (number-to-string day
))
786 (if (not (string= "" (cal-tex-latexify-list holidays date
)))
789 (cal-tex-large-bf (cal-tex-latexify-list holidays date
"; "))))
791 (insert " " (eval cal-tex-daily-string
))
795 (cal-tex-b-parbox "t" "\\textwidth")
796 (if (not (string= "" (cal-tex-latexify-list diary-list date
)))
798 (insert "\\vbox to 0pt{")
800 (cal-tex-latexify-list diary-list date
))
804 (setq date
(cal-tex-incr-date date
))
805 (setq month
(extract-calendar-month date
))
806 (setq day
(extract-calendar-day date
))
808 (cal-tex-e-parbox "2cm")
810 (setq month
(extract-calendar-month date
))
811 (setq year
(extract-calendar-year date
)))
815 (run-hooks 'cal-tex-week-hook
)
817 (cal-tex-end-document)
818 (run-hooks 'cal-tex-hook
)))
820 (defvar cal-tex-LaTeX-hourbox
821 "\\newcommand{\\hourbox}[2]%
822 {\\makebox[2em]{\\rule{0cm}{#2ex}#1}\\rule{3in}{.15mm}}\n"
823 "One hour and a line on the right.")
825 (defun cal-tex-week-hours (date holidays height
)
826 "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT."
827 (let ((month (extract-calendar-month date
))
828 (day (extract-calendar-day date
))
829 (year (extract-calendar-year date
))
831 (cal-tex-comment "begin cal-tex-week-hours")
832 (cal-tex-cmd "\\ \\\\[-.2cm]")
833 (cal-tex-cmd "\\noindent")
834 (cal-tex-b-parbox "l" "6.8in")
835 (cal-tex-large-bf (calendar-day-name date
))
837 (cal-tex-large-bf (calendar-month-name month
))
839 (cal-tex-large-bf (number-to-string day
))
840 (if (not (string= "" (cal-tex-latexify-list holidays date
)))
843 (cal-tex-large-bf (cal-tex-latexify-list holidays date
"; "))))
845 (insert " " (eval cal-tex-daily-string
))
848 (cal-tex-rule "0pt" "6.8in" ".2mm")
850 (calendar-for-loop i from
8 to
12 do
852 (setq afternoon
(+ i
5))
853 (setq afternoon
(- i
7)))
854 (cal-tex-cmd "\\hourbox" (number-to-string i
))
856 (cal-tex-hspace ".4cm")
857 (cal-tex-cmd "\\hourbox" (number-to-string afternoon
))
861 (defun cal-tex-cursor-week-monday (&optional arg
)
862 "Make a buffer with LaTeX commands for a two-page one-week calendar.
863 It applies to the week that point is in, and starts on Monday.
864 Optional prefix argument specifies number of weeks.
865 Holidays are included if `cal-tex-holidays' is t."
867 (let* ((n (if arg arg
1))
868 (date (calendar-gregorian-from-absolute
869 (calendar-dayname-on-or-before
871 (calendar-absolute-from-gregorian
872 (calendar-cursor-to-date t
))))))
873 (cal-tex-preamble "11pt")
874 (cal-tex-cmd "\\textwidth 6.5in")
875 (cal-tex-cmd "\\textheight 10.5in")
876 (cal-tex-cmd "\\oddsidemargin 0in")
877 (cal-tex-cmd "\\evensidemargin 0in")
879 (calendar-for-loop i from
1 to n do
880 (cal-tex-vspace "-1cm")
881 (insert "\\noindent ")
882 (cal-tex-weekly4-box (cal-tex-incr-date date
) nil
)
883 (cal-tex-weekly4-box (cal-tex-incr-date date
4) nil
)
885 (cal-tex-weekly4-box (cal-tex-incr-date date
2) nil
)
886 (cal-tex-weekly4-box (cal-tex-incr-date date
5) nil
)
888 (cal-tex-weekly4-box (cal-tex-incr-date date
3) nil
)
889 (cal-tex-weekly4-box (cal-tex-incr-date date
6) t
)
892 (run-hooks 'cal-tex-week-hook
)
893 (setq date
(cal-tex-incr-date date
7))
895 (cal-tex-end-document)
896 (run-hooks 'cal-tex-hook
)))
898 (defun cal-tex-weekly4-box (date weekend
)
899 "Make one box for DATE, different if WEEKEND."
901 (day (extract-calendar-day date
))
902 (month (extract-calendar-month date
))
903 (year (extract-calendar-year date
))
904 (dayname (calendar-day-name date
))
905 (date1 (cal-tex-incr-date date
))
906 (day1 (extract-calendar-day date1
))
907 (month1 (extract-calendar-month date1
))
908 (year1 (extract-calendar-year date1
))
909 (dayname1 (calendar-day-name date1
))
911 (cal-tex-b-framebox "8cm" "l")
912 (cal-tex-b-parbox "b" "7.5cm")
913 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year
))
914 (cal-tex-rule "0pt" "7.5cm" ".5mm")
918 (calendar-for-loop i from
8 to
12 do
919 (insert (format "{\\large\\sf %d}\\\\\n" i
)))
920 (calendar-for-loop i from
1 to
5 do
921 (insert (format "{\\large\\sf %d}\\\\\n" i
)))))
925 (cal-tex-vspace "1cm")
926 (insert "\\ \\vfill")
927 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n"
928 dayname1 month1 day1 year1
))
929 (cal-tex-rule "0pt" "7.5cm" ".5mm")
931 (cal-tex-vspace "1cm")))
934 (cal-tex-hspace "1cm")))
936 (defun cal-tex-cursor-filofax-2week (&optional arg
)
937 "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor.
938 Optional prefix argument specifies number of weeks.
939 Diary entries are included if `cal-tex-diary' is t.
940 Holidays are included if `cal-tex-holidays' is t."
942 (let* ((n (if arg arg
1))
943 (date (calendar-gregorian-from-absolute
944 (calendar-dayname-on-or-before
945 calendar-week-start-day
946 (calendar-absolute-from-gregorian
947 (calendar-cursor-to-date t
)))))
948 (month (extract-calendar-month date
))
949 (year (extract-calendar-year date
))
950 (day (extract-calendar-day date
))
951 (holidays (if cal-tex-holidays
952 (cal-tex-list-holidays
953 (calendar-absolute-from-gregorian date
)
955 (calendar-absolute-from-gregorian date
)))))
956 (diary-list (if cal-tex-diary
957 (cal-tex-list-diary-entries
958 (calendar-absolute-from-gregorian
961 (calendar-absolute-from-gregorian date
))))))
962 (cal-tex-preamble "twoside")
963 (cal-tex-cmd "\\textwidth 3.25in")
964 (cal-tex-cmd "\\textheight 6.5in")
965 (cal-tex-cmd "\\oddsidemargin 1.75in")
966 (cal-tex-cmd "\\evensidemargin 1.5in")
967 (cal-tex-cmd "\\topmargin 0pt")
968 (cal-tex-cmd "\\headheight -0.875in")
969 (cal-tex-cmd "\\headsep 0.125in")
970 (cal-tex-cmd "\\footskip .125in")
971 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
972 \\long\\def\\rightday#1#2#3#4#5{%
973 \\rule{\\textwidth}{0.3pt}\\\\%
974 \\hbox to \\textwidth{%
977 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
978 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
979 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
980 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
981 \\long\\def\\leftday#1#2#3#4#5{%
982 \\rule{\\textwidth}{0.3pt}\\\\%
983 \\hbox to \\textwidth{%
986 \\hbox to \\textwidth{\\noindent {\\normalsize \\bf #2} \\small #1 \\hfill #5}%
987 \\hbox to \\textwidth{\\vbox {\\noindent \\footnotesize \\em #4}}%
988 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
991 (cal-tex-cmd "\\pagestyle{empty}")
992 (calendar-for-loop i from
1 to n do
994 (insert "\\righthead")
995 (insert "\\lefthead"))
997 (let ((d (cal-tex-incr-date date
6)))
998 (if (= (extract-calendar-month date
)
999 (extract-calendar-month d
))
1001 (calendar-month-name
1002 (extract-calendar-month date
))
1003 (extract-calendar-year date
))
1004 (if (= (extract-calendar-year date
)
1005 (extract-calendar-year d
))
1006 (format "%s---%s %s"
1007 (calendar-month-name
1008 (extract-calendar-month date
))
1009 (calendar-month-name
1010 (extract-calendar-month d
))
1011 (extract-calendar-year date
))
1012 (format "%s %s---%s %s"
1013 (calendar-month-name
1014 (extract-calendar-month date
))
1015 (extract-calendar-year date
)
1016 (calendar-month-name (extract-calendar-month d
))
1017 (extract-calendar-year d
))))))
1019 (calendar-for-loop j from
1 to
7 do
1021 (insert "\\rightday")
1022 (insert "\\leftday"))
1023 (cal-tex-arg (calendar-day-name date
))
1024 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1025 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1026 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1027 (cal-tex-arg (eval cal-tex-daily-string
))
1029 (setq date
(cal-tex-incr-date date
)))
1032 (run-hooks 'cal-tex-week-hook
)
1033 (cal-tex-newpage))))
1034 (cal-tex-end-document)
1035 (run-hooks 'cal-tex-hook
)))
1037 (defun cal-tex-cursor-filofax-week (&optional arg
)
1038 "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
1039 Optional prefix argument specifies number of weeks.
1040 Weeks start on Monday.
1041 Diary entries are included if `cal-tex-diary' is t.
1042 Holidays are included if `cal-tex-holidays' is t."
1044 (let* ((n (if arg arg
1))
1045 (date (calendar-gregorian-from-absolute
1046 (calendar-dayname-on-or-before
1048 (calendar-absolute-from-gregorian
1049 (calendar-cursor-to-date t
)))))
1050 (month (extract-calendar-month date
))
1051 (year (extract-calendar-year date
))
1052 (day (extract-calendar-day date
))
1053 (holidays (if cal-tex-holidays
1054 (cal-tex-list-holidays
1055 (calendar-absolute-from-gregorian date
)
1057 (calendar-absolute-from-gregorian date
)))))
1058 (diary-list (if cal-tex-diary
1059 (cal-tex-list-diary-entries
1060 (calendar-absolute-from-gregorian
1061 (list month
1 year
))
1063 (calendar-absolute-from-gregorian date
))))))
1064 (cal-tex-preamble "twoside")
1065 (cal-tex-cmd "\\textwidth 3.25in")
1066 (cal-tex-cmd "\\textheight 6.5in")
1067 (cal-tex-cmd "\\oddsidemargin 1.75in")
1068 (cal-tex-cmd "\\evensidemargin 1.5in")
1069 (cal-tex-cmd "\\topmargin 0pt")
1070 (cal-tex-cmd "\\headheight -0.875in")
1071 (cal-tex-cmd "\\headsep 0.125in")
1072 (cal-tex-cmd "\\footskip .125in")
1073 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
1074 \\long\\def\\rightday#1#2#3#4#5{%
1075 \\rule{\\textwidth}{0.3pt}\\\\%
1076 \\hbox to \\textwidth{%
1079 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
1080 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
1081 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1082 \\long\\def\\weekend#1#2#3#4#5{%
1083 \\rule{\\textwidth}{0.3pt}\\\\%
1084 \\hbox to \\textwidth{%
1087 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
1088 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
1089 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1090 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
1091 \\long\\def\\leftday#1#2#3#4#5{%
1092 \\rule{\\textwidth}{0.3pt}\\\\%
1093 \\hbox to \\textwidth{%
1096 \\hbox to \\textwidth{\\noindent {\\normalsize \\bf #2} \\small #1 \\hfill #5}%
1097 \\hbox to \\textwidth{\\vbox {\\noindent \\footnotesize \\em #4}}%
1098 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1100 (cal-tex-b-document)
1101 (cal-tex-cmd "\\pagestyle{empty}\\ ")
1103 (calendar-for-loop i from
1 to n do
1104 (insert "\\lefthead")
1106 (let ((d (cal-tex-incr-date date
2)))
1107 (if (= (extract-calendar-month date
)
1108 (extract-calendar-month d
))
1110 (calendar-month-name
1111 (extract-calendar-month date
))
1112 (extract-calendar-year date
))
1113 (if (= (extract-calendar-year date
)
1114 (extract-calendar-year d
))
1115 (format "%s---%s %s"
1116 (calendar-month-name
1117 (extract-calendar-month date
))
1118 (calendar-month-name
1119 (extract-calendar-month d
))
1120 (extract-calendar-year date
))
1121 (format "%s %s---%s %s"
1122 (calendar-month-name
1123 (extract-calendar-month date
))
1124 (extract-calendar-year date
)
1125 (calendar-month-name (extract-calendar-month d
))
1126 (extract-calendar-year d
))))))
1128 (calendar-for-loop j from
1 to
3 do
1129 (insert "\\leftday")
1130 (cal-tex-arg (calendar-day-name date
))
1131 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1132 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1133 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1134 (cal-tex-arg (eval cal-tex-daily-string
))
1136 (setq date
(cal-tex-incr-date date
)))
1137 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")
1139 (insert "\\righthead")
1141 (let ((d (cal-tex-incr-date date
3)))
1142 (if (= (extract-calendar-month date
)
1143 (extract-calendar-month d
))
1145 (calendar-month-name
1146 (extract-calendar-month date
))
1147 (extract-calendar-year date
))
1148 (if (= (extract-calendar-year date
)
1149 (extract-calendar-year d
))
1150 (format "%s---%s %s"
1151 (calendar-month-name
1152 (extract-calendar-month date
))
1153 (calendar-month-name
1154 (extract-calendar-month d
))
1155 (extract-calendar-year date
))
1156 (format "%s %s---%s %s"
1157 (calendar-month-name
1158 (extract-calendar-month date
))
1159 (extract-calendar-year date
)
1160 (calendar-month-name (extract-calendar-month d
))
1161 (extract-calendar-year d
))))))
1163 (calendar-for-loop j from
1 to
2 do
1164 (insert "\\rightday")
1165 (cal-tex-arg (calendar-day-name date
))
1166 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1167 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1168 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1169 (cal-tex-arg (eval cal-tex-daily-string
))
1171 (setq date
(cal-tex-incr-date date
)))
1172 (calendar-for-loop j from
1 to
2 do
1173 (insert "\\weekend")
1174 (cal-tex-arg (calendar-day-name date
))
1175 (cal-tex-arg (int-to-string (extract-calendar-day date
)))
1176 (cal-tex-arg (cal-tex-latexify-list diary-list date
))
1177 (cal-tex-arg (cal-tex-latexify-list holidays date
))
1178 (cal-tex-arg (eval cal-tex-daily-string
))
1180 (setq date
(cal-tex-incr-date date
)))
1183 (run-hooks 'cal-tex-week-hook
)
1184 (cal-tex-newpage))))
1185 (cal-tex-end-document)
1186 (run-hooks 'cal-tex-hook
)))
1191 (defun cal-tex-cursor-day (&optional arg
)
1192 "Make a buffer with LaTeX commands for the day cursor is on.
1193 Optional prefix argument specifies number of days."
1195 (let ((n (if arg arg
1))
1196 (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t
))))
1197 (cal-tex-preamble "12pt")
1198 (cal-tex-cmd "\\textwidth 6.5in")
1199 (cal-tex-cmd "\\textheight 10.5in")
1200 (cal-tex-b-document)
1201 (cal-tex-cmd "\\pagestyle{empty}")
1202 (calendar-for-loop i from
1 to n do
1203 (cal-tex-vspace "-1.7in")
1204 (cal-tex-daily-page (calendar-gregorian-from-absolute date
))
1205 (setq date
(1+ date
))
1209 (run-hooks 'cal-tex-daily-hook
))))
1210 (cal-tex-end-document)
1211 (run-hooks 'cal-tex-hook
)))
1213 (defun cal-tex-daily-page (date)
1214 "Make a calendar page for Gregorian DATE on 8.5 by 11 paper."
1216 (month-name (calendar-month-name (extract-calendar-month date
))))
1217 (cal-tex-banner "cal-tex-daily-page")
1218 (cal-tex-b-makebox "4cm" "l")
1219 (cal-tex-b-parbox "b" "3.8cm")
1220 (cal-tex-rule "0mm" "0mm" "2cm")
1221 (cal-tex-Huge (number-to-string (extract-calendar-day date
)))
1223 (cal-tex-bf month-name
)
1225 (cal-tex-hspace "1cm")
1226 (cal-tex-scriptsize (eval cal-tex-daily-string
))
1227 (cal-tex-hspace "3.5cm")
1230 (cal-tex-b-makebox "4cm" "r")
1231 (cal-tex-bf (calendar-day-name date
))
1234 (cal-tex-hspace ".4cm")
1235 (cal-tex-rule "0mm" "16.1cm" "1mm")
1237 (calendar-for-loop i from cal-tex-daily-start to cal-tex-daily-end do
1238 (cal-tex-cmd "\\noindent")
1239 (setq hour
(if cal-tex-24
1242 (if (= 0 hour
) (setq hour
12))
1243 (cal-tex-b-makebox "1cm" "c")
1244 (cal-tex-arg (number-to-string hour
))
1246 (cal-tex-rule "0mm" "15.5cm" ".2mm")
1248 (cal-tex-b-makebox "1cm" "c")
1249 (cal-tex-arg "$\\diamond$" )
1251 (cal-tex-rule "0mm" "15.5cm" ".2mm")
1252 (cal-tex-nl ".2cm"))
1254 (insert (cal-tex-mini-calendar
1255 (extract-calendar-month (cal-tex-previous-month date
))
1256 (extract-calendar-year (cal-tex-previous-month date
))
1257 "lastmonth" "1.1in" "1in"))
1258 (insert (cal-tex-mini-calendar
1259 (extract-calendar-month date
)
1260 (extract-calendar-year date
)
1261 "thismonth" "1.1in" "1in"))
1262 (insert (cal-tex-mini-calendar
1263 (extract-calendar-month (cal-tex-next-month date
))
1264 (extract-calendar-year (cal-tex-next-month date
))
1265 "nextmonth" "1.1in" "1in"))
1266 (insert "\\hbox to \\textwidth{")
1268 (insert "\\lastmonth")
1270 (insert "\\thismonth")
1272 (insert "\\nextmonth")
1275 (cal-tex-banner "end of cal-tex-daily-page")))
1281 (defun cal-tex-mini-calendar (month year name width height
&optional ptsize colsep
)
1282 "Produce mini-calendar for MONTH, YEAR in macro NAME with WIDTH and HEIGHT.
1283 Optional PTSIZE gives the point ptsize; scriptsize is the default. Optional
1284 COLSEP gives the column separation; 1mm is the default."
1285 (let* ((blank-days;; at start of month
1287 (- (calendar-day-of-week (list month
1 year
))
1288 calendar-week-start-day
)
1290 (last (calendar-last-day-of-month month year
))
1291 (colsep (if colsep colsep
"1mm"))
1292 (str (concat "\\def\\" name
"{\\hbox to" width
"{%\n"
1293 "\\vbox to" height
"{%\n"
1294 "\\vfil \\hbox to" width
"{%\n"
1296 (if ptsize ptsize
"scriptsize")
1298 "{@{\\hspace{0mm}}r@{\\hspace{" colsep
1299 "}}r@{\\hspace{" colsep
"}}r@{\\hspace{" colsep
1300 "}}r@{\\hspace{" colsep
"}}r@{\\hspace{" colsep
1301 "}}r@{\\hspace{" colsep
"}}r@{\\hspace{0mm}}}%\n"
1302 "\\multicolumn{7}{c}{"
1303 (calendar-month-name month
)
1305 (int-to-string year
)
1307 (calendar-for-loop i from
0 to
6 do
1308 (setq str
(concat str
1309 (substring (aref calendar-day-name-array
1310 (mod (+ calendar-week-start-day i
) 7))
1315 (calendar-for-loop i from
1 to blank-days do
1316 (setq str
(concat str
" & ")))
1317 (calendar-for-loop i from
1 to last do
1318 (setq str
(concat str
(int-to-string i
)))
1319 (setq str
(concat str
(if (zerop (mod (+ i blank-days
) 7))
1320 (if (/= i last
) "\\\\[0.5mm]\n" "")
1322 (setq str
(concat str
"\n\\end{tabular}\\hfil}\\vfil}}}%\n"))
1326 ;;; Various calendar functions
1329 (defun cal-tex-incr-date (date &optional n
)
1330 "The date of the day following DATE.
1331 If optional N is given, the date of N days after DATE."
1332 (calendar-gregorian-from-absolute
1333 (+ (if n n
1) (calendar-absolute-from-gregorian date
))))
1335 (defun cal-tex-latexify-list (date-list date
&optional separator
)
1336 "Return string with concatenated, LaTeXified entries in DATE_LIST for DATE.
1337 Use double backslash as a separator unless optional SEPARATOR is given."
1338 (mapconcat '(lambda (x) (cal-tex-LaTeXify-string x
))
1343 (calendar-date-equal date
(car (car p
)))
1344 (setq result
(append (cdr (car p
)) result
)))
1347 (if separator separator
"\\\\")))
1349 (defun cal-tex-previous-month (date)
1350 "Return the date of the first day in the month previous to DATE."
1351 (let* ((month (extract-calendar-month date
))
1352 (year (extract-calendar-year date
)))
1353 (increment-calendar-month month year -
1)
1354 (list month
1 year
)))
1356 (defun cal-tex-next-month (date)
1357 "Return the date of the first day in the month following DATE."
1358 (let* ((month (extract-calendar-month date
))
1359 (year (extract-calendar-year date
)))
1360 (increment-calendar-month month year
1)
1361 (list month
1 year
)))
1367 (defun cal-tex-end-document ()
1368 "Finish the LaTeX document.
1369 Insert the trailer to LaTeX document, pop to LaTeX buffer, add
1370 informative header, and run HOOK."
1371 (cal-tex-e-document)
1373 (pop-to-buffer cal-tex-buffer
)
1374 (goto-char (point-min))
1375 (cal-tex-comment " This buffer was produced by cal-tex.el.")
1376 (cal-tex-comment " To print a calendar, type")
1377 (cal-tex-comment " M-x tex-buffer RET")
1378 (cal-tex-comment " M-x tex-print RET")
1379 (goto-char (point-min)))
1381 (defun cal-tex-insert-preamble (weeks landscape size
&optional append
)
1382 "Initialize the output buffer.
1383 Select the output buffer, and insert the preamble for a calendar of
1384 WEEKS weeks. Insert code for landscape mode if LANDSCAPE is true.
1385 Use pointsize SIZE. Optional argument APPEND, if t, means add to end of
1386 without erasing current contents."
1387 (let ((width "18cm")
1392 (setq height
"18cm")))
1395 (cal-tex-preamble size
)
1398 (cal-tex-cmd "\\oddsidemargin -1.75cm")
1399 (cal-tex-cmd "\\def\\holidaymult{.06}"))
1400 (cal-tex-cmd "\\special{landscape}")
1401 (cal-tex-cmd "\\textwidth 9.5in")
1402 (cal-tex-cmd "\\textheight 7in")
1404 (cal-tex-cmd "\\def\\holidaymult{.08}"))
1405 (cal-tex-cmd cal-tex-caldate
)
1406 (cal-tex-cmd cal-tex-myday
)
1407 (cal-tex-b-document)
1408 (cal-tex-cmd "\\pagestyle{empty}")))
1409 (cal-tex-cmd "\\setlength{\\cellwidth}" width
)
1410 (insert (format "\\setlength{\\cellwidth}{%f\\cellwidth}\n"
1411 (/ 1.1 (length cal-tex-which-days
))))
1412 (cal-tex-cmd "\\setlength{\\cellheight}" height
)
1413 (insert (format "\\setlength{\\cellheight}{%f\\cellheight}\n"
1415 (cal-tex-cmd "\\ \\par")
1416 (cal-tex-vspace "-3cm")))
1418 (defvar cal-tex-LaTeX-subst-list
1420 ("\"".
"''");; Quote changes meaning when list is reversed.
1431 ("\n" .
"\\ \\\\")) ;\\ needed for e.g \begin{center}\n AA\end{center}
1432 "List of symbols and their replacements.")
1434 (defun cal-tex-LaTeXify-string (string)
1435 "Protect special characters in STRING from LaTeX."
1440 (list cal-tex-LaTeX-subst-list
))
1441 (while (not (string-equal tail
""))
1442 (let* ((ch (substring tail
0 1))
1443 (pair (assoc ch list
)))
1444 (if (and pair
(string-equal ch
"\""))
1445 (setq list
(reverse list
)));; Quote changes meaning each time.
1446 (setq tail
(substring tail
1))
1447 (setq head
(concat head
(if pair
(cdr pair
) ch
)))))
1450 (defun cal-tex-hfill () "Insert hfill." (insert "\\hfill"))
1452 (defun cal-tex-newpage () "Insert newpage." (insert "\\newpage%\n"))
1454 (defun cal-tex-noindent () "Insert noindent." (insert "\\noindent"))
1456 (defun cal-tex-vspace (space)
1457 "Insert vspace command to move SPACE vertically."
1458 (insert "\\vspace*{" space
"}")
1461 (defun cal-tex-hspace (space)
1462 "Insert hspace command to move SPACE horizontally."
1463 (insert "\\hspace*{" space
"}")
1466 (defun cal-tex-comment (&optional comment
)
1467 "Insert % at end of line, include COMMENT if present, and move
1474 (defun cal-tex-banner (comment)
1475 "Insert the COMMENT separated by blank lines."
1478 (cal-tex-comment (concat "\t\t\t" comment
))
1482 (defun cal-tex-nl (&optional skip comment
)
1483 "End a line with \\. If SKIP, then add that much spacing.
1484 Add COMMENT if present"
1487 (insert "[" skip
"]"))
1488 (cal-tex-comment comment
))
1490 (defun cal-tex-arg (&optional text
)
1491 "Insert optional TEXT surrounded by braces."
1493 (if text
(insert text
))
1496 (defun cal-tex-cmd (cmd &optional arg
)
1497 "Insert LaTeX CMD, with optional ARG, and end with %"
1506 (defun cal-tex-b-document ()
1507 "Insert beginning of document."
1508 (cal-tex-cmd "\\begin{document}"))
1510 (defun cal-tex-e-document ()
1511 "Insert end of document."
1512 (cal-tex-cmd "\\end{document}"))
1514 (defun cal-tex-b-center ()
1515 "Insert beginning of centered block."
1516 (cal-tex-cmd "\\begin{center}"))
1518 (defun cal-tex-e-center ()
1519 "Insert end of centered block."
1521 (cal-tex-cmd "\\end{center}"))
1529 (defun cal-tex-b-parbox (position width
)
1530 "Insert parbox with parameters POSITION and WIDTH."
1531 (insert "\\parbox[" position
"]{" width
"}{")
1534 (defun cal-tex-e-parbox (&optional height
)
1535 "Insert end of parbox. Force it to be a given HEIGHT."
1538 (cal-tex-rule "0mm" "0mm" height
))
1540 (cal-tex-comment "end parbox"))
1542 (defun cal-tex-b-framebox ( width position
)
1543 "Insert framebox with parameters WIDTH and POSITION (clr)."
1544 (insert "\\framebox[" width
"][" position
"]{" )
1547 (defun cal-tex-e-framebox ()
1548 "Insert end of framebox."
1551 (cal-tex-comment "end framebox"))
1554 (defun cal-tex-b-makebox ( width position
)
1555 "Insert makebox with parameters WIDTH and POSITION (clr)."
1556 (insert "\\makebox[" width
"][" position
"]{" )
1559 (defun cal-tex-e-makebox ()
1560 "Insert end of makebox."
1563 (cal-tex-comment "end makebox"))
1566 (defun cal-tex-rule (lower width height
)
1567 "Insert a rule with parameters LOWER WIDTH HEIGHT."
1568 (insert "\\rule[" lower
"]{" width
"}{" height
"}"))
1574 (defun cal-tex-em (string)
1575 "Insert STRING in bf font."
1576 (insert "{\\em " string
"}"))
1578 (defun cal-tex-bf (string)
1579 "Insert STRING in bf font."
1580 (insert "{\\bf " string
"}"))
1582 (defun cal-tex-scriptsize (string)
1583 "Insert STRING in scriptsize font."
1584 (insert "{\\scriptsize " string
"}"))
1586 (defun cal-tex-huge (string)
1587 "Insert STRING in huge size."
1588 (insert "{\\huge " string
"}"))
1590 (defun cal-tex-Huge (string)
1591 "Insert STRING in Huge size."
1592 (insert "{\\Huge " string
"}"))
1594 (defun cal-tex-Huge-bf (string)
1595 "Insert STRING in Huge bf size."
1596 (insert "{\\Huge\\bf " string
"}"))
1598 (defun cal-tex-large (string)
1599 "Insert STRING in large size."
1600 (insert "{\\large " string
"}"))
1602 (defun cal-tex-large-bf (string)
1603 "Insert STRING in large bf size."
1604 (insert "{\\large\\bf " string
"}"))
1608 ;;; cal-tex.el ends here