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