]> code.delx.au - gnu-emacs/blob - lisp/calendar/cal-tex.el
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
[gnu-emacs] / lisp / calendar / cal-tex.el
1 ;;; cal-tex.el --- calendar functions for printing calendars with LaTeX.
2
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4
5 ;; Author: Steve Fisk <fisk@bowdoin.edu>
6 ;; Edward M. Reingold <reingold@cs.uiuc.edu>
7 ;; Keywords: calendar
8 ;; Human-Keywords: Calendar, LaTeX
9
10 ;; This file is part of GNU Emacs.
11
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)
15 ;; any later version.
16
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.
21
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.
26
27 ;;; Commentary:
28
29 ;; This collection of functions implements the creation of LaTeX calendars
30 ;; based on the user's holiday choices and diary file.
31
32 ;; TO DO
33 ;;
34 ;; (*) Add holidays and diary entries to daily calendar.
35 ;;
36 ;; (*) Add diary entries to weekly calendar functions.
37 ;;
38 ;; (*) Make calendar styles for A4 paper.
39 ;;
40 ;; (*) Make monthly styles Filofax paper.
41
42 ;;; Code:
43
44 (require 'calendar)
45
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)
49
50 ;;;
51 ;;; Customizable variables
52 ;;;
53
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
58
59 (setq cal-tex-which-days '(1 3 5))
60
61 to only print Monday, Wednesday, Friday."
62 :type '(repeat integer)
63 :group 'calendar-tex)
64
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."
68 :type 'boolean
69 :group 'calendar-tex)
70
71 (defcustom cal-tex-diary nil
72 "*If t, the diary entries are printed in the calendar."
73 :type 'boolean
74 :group 'calendar-tex)
75
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.
85
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
88
89 '(progn
90 (require 'cal-hebrew)
91 (calendar-hebrew-date-string date))
92
93 will put the Hebrew date at the bottom of each day."
94 :type 'sexp
95 :group 'calendar-tex)
96
97 (defcustom cal-tex-buffer "calendar.tex"
98 "*The name for the tex-ed calendar."
99 :type 'string
100 :group 'calendar-tex)
101
102 (defcustom cal-tex-24 nil
103 "*If t, use a 24 hour clock in the daily calendar."
104 :type 'boolean
105 :group 'calendar-tex)
106
107 (defcustom cal-tex-daily-start 8
108 "*The first hour of the daily calendar page."
109 :type 'integer
110 :group 'calendar-tex)
111
112 (defcustom cal-tex-daily-end 20
113 "*The last hour of the daily calendar page."
114 :type 'integer
115 :group 'calendar-tex)
116
117 ;;;
118 ;;; Definitions for LaTeX code
119 ;;;
120
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.")
124
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.")
128
129 (defvar cal-tex-cal-one-month
130 "\\def\\calmonth#1#2%
131 {\\begin{center}%
132 \\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]%
133 \\end{center}}%
134 \\vspace*{-1.5cm}%
135 %
136 "
137 "LaTeX code for the month header")
138
139 (defvar cal-tex-cal-multi-month
140 "\\def\\calmonth#1#2#3#4%
141 {\\begin{center}%
142 \\Huge\\bf #1 #2---#3 #4\\\\[1cm]%
143 \\end{center}}%
144 \\vspace*{-1.5cm}%
145 %
146 "
147 "LaTeX code for the month header")
148
149 (defvar cal-tex-myday
150 "\\renewcommand{\\myday}[1]%
151 {\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}}
152 %
153 "
154 "LaTeX code for a day heading")
155
156 (defvar cal-tex-caldate
157 "\\fboxsep=0pt
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}}
167 \\hspace*{1mm}%
168 \\hbox to\\cellwidth{#6}%
169 \\vfill%
170 \\hbox to\\cellwidth{\\hfill \\tiny #5 \\hfill}%
171 \\vskip 1.4pt}%
172 \\hskip -0.4pt}}}
173 "
174 "LaTeX code to insert one box with date info in calendar.
175 This definition is the heart of the calendar!")
176
177 (defun cal-tex-list-holidays (d1 d2)
178 "Generate a list of all holidays from absolute date D1 to D2."
179 (let* ((start (calendar-gregorian-from-absolute d1))
180 (displayed-month (extract-calendar-month start))
181 (displayed-year (extract-calendar-year start))
182 (end (calendar-gregorian-from-absolute d2))
183 (end-month (extract-calendar-month end))
184 (end-year (extract-calendar-year end))
185 (number-of-intervals
186 (1+ (/ (calendar-interval displayed-month displayed-year
187 end-month end-year)
188 3)))
189 (holidays nil)
190 (in-range))
191 (increment-calendar-month displayed-month displayed-year 1)
192 (calendar-for-loop i from 1 to number-of-intervals do
193 (setq holidays (append holidays (calendar-holiday-list)))
194 (increment-calendar-month displayed-month displayed-year 3))
195 (while holidays
196 (and (car (car holidays))
197 (let ((a (calendar-absolute-from-gregorian (car (car holidays)))))
198 (and (<= d1 a) (<= a d2)))
199 (setq in-range (append (list (car holidays)) in-range)))
200 (setq holidays (cdr holidays)))
201 in-range))
202
203 (defun cal-tex-list-diary-entries (d1 d2)
204 "Generate a list of all diary-entries from absolute date D1 to D2."
205 (let ((diary-list-include-blanks nil)
206 (diary-display-hook nil))
207 (list-diary-entries
208 (calendar-gregorian-from-absolute d1)
209 (1+ (- d2 d1)))))
210
211 (defun cal-tex-preamble (&optional args)
212 "Insert the LaTeX preamble.
213 Preamble Includes initial definitions for various LaTeX commands.
214 Optional ARGS are included."
215 (set-buffer (get-buffer-create cal-tex-buffer))
216 (erase-buffer)
217 (insert "\\documentstyle")
218 (if args
219 (insert "[" args "]"))
220 (insert "{article}\n"
221 "\\hbadness 20000
222 \\hfuzz=1000pt
223 \\vbadness 20000
224 \\lineskip 0pt
225 \\marginparwidth 0pt
226 \\oddsidemargin -2cm
227 \\evensidemargin -2cm
228 \\marginparsep 0pt
229 \\topmargin 0pt
230 \\textwidth 7.5in
231 \\textheight 9.5in
232 \\newlength{\\cellwidth}
233 \\newlength{\\cellheight}
234 \\newlength{\\boxwidth}
235 \\newlength{\\boxheight}
236 \\newlength{\\cellsize}
237 \\newcommand{\\myday}[1]{}
238 \\newcommand{\\caldate}[6]{}
239 \\newcommand{\\nocaldate}[6]{}
240 \\newcommand{\\calsmall}[6]{}
241 %
242 "))
243
244 ;;;
245 ;;; Yearly calendars
246 ;;;
247
248 (defun cal-tex-cursor-year (&optional arg)
249 "Make a buffer with LaTeX commands for the year cursor is on.
250 Optional prefix argument specifies number of years."
251 (interactive "P")
252 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t))
253 (if arg arg 1)))
254
255 (defun cal-tex-cursor-year-landscape (&optional arg)
256 "Make a buffer with LaTeX commands for the year cursor is on.
257 Optional prefix argument specifies number of years."
258 (interactive "P")
259 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t))
260 (if arg arg 1)
261 t))
262
263 (defun cal-tex-year (year n &optional landscape)
264 "Make a one page yearly calendar of YEAR; do this for N years.
265 There are four rows of three months each, unless optional LANDSCAPE is t,
266 in which case the calendar isprinted in landscape mode with three rows of
267 four months each."
268 (cal-tex-insert-preamble 1 landscape "12pt")
269 (if landscape
270 (cal-tex-vspace "-.6cm")
271 (cal-tex-vspace "-3.1cm"))
272 (calendar-for-loop j from 1 to n do
273 (insert "\\vfill%\n")
274 (cal-tex-b-center)
275 (cal-tex-Huge (number-to-string year))
276 (cal-tex-e-center)
277 (cal-tex-vspace "1cm")
278 (cal-tex-b-center)
279 (cal-tex-b-parbox "l" (if landscape "5.9in" "4.3in"))
280 (insert "\n")
281 (cal-tex-noindent)
282 (cal-tex-nl)
283 (calendar-for-loop i from 1 to 12 do
284 (insert (cal-tex-mini-calendar i year "month" "1.1in" "1in"))
285 (insert "\\month")
286 (cal-tex-hspace "0.5in")
287 (if (zerop (mod i (if landscape 4 3)))
288 (cal-tex-nl "0.5in")))
289 (cal-tex-e-parbox)
290 (cal-tex-e-center)
291 (insert "\\vfill%\n")
292 (setq year (1+ year))
293 (if (/= j n)
294 (cal-tex-newpage)
295 (cal-tex-end-document))
296 (run-hooks 'cal-tex-year-hook))
297 (run-hooks 'cal-tex-hook))
298
299 (defun cal-tex-cursor-filofax-year (&optional arg)
300 "Make a Filofax one page yearly calendar of year indicated by cursor.
301 Optional parameter specifies number of years."
302 (interactive "P")
303 (let* ((n (if arg arg 1))
304 (year (extract-calendar-year (calendar-cursor-to-date t))))
305 (cal-tex-preamble "twoside")
306 (cal-tex-cmd "\\textwidth 3.25in")
307 (cal-tex-cmd "\\textheight 6.5in")
308 (cal-tex-cmd "\\oddsidemargin 1.675in")
309 (cal-tex-cmd "\\evensidemargin 1.675in")
310 (cal-tex-cmd "\\topmargin 0pt")
311 (cal-tex-cmd "\\headheight -0.875in")
312 (cal-tex-cmd "\\fboxsep 0.5mm")
313 (cal-tex-cmd "\\pagestyle{empty}")
314 (cal-tex-b-document)
315 (cal-tex-cmd "\\vspace*{0.25in}")
316 (calendar-for-loop j from 1 to n do
317 (insert (format "\\hfil {\\Large \\bf %s} \\hfil\\\\\n" year))
318 (cal-tex-b-center)
319 (cal-tex-b-parbox "l" "\\textwidth")
320 (insert "\n")
321 (cal-tex-noindent)
322 (cal-tex-nl)
323 (calendar-for-loop i from 1 to 12 do
324 (insert (cal-tex-mini-calendar i year
325 (calendar-month-name i)
326 "1in" ".9in" "tiny" "0.6mm")))
327 (insert
328 "\\noindent\\fbox{\\January}\\fbox{\\February}\\fbox{\\March}\\\\
329 \\noindent\\fbox{\\April}\\fbox{\\May}\\fbox{\\June}\\\\
330 \\noindent\\fbox{\\July}\\fbox{\\August}\\fbox{\\September}\\\\
331 \\noindent\\fbox{\\October}\\fbox{\\November}\\fbox{\\December}
332 ")
333 (cal-tex-e-parbox)
334 (cal-tex-e-center)
335 (setq year (1+ year))
336 (if (= j n)
337 (cal-tex-end-document)
338 (cal-tex-newpage)
339 (cal-tex-cmd "\\vspace*{0.25in}"))
340 (run-hooks 'cal-tex-year-hook))
341 (run-hooks 'cal-tex-hook)))
342
343 ;;;
344 ;;; Monthly calendars
345 ;;;
346
347 (defun cal-tex-cursor-month-landscape (&optional arg)
348 "Make a buffer with LaTeX commands for the month cursor is on.
349 Optional prefix argument specifies number of months to be produced.
350 The output is in landscape format, one month to a page."
351 (interactive "P")
352 (let* ((n (if arg arg 1))
353 (date (calendar-cursor-to-date t))
354 (month (extract-calendar-month date))
355 (year (extract-calendar-year date))
356 (end-month month)
357 (end-year year)
358 (cal-tex-which-days '(0 1 2 3 4 5 6)))
359 (increment-calendar-month end-month end-year (1- n))
360 (let ((diary-list (if cal-tex-diary
361 (cal-tex-list-diary-entries
362 (calendar-absolute-from-gregorian
363 (list month 1 year))
364 (calendar-absolute-from-gregorian
365 (list end-month
366 (calendar-last-day-of-month
367 end-month end-year)
368 end-year)))))
369 (holidays (if cal-tex-holidays
370 (cal-tex-list-holidays
371 (calendar-absolute-from-gregorian
372 (list month 1 year))
373 (calendar-absolute-from-gregorian
374 (list end-month
375 (calendar-last-day-of-month end-month end-year)
376 end-year)))))
377 (other-month)
378 (other-year)
379 (small-months-at-start))
380 (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt")
381 (cal-tex-cmd cal-tex-cal-one-month)
382 (calendar-for-loop i from 1 to n do
383 (setq other-month month)
384 (setq other-year year)
385 (increment-calendar-month other-month other-year -1)
386 (insert (cal-tex-mini-calendar other-month other-year "lastmonth"
387 "\\cellwidth" "\\cellheight"))
388 (increment-calendar-month other-month other-year 2)
389 (insert (cal-tex-mini-calendar other-month other-year "nextmonth"
390 "\\cellwidth" "\\cellheight"))
391 (cal-tex-insert-month-header 1 month year month year)
392 (cal-tex-insert-day-names)
393 (cal-tex-nl ".2cm")
394 (setq small-months-at-start
395 (< 1 (mod (- (calendar-day-of-week (list month 1 year))
396 calendar-week-start-day)
397 7)))
398 (if small-months-at-start
399 (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}"))
400 (cal-tex-insert-blank-days month year cal-tex-day-prefix)
401 (cal-tex-insert-days month year diary-list holidays
402 cal-tex-day-prefix)
403 (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix)
404 (if (and (not small-months-at-start)
405 (< 1 (mod (- (1- calendar-week-start-day)
406 (calendar-day-of-week
407 (list month
408 (calendar-last-day-of-month month year)
409 year)))
410 7)))
411 (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}"
412 "\\lastmonth\\nextmonth"))
413 (if (/= i n)
414 (progn
415 (run-hooks 'cal-tex-month-hook)
416 (cal-tex-newpage)
417 (increment-calendar-month month year 1)
418 (cal-tex-vspace "-2cm")
419 (cal-tex-insert-preamble
420 (cal-tex-number-weeks month year 1) t "12pt" t))))
421 (cal-tex-end-document)
422 (run-hooks 'cal-tex-hook))))
423
424 (defun cal-tex-cursor-month (arg)
425 "Make a buffer with LaTeX commands for the month cursor is on.
426 Optional prefix argument specifies number of months to be produced.
427 Calendar is condensed onto one page."
428 (interactive "P")
429 (let* ((date (calendar-cursor-to-date t))
430 (month (extract-calendar-month date))
431 (year (extract-calendar-year date))
432 (end-month month)
433 (end-year year)
434 (n (if arg arg 1)))
435 (increment-calendar-month end-month end-year (1- n))
436 (let ((diary-list (if cal-tex-diary
437 (cal-tex-list-diary-entries
438 (calendar-absolute-from-gregorian
439 (list month 1 year))
440 (calendar-absolute-from-gregorian
441 (list end-month
442 (calendar-last-day-of-month
443 end-month end-year)
444 end-year)))))
445 (holidays (if cal-tex-holidays
446 (cal-tex-list-holidays
447 (calendar-absolute-from-gregorian
448 (list month 1 year))
449 (calendar-absolute-from-gregorian
450 (list end-month
451 (calendar-last-day-of-month end-month end-year)
452 end-year)))))
453 (other-month)
454 (other-year))
455 (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil"12pt")
456 (if (> n 1)
457 (cal-tex-cmd cal-tex-cal-multi-month)
458 (cal-tex-cmd cal-tex-cal-one-month))
459 (cal-tex-insert-month-header n month year end-month end-year)
460 (cal-tex-insert-day-names)
461 (cal-tex-nl ".2cm")
462 (cal-tex-insert-blank-days month year cal-tex-day-prefix)
463 (calendar-for-loop i from 1 to n do
464 (setq other-month month)
465 (setq other-year year)
466 (cal-tex-insert-days month year diary-list holidays
467 cal-tex-day-prefix)
468 (increment-calendar-month month year 1))
469 (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix)
470 (cal-tex-end-document)))
471 (run-hooks 'cal-tex-hook))
472
473 (defun cal-tex-insert-days (month year diary-list holidays day-format)
474 "Insert LaTeX commands for a range of days in monthly calendars.
475 LaTeX commands are inserted for the days of the MONTH in YEAR.
476 Diary entries on DIARY-LIST are included. Holidays on HOLIDAYS are included.
477 Each day is formatted using format DAY-FORMAT."
478 (let* ((blank-days;; at start of month
479 (mod
480 (- (calendar-day-of-week (list month 1 year))
481 calendar-week-start-day)
482 7))
483 (date)
484 (last (calendar-last-day-of-month month year)))
485 (calendar-for-loop i from 1 to last do
486 (setq date (list month i year))
487 (if (memq (calendar-day-of-week date) cal-tex-which-days)
488 (progn
489 (insert (format day-format (calendar-month-name month) i))
490 (cal-tex-arg (cal-tex-latexify-list diary-list date))
491 (cal-tex-arg (cal-tex-latexify-list holidays date))
492 (cal-tex-arg (eval cal-tex-daily-string))
493 (cal-tex-arg)
494 (cal-tex-comment)))
495 (if (and (zerop (mod (+ i blank-days) 7))
496 (/= i last))
497 (progn
498 (cal-tex-hfill)
499 (cal-tex-nl))))))
500
501 (defun cal-tex-insert-day-names ()
502 "Insert the names of the days at top of a monthly calendar."
503 (calendar-for-loop i from 0 to 6 do
504 (if (memq i cal-tex-which-days)
505 (insert (format cal-tex-day-name-format
506 (aref calendar-day-name-array
507 (mod (+ calendar-week-start-day i) 7)))))
508 (cal-tex-comment)))
509
510 (defun cal-tex-insert-month-header (n month year end-month end-year)
511 "Create a title for a calendar.
512 A title is inserted for a calendar with N months starting with
513 MONTH YEAR and ending with END-MONTH END-YEAR."
514 (let ( (month-name (calendar-month-name month))
515 (end-month-name (calendar-month-name end-month)))
516 (if (= 1 n)
517 (insert (format "\\calmonth{%s}{%s}\n\\vspace*{-0.5cm}"
518 month-name year) )
519 (insert (format "\\calmonth{%s}{%s}{%s}{%s}\n\\vspace*{-0.5cm}"
520 month-name year end-month-name end-year))))
521 (cal-tex-comment))
522
523 (defun cal-tex-insert-blank-days (month year day-format)
524 "Insert code for initial days not in calendar.
525 Insert LaTeX code for the blank days at the beginning of the MONTH in
526 YEAR. The entry is formatted using DAY-FORMAT. If the entire week is
527 blank, no days are inserted."
528 (if (cal-tex-first-blank-p month year)
529 (let* ((blank-days;; at start of month
530 (mod
531 (- (calendar-day-of-week (list month 1 year))
532 calendar-week-start-day)
533 7)))
534 (calendar-for-loop i from 0 to (1- blank-days) do
535 (if (memq i cal-tex-which-days)
536 (insert (format day-format " " " ") "{}{}{}{}%\n"))))))
537
538 (defun cal-tex-insert-blank-days-at-end (month year day-format)
539 "Insert code for final days not in calendar.
540 Insert LaTeX code for the blank days at the end of the MONTH in YEAR.
541 The entry is formatted using DAY-FORMAT."
542 (if (cal-tex-last-blank-p month year)
543 (let* ((last-day (calendar-last-day-of-month month year))
544 (blank-days;; at end of month
545 (mod
546 (- (calendar-day-of-week (list month last-day year))
547 calendar-week-start-day)
548 7)))
549 (calendar-for-loop i from (1+ blank-days) to 6 do
550 (if (memq i cal-tex-which-days)
551 (insert (format day-format "" "") "{}{}{}{}%\n"))))))
552
553 (defun cal-tex-first-blank-p (month year)
554 "Determine if any days of the first week will be printed.
555 Return t if there will there be any days of the first week printed
556 in the calendar starting in MONTH YEAR."
557 (let ((any-days nil)
558 (the-saturday)) ;the day of week of 1st Saturday
559 (calendar-for-loop i from 1 to 7 do
560 (if (= 6 (calendar-day-of-week (list month i year)))
561 (setq the-saturday i)))
562 (calendar-for-loop i from 1 to the-saturday do
563 (if (memq (calendar-day-of-week (list month i year))
564 cal-tex-which-days)
565 (setq any-days t)))
566 any-days))
567
568 (defun cal-tex-last-blank-p (month year)
569 "Determine if any days of the last week will be printed.
570 Return t if there will there be any days of the last week printed
571 in the calendar starting in MONTH YEAR."
572 (let ((any-days nil)
573 (last-day (calendar-last-day-of-month month year))
574 (the-sunday)) ;the day of week of last Sunday
575 (calendar-for-loop i from (- last-day 6) to last-day do
576 (if (= 0 (calendar-day-of-week (list month i year)))
577 (setq the-sunday i)))
578 (calendar-for-loop i from the-sunday to last-day do
579 (if (memq (calendar-day-of-week (list month i year))
580 cal-tex-which-days)
581 (setq any-days t)))
582 any-days))
583
584 (defun cal-tex-number-weeks (month year n)
585 "Determine the number of weeks in a range of dates.
586 Compute the number of weeks in the calendar starting with MONTH and YEAR,
587 and lasting N months, including only the days in WHICH-DAYS. As it stands,
588 this is only an upper bound."
589 (let ((d (list month 1 year)))
590 (increment-calendar-month month year (1- n))
591 (/ (- (calendar-dayname-on-or-before
592 calendar-week-start-day
593 (+ 7 (calendar-absolute-from-gregorian
594 (list month (calendar-last-day-of-month month year) year))))
595 (calendar-dayname-on-or-before
596 calendar-week-start-day
597 (calendar-absolute-from-gregorian d)))
598 7)))
599
600 ;;;
601 ;;; Weekly calendars
602 ;;;
603
604 (defun cal-tex-cursor-week (&optional arg)
605 "Make a buffer with LaTeX commands for a two-page one-week calendar.
606 It applies to the week that point is in.
607 Optional prefix argument specifies number of weeks.
608 Holidays are included if `cal-tex-holidays' is t."
609 (interactive "P")
610 (let* ((n (if arg arg 1))
611 (date (calendar-gregorian-from-absolute
612 (calendar-dayname-on-or-before
613 calendar-week-start-day
614 (calendar-absolute-from-gregorian
615 (calendar-cursor-to-date t)))))
616 (month (extract-calendar-month date))
617 (year (extract-calendar-year date))
618 (holidays (if cal-tex-holidays
619 (cal-tex-list-holidays
620 (calendar-absolute-from-gregorian date)
621 (+ (* 7 n)
622 (calendar-absolute-from-gregorian date))))))
623 (cal-tex-preamble "11pt")
624 (cal-tex-cmd "\\textwidth 6.5in")
625 (cal-tex-cmd "\\textheight 10.5in")
626 (cal-tex-cmd "\\oddsidemargin 0in")
627 (cal-tex-cmd "\\evensidemargin 0in")
628 (insert cal-tex-LaTeX-hourbox)
629 (cal-tex-b-document)
630 (cal-tex-cmd "\\pagestyle{empty}")
631 (calendar-for-loop i from 1 to n do
632 (cal-tex-vspace "-1.5in")
633 (cal-tex-b-center)
634 (cal-tex-Huge-bf (format "\\uppercase{%s}"
635 (calendar-month-name month)))
636 (cal-tex-hspace "2em")
637 (cal-tex-Huge-bf (number-to-string year))
638 (cal-tex-nl ".5cm")
639 (cal-tex-e-center)
640 (cal-tex-hspace "-.2in")
641 (cal-tex-b-parbox "l" "7in")
642 (calendar-for-loop j from 1 to 7 do
643 (cal-tex-week-hours date holidays "3.1")
644 (setq date (cal-tex-incr-date date)))
645 (cal-tex-e-parbox)
646 (setq month (extract-calendar-month date))
647 (setq year (extract-calendar-year date))
648 (if (/= i n)
649 (progn
650 (run-hooks 'cal-tex-week-hook)
651 (cal-tex-newpage))))
652 (cal-tex-end-document)
653 (run-hooks 'cal-tex-hook)))
654
655 (defun cal-tex-cursor-week2 (&optional arg)
656 "Make a buffer with LaTeX commands for a two-page one-week calendar.
657 It applies to the week that point is in.
658 Optional prefix argument specifies number of weeks.
659 Holidays are included if `cal-tex-holidays' is t."
660 (interactive "P")
661 (let* ((n (if arg arg 1))
662 (date (calendar-gregorian-from-absolute
663 (calendar-dayname-on-or-before
664 calendar-week-start-day
665 (calendar-absolute-from-gregorian
666 (calendar-cursor-to-date t)))))
667 (month (extract-calendar-month date))
668 (year (extract-calendar-year date))
669 (d date)
670 (holidays (if cal-tex-holidays
671 (cal-tex-list-holidays
672 (calendar-absolute-from-gregorian date)
673 (+ (* 7 n)
674 (calendar-absolute-from-gregorian date))))))
675 (cal-tex-preamble "12pt")
676 (cal-tex-cmd "\\textwidth 6.5in")
677 (cal-tex-cmd "\\textheight 10.5in")
678 (cal-tex-cmd "\\oddsidemargin 0in")
679 (cal-tex-cmd "\\evensidemargin 0in")
680 (insert cal-tex-LaTeX-hourbox)
681 (cal-tex-b-document)
682 (cal-tex-cmd "\\pagestyle{empty}")
683 (calendar-for-loop i from 1 to n do
684 (cal-tex-vspace "-1.5in")
685 (cal-tex-b-center)
686 (cal-tex-Huge-bf (format "\\uppercase{%s}"
687 (calendar-month-name month)))
688 (cal-tex-hspace "2em")
689 (cal-tex-Huge-bf (number-to-string year))
690 (cal-tex-nl ".5cm")
691 (cal-tex-e-center)
692 (cal-tex-hspace "-.2in")
693 (cal-tex-b-parbox "l" "\\textwidth")
694 (calendar-for-loop j from 1 to 3 do
695 (cal-tex-week-hours date holidays "5")
696 (setq date (cal-tex-incr-date date)))
697 (cal-tex-e-parbox)
698 (cal-tex-nl)
699 (insert (cal-tex-mini-calendar
700 (extract-calendar-month (cal-tex-previous-month date))
701 (extract-calendar-year (cal-tex-previous-month date))
702 "lastmonth" "1.1in" "1in"))
703 (insert (cal-tex-mini-calendar
704 (extract-calendar-month date)
705 (extract-calendar-year date)
706 "thismonth" "1.1in" "1in"))
707 (insert (cal-tex-mini-calendar
708 (extract-calendar-month (cal-tex-next-month date))
709 (extract-calendar-year (cal-tex-next-month date))
710 "nextmonth" "1.1in" "1in"))
711 (insert "\\hbox to \\textwidth{")
712 (cal-tex-hfill)
713 (insert "\\lastmonth")
714 (cal-tex-hfill)
715 (insert "\\thismonth")
716 (cal-tex-hfill)
717 (insert "\\nextmonth")
718 (cal-tex-hfill)
719 (insert "}")
720 (cal-tex-nl)
721 (cal-tex-b-parbox "l" "\\textwidth")
722 (calendar-for-loop j from 4 to 7 do
723 (cal-tex-week-hours date holidays "5")
724 (setq date (cal-tex-incr-date date)))
725 (cal-tex-e-parbox)
726 (setq month (extract-calendar-month date))
727 (setq year (extract-calendar-year date))
728 (if (/= i n)
729 (progn
730 (run-hooks 'cal-tex-week-hook)
731 (cal-tex-newpage))))
732 (cal-tex-end-document)
733 (run-hooks 'cal-tex-hook)))
734
735 (defun cal-tex-cursor-week-iso (&optional arg)
736 "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar.
737 Optional prefix argument specifies number of weeks.
738 Diary entries are included if `cal-tex-diary' is t.
739 Holidays are included if `cal-tex-holidays' is t."
740 (interactive "P")
741 (let* ((n (if arg arg 1))
742 (date (calendar-gregorian-from-absolute
743 (calendar-dayname-on-or-before
744 1
745 (calendar-absolute-from-gregorian
746 (calendar-cursor-to-date t)))))
747 (month (extract-calendar-month date))
748 (year (extract-calendar-year date))
749 (day (extract-calendar-day date))
750 (holidays (if cal-tex-holidays
751 (cal-tex-list-holidays
752 (calendar-absolute-from-gregorian date)
753 (+ (* 7 n)
754 (calendar-absolute-from-gregorian date)))))
755 (diary-list (if cal-tex-diary
756 (cal-tex-list-diary-entries
757 (calendar-absolute-from-gregorian
758 (list month 1 year))
759 (+ (* 7 n)
760 (calendar-absolute-from-gregorian date))))))
761 (cal-tex-preamble "11pt")
762 (cal-tex-cmd "\\textwidth 6.5in")
763 (cal-tex-cmd "\\textheight 10.5in")
764 (cal-tex-cmd "\\oddsidemargin 0in")
765 (cal-tex-cmd "\\evensidemargin 0in")
766 (cal-tex-b-document)
767 (cal-tex-cmd "\\pagestyle{empty}")
768 (calendar-for-loop i from 1 to n do
769 (cal-tex-vspace "-1.5in")
770 (cal-tex-b-center)
771 (cal-tex-Huge-bf
772 (let* ((d (calendar-iso-from-absolute
773 (calendar-absolute-from-gregorian date))))
774 (format "Week %d of %d"
775 (extract-calendar-month d)
776 (extract-calendar-year d))))
777 (cal-tex-nl ".5cm")
778 (cal-tex-e-center)
779 (cal-tex-b-parbox "l" "\\textwidth")
780 (calendar-for-loop j from 1 to 7 do
781 (cal-tex-b-parbox "t" "\\textwidth")
782 (cal-tex-b-parbox "t" "\\textwidth")
783 (cal-tex-rule "0pt" "\\textwidth" ".2mm")
784 (cal-tex-nl)
785 (cal-tex-b-parbox "t" "\\textwidth")
786 (cal-tex-large-bf (calendar-day-name date))
787 (insert ", ")
788 (cal-tex-large-bf (calendar-month-name month))
789 (insert " ")
790 (cal-tex-large-bf (number-to-string day))
791 (if (not (string= "" (cal-tex-latexify-list holidays date)))
792 (progn
793 (insert ": ")
794 (cal-tex-large-bf (cal-tex-latexify-list holidays date "; "))))
795 (cal-tex-hfill)
796 (insert " " (eval cal-tex-daily-string))
797 (cal-tex-e-parbox)
798 (cal-tex-nl)
799 (cal-tex-noindent)
800 (cal-tex-b-parbox "t" "\\textwidth")
801 (if (not (string= "" (cal-tex-latexify-list diary-list date)))
802 (progn
803 (insert "\\vbox to 0pt{")
804 (cal-tex-large-bf
805 (cal-tex-latexify-list diary-list date))
806 (insert "}")))
807 (cal-tex-e-parbox)
808 (cal-tex-nl)
809 (setq date (cal-tex-incr-date date))
810 (setq month (extract-calendar-month date))
811 (setq day (extract-calendar-day date))
812 (cal-tex-e-parbox)
813 (cal-tex-e-parbox "2cm")
814 (cal-tex-nl)
815 (setq month (extract-calendar-month date))
816 (setq year (extract-calendar-year date)))
817 (cal-tex-e-parbox)
818 (if (/= i n)
819 (progn
820 (run-hooks 'cal-tex-week-hook)
821 (cal-tex-newpage))))
822 (cal-tex-end-document)
823 (run-hooks 'cal-tex-hook)))
824
825 (defvar cal-tex-LaTeX-hourbox
826 "\\newcommand{\\hourbox}[2]%
827 {\\makebox[2em]{\\rule{0cm}{#2ex}#1}\\rule{3in}{.15mm}}\n"
828 "One hour and a line on the right.")
829
830 (defun cal-tex-week-hours (date holidays height)
831 "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT."
832 (let ((month (extract-calendar-month date))
833 (day (extract-calendar-day date))
834 (year (extract-calendar-year date))
835 (afternoon))
836 (cal-tex-comment "begin cal-tex-week-hours")
837 (cal-tex-cmd "\\ \\\\[-.2cm]")
838 (cal-tex-cmd "\\noindent")
839 (cal-tex-b-parbox "l" "6.8in")
840 (cal-tex-large-bf (calendar-day-name date))
841 (insert ", ")
842 (cal-tex-large-bf (calendar-month-name month))
843 (insert " ")
844 (cal-tex-large-bf (number-to-string day))
845 (if (not (string= "" (cal-tex-latexify-list holidays date)))
846 (progn
847 (insert ": ")
848 (cal-tex-large-bf (cal-tex-latexify-list holidays date "; "))))
849 (cal-tex-hfill)
850 (insert " " (eval cal-tex-daily-string))
851 (cal-tex-e-parbox)
852 (cal-tex-nl "-.3cm")
853 (cal-tex-rule "0pt" "6.8in" ".2mm")
854 (cal-tex-nl "-.1cm")
855 (calendar-for-loop i from 8 to 12 do
856 (if cal-tex-24
857 (setq afternoon (+ i 5))
858 (setq afternoon (- i 7)))
859 (cal-tex-cmd "\\hourbox" (number-to-string i))
860 (cal-tex-arg height)
861 (cal-tex-hspace ".4cm")
862 (cal-tex-cmd "\\hourbox" (number-to-string afternoon))
863 (cal-tex-arg height)
864 (cal-tex-nl))))
865
866 (defun cal-tex-cursor-week-monday (&optional arg)
867 "Make a buffer with LaTeX commands for a two-page one-week calendar.
868 It applies to the week that point is in, and starts on Monday.
869 Optional prefix argument specifies number of weeks.
870 Holidays are included if `cal-tex-holidays' is t."
871 (interactive "P")
872 (let* ((n (if arg arg 1))
873 (date (calendar-gregorian-from-absolute
874 (calendar-dayname-on-or-before
875 0
876 (calendar-absolute-from-gregorian
877 (calendar-cursor-to-date t))))))
878 (cal-tex-preamble "11pt")
879 (cal-tex-cmd "\\textwidth 6.5in")
880 (cal-tex-cmd "\\textheight 10.5in")
881 (cal-tex-cmd "\\oddsidemargin 0in")
882 (cal-tex-cmd "\\evensidemargin 0in")
883 (cal-tex-b-document)
884 (calendar-for-loop i from 1 to n do
885 (cal-tex-vspace "-1cm")
886 (insert "\\noindent ")
887 (cal-tex-weekly4-box (cal-tex-incr-date date) nil)
888 (cal-tex-weekly4-box (cal-tex-incr-date date 4) nil)
889 (cal-tex-nl ".2cm")
890 (cal-tex-weekly4-box (cal-tex-incr-date date 2) nil)
891 (cal-tex-weekly4-box (cal-tex-incr-date date 5) nil)
892 (cal-tex-nl ".2cm")
893 (cal-tex-weekly4-box (cal-tex-incr-date date 3) nil)
894 (cal-tex-weekly4-box (cal-tex-incr-date date 6) t)
895 (if (/= i n)
896 (progn
897 (run-hooks 'cal-tex-week-hook)
898 (setq date (cal-tex-incr-date date 7))
899 (cal-tex-newpage))))
900 (cal-tex-end-document)
901 (run-hooks 'cal-tex-hook)))
902
903 (defun cal-tex-weekly4-box (date weekend)
904 "Make one box for DATE, different if WEEKEND."
905 (let* (
906 (day (extract-calendar-day date))
907 (month (extract-calendar-month date))
908 (year (extract-calendar-year date))
909 (dayname (calendar-day-name date))
910 (date1 (cal-tex-incr-date date))
911 (day1 (extract-calendar-day date1))
912 (month1 (extract-calendar-month date1))
913 (year1 (extract-calendar-year date1))
914 (dayname1 (calendar-day-name date1))
915 )
916 (cal-tex-b-framebox "8cm" "l")
917 (cal-tex-b-parbox "b" "7.5cm")
918 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year))
919 (cal-tex-rule "0pt" "7.5cm" ".5mm")
920 (cal-tex-nl)
921 (if (not weekend)
922 (progn
923 (calendar-for-loop i from 8 to 12 do
924 (insert (format "{\\large\\sf %d}\\\\\n" i)))
925 (calendar-for-loop i from 1 to 5 do
926 (insert (format "{\\large\\sf %d}\\\\\n" i)))))
927 (cal-tex-nl ".5cm")
928 (if weekend
929 (progn
930 (cal-tex-vspace "1cm")
931 (insert "\\ \\vfill")
932 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n"
933 dayname1 month1 day1 year1))
934 (cal-tex-rule "0pt" "7.5cm" ".5mm")
935 (cal-tex-nl "1.5cm")
936 (cal-tex-vspace "1cm")))
937 (cal-tex-e-parbox)
938 (cal-tex-e-framebox)
939 (cal-tex-hspace "1cm")))
940
941 (defun cal-tex-cursor-filofax-2week (&optional arg)
942 "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor.
943 Optional prefix argument specifies number of weeks.
944 Diary entries are included if `cal-tex-diary' is t.
945 Holidays are included if `cal-tex-holidays' is t."
946 (interactive "P")
947 (let* ((n (if arg arg 1))
948 (date (calendar-gregorian-from-absolute
949 (calendar-dayname-on-or-before
950 calendar-week-start-day
951 (calendar-absolute-from-gregorian
952 (calendar-cursor-to-date t)))))
953 (month (extract-calendar-month date))
954 (year (extract-calendar-year date))
955 (day (extract-calendar-day date))
956 (holidays (if cal-tex-holidays
957 (cal-tex-list-holidays
958 (calendar-absolute-from-gregorian date)
959 (+ (* 7 n)
960 (calendar-absolute-from-gregorian date)))))
961 (diary-list (if cal-tex-diary
962 (cal-tex-list-diary-entries
963 (calendar-absolute-from-gregorian
964 (list month 1 year))
965 (+ (* 7 n)
966 (calendar-absolute-from-gregorian date))))))
967 (cal-tex-preamble "twoside")
968 (cal-tex-cmd "\\textwidth 3.25in")
969 (cal-tex-cmd "\\textheight 6.5in")
970 (cal-tex-cmd "\\oddsidemargin 1.75in")
971 (cal-tex-cmd "\\evensidemargin 1.5in")
972 (cal-tex-cmd "\\topmargin 0pt")
973 (cal-tex-cmd "\\headheight -0.875in")
974 (cal-tex-cmd "\\headsep 0.125in")
975 (cal-tex-cmd "\\footskip .125in")
976 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
977 \\long\\def\\rightday#1#2#3#4#5{%
978 \\rule{\\textwidth}{0.3pt}\\\\%
979 \\hbox to \\textwidth{%
980 \\vbox to 0.7in{%
981 \\vspace*{2pt}%
982 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
983 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
984 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
985 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
986 \\long\\def\\leftday#1#2#3#4#5{%
987 \\rule{\\textwidth}{0.3pt}\\\\%
988 \\hbox to \\textwidth{%
989 \\vbox to 0.7in{%
990 \\vspace*{2pt}%
991 \\hbox to \\textwidth{\\noindent {\\normalsize \\bf #2} \\small #1 \\hfill #5}%
992 \\hbox to \\textwidth{\\vbox {\\noindent \\footnotesize \\em #4}}%
993 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
994 ")
995 (cal-tex-b-document)
996 (cal-tex-cmd "\\pagestyle{empty}")
997 (calendar-for-loop i from 1 to n do
998 (if (= (mod i 2) 1)
999 (insert "\\righthead")
1000 (insert "\\lefthead"))
1001 (cal-tex-arg
1002 (let ((d (cal-tex-incr-date date 6)))
1003 (if (= (extract-calendar-month date)
1004 (extract-calendar-month d))
1005 (format "%s %s"
1006 (calendar-month-name
1007 (extract-calendar-month date))
1008 (extract-calendar-year date))
1009 (if (= (extract-calendar-year date)
1010 (extract-calendar-year d))
1011 (format "%s---%s %s"
1012 (calendar-month-name
1013 (extract-calendar-month date))
1014 (calendar-month-name
1015 (extract-calendar-month d))
1016 (extract-calendar-year date))
1017 (format "%s %s---%s %s"
1018 (calendar-month-name
1019 (extract-calendar-month date))
1020 (extract-calendar-year date)
1021 (calendar-month-name (extract-calendar-month d))
1022 (extract-calendar-year d))))))
1023 (insert "%\n")
1024 (calendar-for-loop j from 1 to 7 do
1025 (if (= (mod i 2) 1)
1026 (insert "\\rightday")
1027 (insert "\\leftday"))
1028 (cal-tex-arg (calendar-day-name date))
1029 (cal-tex-arg (int-to-string (extract-calendar-day date)))
1030 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1031 (cal-tex-arg (cal-tex-latexify-list holidays date))
1032 (cal-tex-arg (eval cal-tex-daily-string))
1033 (insert "%\n")
1034 (setq date (cal-tex-incr-date date)))
1035 (if (/= i n)
1036 (progn
1037 (run-hooks 'cal-tex-week-hook)
1038 (cal-tex-newpage))))
1039 (cal-tex-end-document)
1040 (run-hooks 'cal-tex-hook)))
1041
1042 (defun cal-tex-cursor-filofax-week (&optional arg)
1043 "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
1044 Optional prefix argument specifies number of weeks.
1045 Weeks start on Monday.
1046 Diary entries are included if `cal-tex-diary' is t.
1047 Holidays are included if `cal-tex-holidays' is t."
1048 (interactive "P")
1049 (let* ((n (if arg arg 1))
1050 (date (calendar-gregorian-from-absolute
1051 (calendar-dayname-on-or-before
1052 1
1053 (calendar-absolute-from-gregorian
1054 (calendar-cursor-to-date t)))))
1055 (month (extract-calendar-month date))
1056 (year (extract-calendar-year date))
1057 (day (extract-calendar-day date))
1058 (holidays (if cal-tex-holidays
1059 (cal-tex-list-holidays
1060 (calendar-absolute-from-gregorian date)
1061 (+ (* 7 n)
1062 (calendar-absolute-from-gregorian date)))))
1063 (diary-list (if cal-tex-diary
1064 (cal-tex-list-diary-entries
1065 (calendar-absolute-from-gregorian
1066 (list month 1 year))
1067 (+ (* 7 n)
1068 (calendar-absolute-from-gregorian date))))))
1069 (cal-tex-preamble "twoside")
1070 (cal-tex-cmd "\\textwidth 3.25in")
1071 (cal-tex-cmd "\\textheight 6.5in")
1072 (cal-tex-cmd "\\oddsidemargin 1.75in")
1073 (cal-tex-cmd "\\evensidemargin 1.5in")
1074 (cal-tex-cmd "\\topmargin 0pt")
1075 (cal-tex-cmd "\\headheight -0.875in")
1076 (cal-tex-cmd "\\headsep 0.125in")
1077 (cal-tex-cmd "\\footskip .125in")
1078 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
1079 \\long\\def\\rightday#1#2#3#4#5{%
1080 \\rule{\\textwidth}{0.3pt}\\\\%
1081 \\hbox to \\textwidth{%
1082 \\vbox to 1.85in{%
1083 \\vspace*{2pt}%
1084 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
1085 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
1086 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1087 \\long\\def\\weekend#1#2#3#4#5{%
1088 \\rule{\\textwidth}{0.3pt}\\\\%
1089 \\hbox to \\textwidth{%
1090 \\vbox to .8in{%
1091 \\vspace*{2pt}%
1092 \\hbox to \\textwidth{\\small #5 \\hfill #1 {\\normalsize \\bf #2}}%
1093 \\hbox to \\textwidth{\\vbox {\\raggedleft \\footnotesize \\em #4}}%
1094 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1095 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
1096 \\long\\def\\leftday#1#2#3#4#5{%
1097 \\rule{\\textwidth}{0.3pt}\\\\%
1098 \\hbox to \\textwidth{%
1099 \\vbox to 1.85in{%
1100 \\vspace*{2pt}%
1101 \\hbox to \\textwidth{\\noindent {\\normalsize \\bf #2} \\small #1 \\hfill #5}%
1102 \\hbox to \\textwidth{\\vbox {\\noindent \\footnotesize \\em #4}}%
1103 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #3}}}}\\\\}
1104 ")
1105 (cal-tex-b-document)
1106 (cal-tex-cmd "\\pagestyle{empty}\\ ")
1107 (cal-tex-newpage)
1108 (calendar-for-loop i from 1 to n do
1109 (insert "\\lefthead")
1110 (cal-tex-arg
1111 (let ((d (cal-tex-incr-date date 2)))
1112 (if (= (extract-calendar-month date)
1113 (extract-calendar-month d))
1114 (format "%s %s"
1115 (calendar-month-name
1116 (extract-calendar-month date))
1117 (extract-calendar-year date))
1118 (if (= (extract-calendar-year date)
1119 (extract-calendar-year d))
1120 (format "%s---%s %s"
1121 (calendar-month-name
1122 (extract-calendar-month date))
1123 (calendar-month-name
1124 (extract-calendar-month d))
1125 (extract-calendar-year date))
1126 (format "%s %s---%s %s"
1127 (calendar-month-name
1128 (extract-calendar-month date))
1129 (extract-calendar-year date)
1130 (calendar-month-name (extract-calendar-month d))
1131 (extract-calendar-year d))))))
1132 (insert "%\n")
1133 (calendar-for-loop j from 1 to 3 do
1134 (insert "\\leftday")
1135 (cal-tex-arg (calendar-day-name date))
1136 (cal-tex-arg (int-to-string (extract-calendar-day date)))
1137 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1138 (cal-tex-arg (cal-tex-latexify-list holidays date))
1139 (cal-tex-arg (eval cal-tex-daily-string))
1140 (insert "%\n")
1141 (setq date (cal-tex-incr-date date)))
1142 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")
1143 (cal-tex-newpage)
1144 (insert "\\righthead")
1145 (cal-tex-arg
1146 (let ((d (cal-tex-incr-date date 3)))
1147 (if (= (extract-calendar-month date)
1148 (extract-calendar-month d))
1149 (format "%s %s"
1150 (calendar-month-name
1151 (extract-calendar-month date))
1152 (extract-calendar-year date))
1153 (if (= (extract-calendar-year date)
1154 (extract-calendar-year d))
1155 (format "%s---%s %s"
1156 (calendar-month-name
1157 (extract-calendar-month date))
1158 (calendar-month-name
1159 (extract-calendar-month d))
1160 (extract-calendar-year date))
1161 (format "%s %s---%s %s"
1162 (calendar-month-name
1163 (extract-calendar-month date))
1164 (extract-calendar-year date)
1165 (calendar-month-name (extract-calendar-month d))
1166 (extract-calendar-year d))))))
1167 (insert "%\n")
1168 (calendar-for-loop j from 1 to 2 do
1169 (insert "\\rightday")
1170 (cal-tex-arg (calendar-day-name date))
1171 (cal-tex-arg (int-to-string (extract-calendar-day date)))
1172 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1173 (cal-tex-arg (cal-tex-latexify-list holidays date))
1174 (cal-tex-arg (eval cal-tex-daily-string))
1175 (insert "%\n")
1176 (setq date (cal-tex-incr-date date)))
1177 (calendar-for-loop j from 1 to 2 do
1178 (insert "\\weekend")
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))
1184 (insert "%\n")
1185 (setq date (cal-tex-incr-date date)))
1186 (if (/= i n)
1187 (progn
1188 (run-hooks 'cal-tex-week-hook)
1189 (cal-tex-newpage))))
1190 (cal-tex-end-document)
1191 (run-hooks 'cal-tex-hook)))
1192
1193 (defun cal-tex-cursor-filofax-daily (&optional arg)
1194 "Day-per-page Filofax style calendar for week indicated by cursor.
1195 Optional prefix argument specifies number of weeks. Weeks start on Monday.
1196 Diary entries are included if `cal-tex-diary' is t.
1197 Holidays are included if `cal-tex-holidays' is t."
1198 (interactive "P")
1199 (let* ((n (if arg arg 1))
1200 (date (calendar-gregorian-from-absolute
1201 (calendar-dayname-on-or-before
1202 1
1203 (calendar-absolute-from-gregorian
1204 (calendar-cursor-to-date t)))))
1205 (month (extract-calendar-month date))
1206 (year (extract-calendar-year date))
1207 (day (extract-calendar-day date))
1208 (holidays (if cal-tex-holidays
1209 (cal-tex-list-holidays
1210 (calendar-absolute-from-gregorian date)
1211 (+ (* 7 n)
1212 (calendar-absolute-from-gregorian date)))))
1213 (diary-list (if cal-tex-diary
1214 (cal-tex-list-diary-entries
1215 (calendar-absolute-from-gregorian
1216 (list month 1 year))
1217 (+ (* 7 n)
1218 (calendar-absolute-from-gregorian date))))))
1219 (cal-tex-preamble "twoside")
1220 (cal-tex-cmd "\\textwidth 3.25in")
1221 (cal-tex-cmd "\\textheight 6.5in")
1222 (cal-tex-cmd "\\oddsidemargin 1.75in")
1223 (cal-tex-cmd "\\evensidemargin 1.5in")
1224 (cal-tex-cmd "\\topmargin 0pt")
1225 (cal-tex-cmd "\\headheight -0.875in")
1226 (cal-tex-cmd "\\headsep 0.125in")
1227 (cal-tex-cmd "\\footskip .125in")
1228 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
1229 \\long\\def\\rightday#1#2#3{%
1230 \\rule{\\textwidth}{0.3pt}\\\\%
1231 \\hbox to \\textwidth{%
1232 \\vbox to 1.85in{%
1233 \\vspace*{2pt}%
1234 \\hbox to \\textwidth{\\hfill \\small #3 \\hfill}%
1235 \\hbox to \\textwidth{\\vbox {\\raggedleft \\em #2}}%
1236 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #1}}}}}
1237 \\long\\def\\weekend#1#2#3{%
1238 \\rule{\\textwidth}{0.3pt}\\\\%
1239 \\hbox to \\textwidth{%
1240 \\vbox to 2in{%
1241 \\vspace*{2pt}%
1242 \\hbox to \\textwidth{\\hfill \\small #3 \\hfill}%
1243 \\hbox to \\textwidth{\\vbox {\\noindent \\em #2}}%
1244 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #1}}}}}
1245 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]}
1246 \\long\\def\\leftday#1#2#3{%
1247 \\rule{\\textwidth}{0.3pt}\\\\%
1248 \\hbox to \\textwidth{%
1249 \\vbox to 1.85in{%
1250 \\vspace*{2pt}%
1251 \\hbox to \\textwidth{\\hfill \\small #3 \\hfill}%
1252 \\hbox to \\textwidth{\\vbox {\\noindent \\em #2}}%
1253 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #1}}}}}
1254 ")
1255 (cal-tex-b-document)
1256 (cal-tex-cmd "\\pagestyle{empty}")
1257 (calendar-for-loop i from 1 to n do
1258 (calendar-for-loop j from 1 to 5 do
1259 (insert (if (oddp j) "\\righthead" "\\lefthead"))
1260 (cal-tex-arg (calendar-date-string date))
1261 (insert "%\n")
1262 (insert (if (oddp j) "\\rightday" "\\leftday"))
1263 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1264 (cal-tex-arg (cal-tex-latexify-list holidays date))
1265 (cal-tex-arg (eval cal-tex-daily-string))
1266 (insert "%\n")
1267 (insert "\\vfill\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")
1268 (cal-tex-newpage)
1269 (setq date (cal-tex-incr-date date)))
1270 (insert "%\n")
1271 (calendar-for-loop j from 1 to 2 do
1272 (insert "\\lefthead")
1273 (cal-tex-arg (calendar-date-string date))
1274 (insert "\\weekend")
1275 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1276 (cal-tex-arg (cal-tex-latexify-list holidays date))
1277 (cal-tex-arg (eval cal-tex-daily-string))
1278 (insert "%\n")
1279 (insert "\\vfill")
1280 (setq date (cal-tex-incr-date date)))
1281 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")
1282 (if (/= i n)
1283 (progn
1284 (run-hooks 'cal-tex-week-hook)
1285 (cal-tex-newpage))))
1286 (cal-tex-end-document)
1287 (run-hooks 'cal-tex-hook)))
1288
1289
1290 ;;;
1291 ;;; Daily calendars
1292 ;;;
1293
1294 (defun cal-tex-cursor-day (&optional arg)
1295 "Make a buffer with LaTeX commands for the day cursor is on.
1296 Optional prefix argument specifies number of days."
1297 (interactive "P")
1298 (let ((n (if arg arg 1))
1299 (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))
1300 (cal-tex-preamble "12pt")
1301 (cal-tex-cmd "\\textwidth 6.5in")
1302 (cal-tex-cmd "\\textheight 10.5in")
1303 (cal-tex-b-document)
1304 (cal-tex-cmd "\\pagestyle{empty}")
1305 (calendar-for-loop i from 1 to n do
1306 (cal-tex-vspace "-1.7in")
1307 (cal-tex-daily-page (calendar-gregorian-from-absolute date))
1308 (setq date (1+ date))
1309 (if (/= i n)
1310 (progn
1311 (cal-tex-newpage)
1312 (run-hooks 'cal-tex-daily-hook))))
1313 (cal-tex-end-document)
1314 (run-hooks 'cal-tex-hook)))
1315
1316 (defun cal-tex-daily-page (date)
1317 "Make a calendar page for Gregorian DATE on 8.5 by 11 paper."
1318 (let* ((hour)
1319 (month-name (calendar-month-name (extract-calendar-month date))))
1320 (cal-tex-banner "cal-tex-daily-page")
1321 (cal-tex-b-makebox "4cm" "l")
1322 (cal-tex-b-parbox "b" "3.8cm")
1323 (cal-tex-rule "0mm" "0mm" "2cm")
1324 (cal-tex-Huge (number-to-string (extract-calendar-day date)))
1325 (cal-tex-nl ".5cm")
1326 (cal-tex-bf month-name )
1327 (cal-tex-e-parbox)
1328 (cal-tex-hspace "1cm")
1329 (cal-tex-scriptsize (eval cal-tex-daily-string))
1330 (cal-tex-hspace "3.5cm")
1331 (cal-tex-e-makebox)
1332 (cal-tex-hfill)
1333 (cal-tex-b-makebox "4cm" "r")
1334 (cal-tex-bf (calendar-day-name date))
1335 (cal-tex-e-makebox)
1336 (cal-tex-nl)
1337 (cal-tex-hspace ".4cm")
1338 (cal-tex-rule "0mm" "16.1cm" "1mm")
1339 (cal-tex-nl ".1cm")
1340 (calendar-for-loop i from cal-tex-daily-start to cal-tex-daily-end do
1341 (cal-tex-cmd "\\noindent")
1342 (setq hour (if cal-tex-24
1343 i
1344 (mod i 12)))
1345 (if (= 0 hour) (setq hour 12))
1346 (cal-tex-b-makebox "1cm" "c")
1347 (cal-tex-arg (number-to-string hour))
1348 (cal-tex-e-makebox)
1349 (cal-tex-rule "0mm" "15.5cm" ".2mm")
1350 (cal-tex-nl ".2cm")
1351 (cal-tex-b-makebox "1cm" "c")
1352 (cal-tex-arg "$\\diamond$" )
1353 (cal-tex-e-makebox)
1354 (cal-tex-rule "0mm" "15.5cm" ".2mm")
1355 (cal-tex-nl ".2cm"))
1356 (cal-tex-hfill)
1357 (insert (cal-tex-mini-calendar
1358 (extract-calendar-month (cal-tex-previous-month date))
1359 (extract-calendar-year (cal-tex-previous-month date))
1360 "lastmonth" "1.1in" "1in"))
1361 (insert (cal-tex-mini-calendar
1362 (extract-calendar-month date)
1363 (extract-calendar-year date)
1364 "thismonth" "1.1in" "1in"))
1365 (insert (cal-tex-mini-calendar
1366 (extract-calendar-month (cal-tex-next-month date))
1367 (extract-calendar-year (cal-tex-next-month date))
1368 "nextmonth" "1.1in" "1in"))
1369 (insert "\\hbox to \\textwidth{")
1370 (cal-tex-hfill)
1371 (insert "\\lastmonth")
1372 (cal-tex-hfill)
1373 (insert "\\thismonth")
1374 (cal-tex-hfill)
1375 (insert "\\nextmonth")
1376 (cal-tex-hfill)
1377 (insert "}")
1378 (cal-tex-banner "end of cal-tex-daily-page")))
1379
1380 ;;;
1381 ;;; Mini calendars
1382 ;;;
1383
1384 (defun cal-tex-mini-calendar (month year name width height &optional ptsize colsep)
1385 "Produce mini-calendar for MONTH, YEAR in macro NAME with WIDTH and HEIGHT.
1386 Optional PTSIZE gives the point ptsize; scriptsize is the default. Optional
1387 COLSEP gives the column separation; 1mm is the default."
1388 (let* ((blank-days;; at start of month
1389 (mod
1390 (- (calendar-day-of-week (list month 1 year))
1391 calendar-week-start-day)
1392 7))
1393 (last (calendar-last-day-of-month month year))
1394 (colsep (if colsep colsep "1mm"))
1395 (str (concat "\\def\\" name "{\\hbox to" width "{%\n"
1396 "\\vbox to" height "{%\n"
1397 "\\vfil \\hbox to" width "{%\n"
1398 "\\hfil\\"
1399 (if ptsize ptsize "scriptsize")
1400 "\\begin{tabular}"
1401 "{@{\\hspace{0mm}}r@{\\hspace{" colsep
1402 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep
1403 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep
1404 "}}r@{\\hspace{" colsep "}}r@{\\hspace{0mm}}}%\n"
1405 "\\multicolumn{7}{c}{"
1406 (calendar-month-name month)
1407 " "
1408 (int-to-string year)
1409 "}\\\\[1mm]\n")))
1410 (calendar-for-loop i from 0 to 6 do
1411 (setq str (concat str
1412 (substring (aref calendar-day-name-array
1413 (mod (+ calendar-week-start-day i) 7))
1414 0 2)
1415 (if (/= i 6)
1416 " & "
1417 "\\\\[0.7mm]\n"))))
1418 (calendar-for-loop i from 1 to blank-days do
1419 (setq str (concat str " & ")))
1420 (calendar-for-loop i from 1 to last do
1421 (setq str (concat str (int-to-string i)))
1422 (setq str (concat str (if (zerop (mod (+ i blank-days) 7))
1423 (if (/= i last) "\\\\[0.5mm]\n" "")
1424 " & "))))
1425 (setq str (concat str "\n\\end{tabular}\\hfil}\\vfil}}}%\n"))
1426 str))
1427
1428 ;;;
1429 ;;; Various calendar functions
1430 ;;;
1431
1432 (defun cal-tex-incr-date (date &optional n)
1433 "The date of the day following DATE.
1434 If optional N is given, the date of N days after DATE."
1435 (calendar-gregorian-from-absolute
1436 (+ (if n n 1) (calendar-absolute-from-gregorian date))))
1437
1438 (defun cal-tex-latexify-list (date-list date &optional separator)
1439 "Return string with concatenated, LaTeXified entries in DATE_LIST for DATE.
1440 Use double backslash as a separator unless optional SEPARATOR is given."
1441 (mapconcat '(lambda (x) (cal-tex-LaTeXify-string x))
1442 (let ((result)
1443 (p date-list))
1444 (while p
1445 (and (car (car p))
1446 (calendar-date-equal date (car (car p)))
1447 (setq result (append result (cdr (car p)))))
1448 (setq p (cdr p)))
1449 result)
1450 (if separator separator "\\\\")))
1451
1452 (defun cal-tex-previous-month (date)
1453 "Return the date of the first day in the month previous to DATE."
1454 (let* ((month (extract-calendar-month date))
1455 (year (extract-calendar-year date)))
1456 (increment-calendar-month month year -1)
1457 (list month 1 year)))
1458
1459 (defun cal-tex-next-month (date)
1460 "Return the date of the first day in the month following DATE."
1461 (let* ((month (extract-calendar-month date))
1462 (year (extract-calendar-year date)))
1463 (increment-calendar-month month year 1)
1464 (list month 1 year)))
1465
1466 ;;;
1467 ;;; LaTeX Code
1468 ;;;
1469
1470 (defun cal-tex-end-document ()
1471 "Finish the LaTeX document.
1472 Insert the trailer to LaTeX document, pop to LaTeX buffer, add
1473 informative header, and run HOOK."
1474 (cal-tex-e-document)
1475 (latex-mode)
1476 (pop-to-buffer cal-tex-buffer)
1477 (goto-char (point-min))
1478 (cal-tex-comment " This buffer was produced by cal-tex.el.")
1479 (cal-tex-comment " To print a calendar, type")
1480 (cal-tex-comment " M-x tex-buffer RET")
1481 (cal-tex-comment " M-x tex-print RET")
1482 (goto-char (point-min)))
1483
1484 (defun cal-tex-insert-preamble (weeks landscape size &optional append)
1485 "Initialize the output buffer.
1486 Select the output buffer, and insert the preamble for a calendar of
1487 WEEKS weeks. Insert code for landscape mode if LANDSCAPE is true.
1488 Use pointsize SIZE. Optional argument APPEND, if t, means add to end of
1489 without erasing current contents."
1490 (let ((width "18cm")
1491 (height "24cm"))
1492 (if landscape
1493 (progn
1494 (setq width "24cm")
1495 (setq height "18cm")))
1496 (if (not append)
1497 (progn
1498 (cal-tex-preamble size)
1499 (if (not landscape)
1500 (progn
1501 (cal-tex-cmd "\\oddsidemargin -1.75cm")
1502 (cal-tex-cmd "\\def\\holidaymult{.06}"))
1503 (cal-tex-cmd "\\special{landscape}")
1504 (cal-tex-cmd "\\textwidth 9.5in")
1505 (cal-tex-cmd "\\textheight 7in")
1506 (cal-tex-comment)
1507 (cal-tex-cmd "\\def\\holidaymult{.08}"))
1508 (cal-tex-cmd cal-tex-caldate)
1509 (cal-tex-cmd cal-tex-myday)
1510 (cal-tex-b-document)
1511 (cal-tex-cmd "\\pagestyle{empty}")))
1512 (cal-tex-cmd "\\setlength{\\cellwidth}" width)
1513 (insert (format "\\setlength{\\cellwidth}{%f\\cellwidth}\n"
1514 (/ 1.1 (length cal-tex-which-days))))
1515 (cal-tex-cmd "\\setlength{\\cellheight}" height)
1516 (insert (format "\\setlength{\\cellheight}{%f\\cellheight}\n"
1517 (/ 1.0 weeks)))
1518 (cal-tex-cmd "\\ \\par")
1519 (cal-tex-vspace "-3cm")))
1520
1521 (defvar cal-tex-LaTeX-subst-list
1522 '(("\"". "``")
1523 ("\"". "''");; Quote changes meaning when list is reversed.
1524 ("@" . "\\verb|@|")
1525 ("&" . "\\&")
1526 ("%" . "\\%")
1527 ("$" . "\\$")
1528 ("#" . "\\#")
1529 ("_" . "\\_")
1530 ("{" . "\\{")
1531 ("}" . "\\}")
1532 ("<" . "$<$")
1533 (">" . "$>$")
1534 ("\n" . "\\ \\\\")) ;\\ needed for e.g \begin{center}\n AA\end{center}
1535 "List of symbols and their replacements.")
1536
1537 (defun cal-tex-LaTeXify-string (string)
1538 "Protect special characters in STRING from LaTeX."
1539 (if (not string)
1540 ""
1541 (let ((head "")
1542 (tail string)
1543 (list cal-tex-LaTeX-subst-list))
1544 (while (not (string-equal tail ""))
1545 (let* ((ch (substring tail 0 1))
1546 (pair (assoc ch list)))
1547 (if (and pair (string-equal ch "\""))
1548 (setq list (reverse list)));; Quote changes meaning each time.
1549 (setq tail (substring tail 1))
1550 (setq head (concat head (if pair (cdr pair) ch)))))
1551 head)))
1552
1553 (defun cal-tex-hfill () "Insert hfill." (insert "\\hfill"))
1554
1555 (defun cal-tex-newpage () "Insert newpage." (insert "\\newpage%\n"))
1556
1557 (defun cal-tex-noindent () "Insert noindent." (insert "\\noindent"))
1558
1559 (defun cal-tex-vspace (space)
1560 "Insert vspace command to move SPACE vertically."
1561 (insert "\\vspace*{" space "}")
1562 (cal-tex-comment))
1563
1564 (defun cal-tex-hspace (space)
1565 "Insert hspace command to move SPACE horizontally."
1566 (insert "\\hspace*{" space "}")
1567 (cal-tex-comment))
1568
1569 (defun cal-tex-comment (&optional comment)
1570 "Insert % at end of line, include COMMENT if present, and move
1571 to next line."
1572 (insert "% ")
1573 (if comment
1574 (insert comment))
1575 (insert "\n"))
1576
1577 (defun cal-tex-banner (comment)
1578 "Insert the COMMENT separated by blank lines."
1579 (cal-tex-comment)
1580 (cal-tex-comment)
1581 (cal-tex-comment (concat "\t\t\t" comment))
1582 (cal-tex-comment))
1583
1584
1585 (defun cal-tex-nl (&optional skip comment)
1586 "End a line with \\. If SKIP, then add that much spacing.
1587 Add COMMENT if present"
1588 (insert "\\\\")
1589 (if skip
1590 (insert "[" skip "]"))
1591 (cal-tex-comment comment))
1592
1593 (defun cal-tex-arg (&optional text)
1594 "Insert optional TEXT surrounded by braces."
1595 (insert "{")
1596 (if text (insert text))
1597 (insert "}"))
1598
1599 (defun cal-tex-cmd (cmd &optional arg)
1600 "Insert LaTeX CMD, with optional ARG, and end with %"
1601 (insert cmd)
1602 (cal-tex-arg arg)
1603 (cal-tex-comment))
1604
1605 ;;;
1606 ;;; Environments
1607 ;;;
1608
1609 (defun cal-tex-b-document ()
1610 "Insert beginning of document."
1611 (cal-tex-cmd "\\begin{document}"))
1612
1613 (defun cal-tex-e-document ()
1614 "Insert end of document."
1615 (cal-tex-cmd "\\end{document}"))
1616
1617 (defun cal-tex-b-center ()
1618 "Insert beginning of centered block."
1619 (cal-tex-cmd "\\begin{center}"))
1620
1621 (defun cal-tex-e-center ()
1622 "Insert end of centered block."
1623 (cal-tex-comment)
1624 (cal-tex-cmd "\\end{center}"))
1625
1626
1627 ;;;
1628 ;;; Boxes
1629 ;;;
1630
1631
1632 (defun cal-tex-b-parbox (position width)
1633 "Insert parbox with parameters POSITION and WIDTH."
1634 (insert "\\parbox[" position "]{" width "}{")
1635 (cal-tex-comment))
1636
1637 (defun cal-tex-e-parbox (&optional height)
1638 "Insert end of parbox. Force it to be a given HEIGHT."
1639 (cal-tex-comment)
1640 (if height
1641 (cal-tex-rule "0mm" "0mm" height))
1642 (insert "}")
1643 (cal-tex-comment "end parbox"))
1644
1645 (defun cal-tex-b-framebox ( width position )
1646 "Insert framebox with parameters WIDTH and POSITION (clr)."
1647 (insert "\\framebox[" width "][" position "]{" )
1648 (cal-tex-comment))
1649
1650 (defun cal-tex-e-framebox ()
1651 "Insert end of framebox."
1652 (cal-tex-comment)
1653 (insert "}")
1654 (cal-tex-comment "end framebox"))
1655
1656
1657 (defun cal-tex-b-makebox ( width position )
1658 "Insert makebox with parameters WIDTH and POSITION (clr)."
1659 (insert "\\makebox[" width "][" position "]{" )
1660 (cal-tex-comment))
1661
1662 (defun cal-tex-e-makebox ()
1663 "Insert end of makebox."
1664 (cal-tex-comment)
1665 (insert "}")
1666 (cal-tex-comment "end makebox"))
1667
1668
1669 (defun cal-tex-rule (lower width height)
1670 "Insert a rule with parameters LOWER WIDTH HEIGHT."
1671 (insert "\\rule[" lower "]{" width "}{" height "}"))
1672
1673 ;;;
1674 ;;; Fonts
1675 ;;;
1676
1677 (defun cal-tex-em (string)
1678 "Insert STRING in bf font."
1679 (insert "{\\em " string "}"))
1680
1681 (defun cal-tex-bf (string)
1682 "Insert STRING in bf font."
1683 (insert "{\\bf " string "}"))
1684
1685 (defun cal-tex-scriptsize (string)
1686 "Insert STRING in scriptsize font."
1687 (insert "{\\scriptsize " string "}"))
1688
1689 (defun cal-tex-huge (string)
1690 "Insert STRING in huge size."
1691 (insert "{\\huge " string "}"))
1692
1693 (defun cal-tex-Huge (string)
1694 "Insert STRING in Huge size."
1695 (insert "{\\Huge " string "}"))
1696
1697 (defun cal-tex-Huge-bf (string)
1698 "Insert STRING in Huge bf size."
1699 (insert "{\\Huge\\bf " string "}"))
1700
1701 (defun cal-tex-large (string)
1702 "Insert STRING in large size."
1703 (insert "{\\large " string "}"))
1704
1705 (defun cal-tex-large-bf (string)
1706 "Insert STRING in large bf size."
1707 (insert "{\\large\\bf " string "}"))
1708
1709 (provide 'cal-tex)
1710
1711 ;;; cal-tex.el ends here