Mercurial > emacs
annotate lisp/calendar/cal-tex.el @ 23192:1ea9db09a678
(checkdoc-buffer-label): New function.
(checkdoc-start-section, checkdoc-error): Use `checkdoc-buffer-label'.
(checkdoc-this-string-valid-engine): Permit ? as terminating
punctuation for first line sentence breaking.
(checkdoc-this-string-valid): When converting a comment into a doc
string, make sure " chars are \".
(checkdoc-sentencespace-region-engine): Only do double space check
if based on the variable `sentence-end-double-space'
author | Eric M. Ludlam <zappo@gnu.org> |
---|---|
date | Sat, 05 Sep 1998 13:46:23 +0000 |
parents | da72a65a2bd6 |
children | 3f2b516f9ddc |
rev | line source |
---|---|
13195 | 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 | |
14169 | 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. | |
13195 | 26 |
27 ;;; Commentary: | |
28 | |
13206
2d1da471963a
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13195
diff
changeset
|
29 ;; This collection of functions implements the creation of LaTeX calendars |
2d1da471963a
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13195
diff
changeset
|
30 ;; based on the user's holiday choices and diary file. |
13195 | 31 |
14169 | 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 ;; | |
19973
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
40 ;; (*) Make monthly styles Filofax paper. |
13195 | 41 |
42 ;;; Code: | |
43 | |
44 (require 'calendar) | |
45 | |
13649
fb670bed6222
Use new file name diary-lib.
Richard M. Stallman <rms@gnu.org>
parents:
13595
diff
changeset
|
46 (autoload 'list-diary-entries "diary-lib" nil t) |
13195 | 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 | |
17626 | 54 (defcustom cal-tex-which-days '(0 1 2 3 4 5 6) |
13195 | 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 | |
17626 | 61 to only print Monday, Wednesday, Friday." |
62 :type '(repeat integer) | |
63 :group 'calendar-tex) | |
13195 | 64 |
17626 | 65 (defcustom cal-tex-holidays t |
13195 | 66 "*If t (default), then the holidays are also printed. |
17626 | 67 If finding the holidays is too slow, set this to nil." |
68 :type 'boolean | |
69 :group 'calendar-tex) | |
13195 | 70 |
17626 | 71 (defcustom cal-tex-diary nil |
72 "*If t, the diary entries are printed in the calendar." | |
73 :type 'boolean | |
74 :group 'calendar-tex) | |
13195 | 75 |
17626 | 76 (defcustom cal-tex-daily-string |
13195 | 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 | |
17626 | 93 will put the Hebrew date at the bottom of each day." |
94 :type 'sexp | |
95 :group 'calendar-tex) | |
13195 | 96 |
17626 | 97 (defcustom cal-tex-buffer "calendar.tex" |
98 "*The name for the tex-ed calendar." | |
99 :type 'string | |
100 :group 'calendar-tex) | |
13195 | 101 |
17626 | 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) | |
13195 | 106 |
17626 | 107 (defcustom cal-tex-daily-start 8 |
108 "*The first hour of the daily calendar page." | |
109 :type 'integer | |
110 :group 'calendar-tex) | |
13195 | 111 |
17626 | 112 (defcustom cal-tex-daily-end 20 |
113 "*The last hour of the daily calendar page." | |
114 :type 'integer | |
115 :group 'calendar-tex) | |
13195 | 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." | |
22147
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
179 (let* ((start (calendar-gregorian-from-absolute d1)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
180 (displayed-month (extract-calendar-month start)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
181 (displayed-year (extract-calendar-year start)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
182 (end (calendar-gregorian-from-absolute d2)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
183 (end-month (extract-calendar-month end)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
184 (end-year (extract-calendar-year end)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
185 (number-of-intervals |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
186 (1+ (/ (calendar-interval displayed-month displayed-year |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
187 end-month end-year) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
188 3))) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
189 (holidays nil) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
190 (in-range)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
191 (increment-calendar-month displayed-month displayed-year 1) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
192 (calendar-for-loop i from 1 to number-of-intervals do |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
193 (setq holidays (append holidays (calendar-holiday-list))) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
194 (increment-calendar-month displayed-month displayed-year 3)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
195 (while holidays |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
196 (and (car (car holidays)) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
197 (let ((a (calendar-absolute-from-gregorian (car (car holidays))))) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
198 (and (<= d1 a) (<= a d2))) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
199 (setq in-range (append (list (car holidays)) in-range))) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
200 (setq holidays (cdr holidays))) |
803bcc3c1a49
Rewrote cal-tex-list-holidays to get holidays in the range correctly (and more
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
20216
diff
changeset
|
201 in-range)) |
13195 | 202 |
203 (defun cal-tex-list-diary-entries (d1 d2) | |
204 "Generate a list of all diary-entries from absolute date D1 to D2." | |
19312
d67c0dba233d
(cal-tex-latexify-list): Put the elements of RESULT in the proper order.
Richard M. Stallman <rms@gnu.org>
parents:
19311
diff
changeset
|
205 (let ((diary-list-include-blanks nil) |
22415
c9fa49047eb5
Prevent diary display from being corrupted on printed calendar generation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
22147
diff
changeset
|
206 (diary-display-hook 'ignore)) |
13195 | 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 | |
14268
28face32932e
Add \hfuzz=1000pt to get rid of overfull box messages.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14169
diff
changeset
|
222 \\hfuzz=1000pt |
13195 | 223 \\vbadness 20000 |
17196
1b2490698826
(cal-tex-preamble): Set \lineskip to 0pt.
Karl Heuer <kwzh@gnu.org>
parents:
15433
diff
changeset
|
224 \\lineskip 0pt |
13195 | 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. | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
257 Optional prefix argument specifies number of years." |
13195 | 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") | |
15433
172725d0d2d5
A bit more fiddling with layout of Filofax year page.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
15432
diff
changeset
|
308 (cal-tex-cmd "\\oddsidemargin 1.675in") |
172725d0d2d5
A bit more fiddling with layout of Filofax year page.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
15432
diff
changeset
|
309 (cal-tex-cmd "\\evensidemargin 1.675in") |
13195 | 310 (cal-tex-cmd "\\topmargin 0pt") |
311 (cal-tex-cmd "\\headheight -0.875in") | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
312 (cal-tex-cmd "\\fboxsep 0.5mm") |
13195 | 313 (cal-tex-cmd "\\pagestyle{empty}") |
314 (cal-tex-b-document) | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
315 (cal-tex-cmd "\\vspace*{0.25in}") |
13195 | 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) | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
326 "1in" ".9in" "tiny" "0.6mm"))) |
13195 | 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)) | |
15433
172725d0d2d5
A bit more fiddling with layout of Filofax year page.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
15432
diff
changeset
|
336 (if (= j n) |
172725d0d2d5
A bit more fiddling with layout of Filofax year page.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
15432
diff
changeset
|
337 (cal-tex-end-document) |
172725d0d2d5
A bit more fiddling with layout of Filofax year page.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
15432
diff
changeset
|
338 (cal-tex-newpage) |
172725d0d2d5
A bit more fiddling with layout of Filofax year page.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
15432
diff
changeset
|
339 (cal-tex-cmd "\\vspace*{0.25in}")) |
13195 | 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) | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
605 "Make a buffer with LaTeX commands for a two-page one-week calendar. |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
606 It applies to the week that point is in. |
13195 | 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) | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
656 "Make a buffer with LaTeX commands for a two-page one-week calendar. |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
657 It applies to the week that point is in. |
13195 | 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 | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
735 (defun cal-tex-cursor-week-iso (&optional arg) |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
736 "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar. |
13195 | 737 Optional prefix argument specifies number of weeks. |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
738 Diary entries are included if `cal-tex-diary' is t. |
13195 | 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))) | |
20216
a63f69267334
(cal-tex-cursor-week-iso): Delete spurious %.
Karl Heuer <kwzh@gnu.org>
parents:
19973
diff
changeset
|
817 (cal-tex-e-parbox) |
13195 | 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 | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
866 (defun cal-tex-cursor-week-monday (&optional arg) |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
867 "Make a buffer with LaTeX commands for a two-page one-week calendar. |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
868 It applies to the week that point is in, and starts on Monday. |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
869 Optional prefix argument specifies number of weeks. |
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
870 Holidays are included if `cal-tex-holidays' is t." |
13195 | 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) | |
13206
2d1da471963a
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13195
diff
changeset
|
898 (setq date (cal-tex-incr-date date 7)) |
13195 | 899 (cal-tex-newpage)))) |
900 (cal-tex-end-document) | |
901 (run-hooks 'cal-tex-hook))) | |
902 | |
903 (defun cal-tex-weekly4-box (date weekend) | |
13206
2d1da471963a
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13195
diff
changeset
|
904 "Make one box for DATE, different if WEEKEND." |
13195 | 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") | |
13206
2d1da471963a
Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13195
diff
changeset
|
918 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year)) |
13195 | 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 | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
941 (defun cal-tex-cursor-filofax-2week (&optional arg) |
13195 | 942 "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor. |
943 Optional prefix argument specifies number of weeks. | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
944 Diary entries are included if `cal-tex-diary' is t. |
13195 | 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 | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
1042 (defun cal-tex-cursor-filofax-week (&optional arg) |
13195 | 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. | |
13595
2af9ec0bc9cc
(cal-tex-version): Deleted.
Richard M. Stallman <rms@gnu.org>
parents:
13206
diff
changeset
|
1046 Diary entries are included if `cal-tex-diary' is t. |
13195 | 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))) | |
19973
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1192 |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1193 (defun cal-tex-cursor-filofax-daily (&optional arg) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1194 "Day-per-page Filofax style calendar for week indicated by cursor. |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1195 Optional prefix argument specifies number of weeks. Weeks start on Monday. |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1196 Diary entries are included if `cal-tex-diary' is t. |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1197 Holidays are included if `cal-tex-holidays' is t." |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1198 (interactive "P") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1199 (let* ((n (if arg arg 1)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1200 (date (calendar-gregorian-from-absolute |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1201 (calendar-dayname-on-or-before |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1202 1 |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1203 (calendar-absolute-from-gregorian |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1204 (calendar-cursor-to-date t))))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1205 (month (extract-calendar-month date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1206 (year (extract-calendar-year date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1207 (day (extract-calendar-day date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1208 (holidays (if cal-tex-holidays |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1209 (cal-tex-list-holidays |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1210 (calendar-absolute-from-gregorian date) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1211 (+ (* 7 n) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1212 (calendar-absolute-from-gregorian date))))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1213 (diary-list (if cal-tex-diary |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1214 (cal-tex-list-diary-entries |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1215 (calendar-absolute-from-gregorian |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1216 (list month 1 year)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1217 (+ (* 7 n) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1218 (calendar-absolute-from-gregorian date)))))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1219 (cal-tex-preamble "twoside") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1220 (cal-tex-cmd "\\textwidth 3.25in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1221 (cal-tex-cmd "\\textheight 6.5in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1222 (cal-tex-cmd "\\oddsidemargin 1.75in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1223 (cal-tex-cmd "\\evensidemargin 1.5in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1224 (cal-tex-cmd "\\topmargin 0pt") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1225 (cal-tex-cmd "\\headheight -0.875in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1226 (cal-tex-cmd "\\headsep 0.125in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1227 (cal-tex-cmd "\\footskip .125in") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1228 (insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]} |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1229 \\long\\def\\rightday#1#2#3{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1230 \\rule{\\textwidth}{0.3pt}\\\\% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1231 \\hbox to \\textwidth{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1232 \\vbox to 1.85in{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1233 \\vspace*{2pt}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1234 \\hbox to \\textwidth{\\hfill \\small #3 \\hfill}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1235 \\hbox to \\textwidth{\\vbox {\\raggedleft \\em #2}}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1236 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #1}}}}} |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1237 \\long\\def\\weekend#1#2#3{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1238 \\rule{\\textwidth}{0.3pt}\\\\% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1239 \\hbox to \\textwidth{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1240 \\vbox to 2in{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1241 \\vspace*{2pt}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1242 \\hbox to \\textwidth{\\hfill \\small #3 \\hfill}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1243 \\hbox to \\textwidth{\\vbox {\\noindent \\em #2}}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1244 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #1}}}}} |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1245 \\def\\lefthead#1{\\noindent {\\normalsize \\bf #1}\\hfill\\\\[-6pt]} |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1246 \\long\\def\\leftday#1#2#3{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1247 \\rule{\\textwidth}{0.3pt}\\\\% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1248 \\hbox to \\textwidth{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1249 \\vbox to 1.85in{% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1250 \\vspace*{2pt}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1251 \\hbox to \\textwidth{\\hfill \\small #3 \\hfill}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1252 \\hbox to \\textwidth{\\vbox {\\noindent \\em #2}}% |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1253 \\hbox to \\textwidth{\\vbox to 0pt {\\noindent \\footnotesize #1}}}}} |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1254 ") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1255 (cal-tex-b-document) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1256 (cal-tex-cmd "\\pagestyle{empty}") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1257 (calendar-for-loop i from 1 to n do |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1258 (calendar-for-loop j from 1 to 5 do |
23120
da72a65a2bd6
(cal-tex-cursor-filofax-daily): Don't use oddp.
Karl Heuer <kwzh@gnu.org>
parents:
22820
diff
changeset
|
1259 (let ((odd (/= 0 (% j 2)))) |
da72a65a2bd6
(cal-tex-cursor-filofax-daily): Don't use oddp.
Karl Heuer <kwzh@gnu.org>
parents:
22820
diff
changeset
|
1260 (insert (if odd "\\righthead" "\\lefthead")) |
da72a65a2bd6
(cal-tex-cursor-filofax-daily): Don't use oddp.
Karl Heuer <kwzh@gnu.org>
parents:
22820
diff
changeset
|
1261 (cal-tex-arg (calendar-date-string date)) |
da72a65a2bd6
(cal-tex-cursor-filofax-daily): Don't use oddp.
Karl Heuer <kwzh@gnu.org>
parents:
22820
diff
changeset
|
1262 (insert "%\n") |
da72a65a2bd6
(cal-tex-cursor-filofax-daily): Don't use oddp.
Karl Heuer <kwzh@gnu.org>
parents:
22820
diff
changeset
|
1263 (insert (if odd "\\rightday" "\\leftday"))) |
19973
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1264 (cal-tex-arg (cal-tex-latexify-list diary-list date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1265 (cal-tex-arg (cal-tex-latexify-list holidays date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1266 (cal-tex-arg (eval cal-tex-daily-string)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1267 (insert "%\n") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1268 (insert "\\vfill\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1269 (cal-tex-newpage) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1270 (setq date (cal-tex-incr-date date))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1271 (insert "%\n") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1272 (calendar-for-loop j from 1 to 2 do |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1273 (insert "\\lefthead") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1274 (cal-tex-arg (calendar-date-string date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1275 (insert "\\weekend") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1276 (cal-tex-arg (cal-tex-latexify-list diary-list date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1277 (cal-tex-arg (cal-tex-latexify-list holidays date)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1278 (cal-tex-arg (eval cal-tex-daily-string)) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1279 (insert "%\n") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1280 (insert "\\vfill") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1281 (setq date (cal-tex-incr-date date))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1282 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n") |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1283 (if (/= i n) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1284 (progn |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1285 (run-hooks 'cal-tex-week-hook) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1286 (cal-tex-newpage)))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1287 (cal-tex-end-document) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1288 (run-hooks 'cal-tex-hook))) |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1289 |
45f02da6ebbb
(cal-tex-cursor-filofax-daily): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19312
diff
changeset
|
1290 |
13195 | 1291 ;;; |
1292 ;;; Daily calendars | |
1293 ;;; | |
1294 | |
1295 (defun cal-tex-cursor-day (&optional arg) | |
1296 "Make a buffer with LaTeX commands for the day cursor is on. | |
1297 Optional prefix argument specifies number of days." | |
1298 (interactive "P") | |
1299 (let ((n (if arg arg 1)) | |
1300 (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t)))) | |
1301 (cal-tex-preamble "12pt") | |
1302 (cal-tex-cmd "\\textwidth 6.5in") | |
1303 (cal-tex-cmd "\\textheight 10.5in") | |
1304 (cal-tex-b-document) | |
1305 (cal-tex-cmd "\\pagestyle{empty}") | |
1306 (calendar-for-loop i from 1 to n do | |
1307 (cal-tex-vspace "-1.7in") | |
1308 (cal-tex-daily-page (calendar-gregorian-from-absolute date)) | |
1309 (setq date (1+ date)) | |
1310 (if (/= i n) | |
1311 (progn | |
1312 (cal-tex-newpage) | |
1313 (run-hooks 'cal-tex-daily-hook)))) | |
1314 (cal-tex-end-document) | |
1315 (run-hooks 'cal-tex-hook))) | |
1316 | |
1317 (defun cal-tex-daily-page (date) | |
1318 "Make a calendar page for Gregorian DATE on 8.5 by 11 paper." | |
1319 (let* ((hour) | |
1320 (month-name (calendar-month-name (extract-calendar-month date)))) | |
1321 (cal-tex-banner "cal-tex-daily-page") | |
1322 (cal-tex-b-makebox "4cm" "l") | |
1323 (cal-tex-b-parbox "b" "3.8cm") | |
1324 (cal-tex-rule "0mm" "0mm" "2cm") | |
1325 (cal-tex-Huge (number-to-string (extract-calendar-day date))) | |
1326 (cal-tex-nl ".5cm") | |
1327 (cal-tex-bf month-name ) | |
1328 (cal-tex-e-parbox) | |
1329 (cal-tex-hspace "1cm") | |
1330 (cal-tex-scriptsize (eval cal-tex-daily-string)) | |
1331 (cal-tex-hspace "3.5cm") | |
1332 (cal-tex-e-makebox) | |
1333 (cal-tex-hfill) | |
1334 (cal-tex-b-makebox "4cm" "r") | |
1335 (cal-tex-bf (calendar-day-name date)) | |
1336 (cal-tex-e-makebox) | |
1337 (cal-tex-nl) | |
1338 (cal-tex-hspace ".4cm") | |
1339 (cal-tex-rule "0mm" "16.1cm" "1mm") | |
1340 (cal-tex-nl ".1cm") | |
1341 (calendar-for-loop i from cal-tex-daily-start to cal-tex-daily-end do | |
1342 (cal-tex-cmd "\\noindent") | |
1343 (setq hour (if cal-tex-24 | |
1344 i | |
1345 (mod i 12))) | |
1346 (if (= 0 hour) (setq hour 12)) | |
1347 (cal-tex-b-makebox "1cm" "c") | |
1348 (cal-tex-arg (number-to-string hour)) | |
1349 (cal-tex-e-makebox) | |
1350 (cal-tex-rule "0mm" "15.5cm" ".2mm") | |
1351 (cal-tex-nl ".2cm") | |
1352 (cal-tex-b-makebox "1cm" "c") | |
1353 (cal-tex-arg "$\\diamond$" ) | |
1354 (cal-tex-e-makebox) | |
1355 (cal-tex-rule "0mm" "15.5cm" ".2mm") | |
1356 (cal-tex-nl ".2cm")) | |
1357 (cal-tex-hfill) | |
1358 (insert (cal-tex-mini-calendar | |
1359 (extract-calendar-month (cal-tex-previous-month date)) | |
1360 (extract-calendar-year (cal-tex-previous-month date)) | |
1361 "lastmonth" "1.1in" "1in")) | |
1362 (insert (cal-tex-mini-calendar | |
1363 (extract-calendar-month date) | |
1364 (extract-calendar-year date) | |
1365 "thismonth" "1.1in" "1in")) | |
1366 (insert (cal-tex-mini-calendar | |
1367 (extract-calendar-month (cal-tex-next-month date)) | |
1368 (extract-calendar-year (cal-tex-next-month date)) | |
1369 "nextmonth" "1.1in" "1in")) | |
1370 (insert "\\hbox to \\textwidth{") | |
1371 (cal-tex-hfill) | |
1372 (insert "\\lastmonth") | |
1373 (cal-tex-hfill) | |
1374 (insert "\\thismonth") | |
1375 (cal-tex-hfill) | |
1376 (insert "\\nextmonth") | |
1377 (cal-tex-hfill) | |
1378 (insert "}") | |
1379 (cal-tex-banner "end of cal-tex-daily-page"))) | |
1380 | |
1381 ;;; | |
1382 ;;; Mini calendars | |
1383 ;;; | |
1384 | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1385 (defun cal-tex-mini-calendar (month year name width height &optional ptsize colsep) |
13195 | 1386 "Produce mini-calendar for MONTH, YEAR in macro NAME with WIDTH and HEIGHT. |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1387 Optional PTSIZE gives the point ptsize; scriptsize is the default. Optional |
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1388 COLSEP gives the column separation; 1mm is the default." |
13195 | 1389 (let* ((blank-days;; at start of month |
1390 (mod | |
1391 (- (calendar-day-of-week (list month 1 year)) | |
1392 calendar-week-start-day) | |
1393 7)) | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1394 (last (calendar-last-day-of-month month year)) |
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1395 (colsep (if colsep colsep "1mm")) |
13195 | 1396 (str (concat "\\def\\" name "{\\hbox to" width "{%\n" |
1397 "\\vbox to" height "{%\n" | |
1398 "\\vfil \\hbox to" width "{%\n" | |
1399 "\\hfil\\" | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1400 (if ptsize ptsize "scriptsize") |
13195 | 1401 "\\begin{tabular}" |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1402 "{@{\\hspace{0mm}}r@{\\hspace{" colsep |
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1403 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep |
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1404 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep |
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1405 "}}r@{\\hspace{" colsep "}}r@{\\hspace{0mm}}}%\n" |
13195 | 1406 "\\multicolumn{7}{c}{" |
1407 (calendar-month-name month) | |
1408 " " | |
1409 (int-to-string year) | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1410 "}\\\\[1mm]\n"))) |
13195 | 1411 (calendar-for-loop i from 0 to 6 do |
1412 (setq str (concat str | |
1413 (substring (aref calendar-day-name-array | |
1414 (mod (+ calendar-week-start-day i) 7)) | |
1415 0 2) | |
1416 (if (/= i 6) | |
1417 " & " | |
15432
c76e8e8fdb0a
Fix Filofax year output so that it's the correct size.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
14268
diff
changeset
|
1418 "\\\\[0.7mm]\n")))) |
13195 | 1419 (calendar-for-loop i from 1 to blank-days do |
1420 (setq str (concat str " & "))) | |
1421 (calendar-for-loop i from 1 to last do | |
1422 (setq str (concat str (int-to-string i))) | |
1423 (setq str (concat str (if (zerop (mod (+ i blank-days) 7)) | |
1424 (if (/= i last) "\\\\[0.5mm]\n" "") | |
1425 " & ")))) | |
1426 (setq str (concat str "\n\\end{tabular}\\hfil}\\vfil}}}%\n")) | |
1427 str)) | |
1428 | |
1429 ;;; | |
1430 ;;; Various calendar functions | |
1431 ;;; | |
1432 | |
1433 (defun cal-tex-incr-date (date &optional n) | |
1434 "The date of the day following DATE. | |
1435 If optional N is given, the date of N days after DATE." | |
1436 (calendar-gregorian-from-absolute | |
1437 (+ (if n n 1) (calendar-absolute-from-gregorian date)))) | |
1438 | |
1439 (defun cal-tex-latexify-list (date-list date &optional separator) | |
1440 "Return string with concatenated, LaTeXified entries in DATE_LIST for DATE. | |
1441 Use double backslash as a separator unless optional SEPARATOR is given." | |
1442 (mapconcat '(lambda (x) (cal-tex-LaTeXify-string x)) | |
1443 (let ((result) | |
1444 (p date-list)) | |
1445 (while p | |
1446 (and (car (car p)) | |
1447 (calendar-date-equal date (car (car p))) | |
22820
fd2cd15ffd6c
(cal-tex-latexify-list): Ignore specifer in diary entry.
Richard M. Stallman <rms@gnu.org>
parents:
22415
diff
changeset
|
1448 (setq result (cons (car (cdr (car p))) result))) |
13195 | 1449 (setq p (cdr p))) |
22820
fd2cd15ffd6c
(cal-tex-latexify-list): Ignore specifer in diary entry.
Richard M. Stallman <rms@gnu.org>
parents:
22415
diff
changeset
|
1450 (reverse result)) |
13195 | 1451 (if separator separator "\\\\"))) |
1452 | |
1453 (defun cal-tex-previous-month (date) | |
1454 "Return the date of the first day in the month previous to DATE." | |
1455 (let* ((month (extract-calendar-month date)) | |
1456 (year (extract-calendar-year date))) | |
1457 (increment-calendar-month month year -1) | |
1458 (list month 1 year))) | |
1459 | |
1460 (defun cal-tex-next-month (date) | |
1461 "Return the date of the first day in the month following DATE." | |
1462 (let* ((month (extract-calendar-month date)) | |
1463 (year (extract-calendar-year date))) | |
1464 (increment-calendar-month month year 1) | |
1465 (list month 1 year))) | |
1466 | |
1467 ;;; | |
1468 ;;; LaTeX Code | |
1469 ;;; | |
1470 | |
1471 (defun cal-tex-end-document () | |
1472 "Finish the LaTeX document. | |
1473 Insert the trailer to LaTeX document, pop to LaTeX buffer, add | |
1474 informative header, and run HOOK." | |
1475 (cal-tex-e-document) | |
1476 (latex-mode) | |
1477 (pop-to-buffer cal-tex-buffer) | |
1478 (goto-char (point-min)) | |
1479 (cal-tex-comment " This buffer was produced by cal-tex.el.") | |
1480 (cal-tex-comment " To print a calendar, type") | |
1481 (cal-tex-comment " M-x tex-buffer RET") | |
1482 (cal-tex-comment " M-x tex-print RET") | |
1483 (goto-char (point-min))) | |
1484 | |
1485 (defun cal-tex-insert-preamble (weeks landscape size &optional append) | |
1486 "Initialize the output buffer. | |
1487 Select the output buffer, and insert the preamble for a calendar of | |
1488 WEEKS weeks. Insert code for landscape mode if LANDSCAPE is true. | |
1489 Use pointsize SIZE. Optional argument APPEND, if t, means add to end of | |
1490 without erasing current contents." | |
1491 (let ((width "18cm") | |
1492 (height "24cm")) | |
1493 (if landscape | |
1494 (progn | |
1495 (setq width "24cm") | |
1496 (setq height "18cm"))) | |
1497 (if (not append) | |
1498 (progn | |
1499 (cal-tex-preamble size) | |
1500 (if (not landscape) | |
1501 (progn | |
1502 (cal-tex-cmd "\\oddsidemargin -1.75cm") | |
1503 (cal-tex-cmd "\\def\\holidaymult{.06}")) | |
1504 (cal-tex-cmd "\\special{landscape}") | |
1505 (cal-tex-cmd "\\textwidth 9.5in") | |
1506 (cal-tex-cmd "\\textheight 7in") | |
1507 (cal-tex-comment) | |
1508 (cal-tex-cmd "\\def\\holidaymult{.08}")) | |
1509 (cal-tex-cmd cal-tex-caldate) | |
1510 (cal-tex-cmd cal-tex-myday) | |
1511 (cal-tex-b-document) | |
1512 (cal-tex-cmd "\\pagestyle{empty}"))) | |
1513 (cal-tex-cmd "\\setlength{\\cellwidth}" width) | |
1514 (insert (format "\\setlength{\\cellwidth}{%f\\cellwidth}\n" | |
1515 (/ 1.1 (length cal-tex-which-days)))) | |
1516 (cal-tex-cmd "\\setlength{\\cellheight}" height) | |
1517 (insert (format "\\setlength{\\cellheight}{%f\\cellheight}\n" | |
1518 (/ 1.0 weeks))) | |
1519 (cal-tex-cmd "\\ \\par") | |
1520 (cal-tex-vspace "-3cm"))) | |
1521 | |
1522 (defvar cal-tex-LaTeX-subst-list | |
1523 '(("\"". "``") | |
1524 ("\"". "''");; Quote changes meaning when list is reversed. | |
1525 ("@" . "\\verb|@|") | |
1526 ("&" . "\\&") | |
1527 ("%" . "\\%") | |
1528 ("$" . "\\$") | |
1529 ("#" . "\\#") | |
1530 ("_" . "\\_") | |
1531 ("{" . "\\{") | |
1532 ("}" . "\\}") | |
1533 ("<" . "$<$") | |
1534 (">" . "$>$") | |
1535 ("\n" . "\\ \\\\")) ;\\ needed for e.g \begin{center}\n AA\end{center} | |
1536 "List of symbols and their replacements.") | |
1537 | |
1538 (defun cal-tex-LaTeXify-string (string) | |
1539 "Protect special characters in STRING from LaTeX." | |
1540 (if (not string) | |
1541 "" | |
1542 (let ((head "") | |
1543 (tail string) | |
1544 (list cal-tex-LaTeX-subst-list)) | |
1545 (while (not (string-equal tail "")) | |
1546 (let* ((ch (substring tail 0 1)) | |
1547 (pair (assoc ch list))) | |
1548 (if (and pair (string-equal ch "\"")) | |
1549 (setq list (reverse list)));; Quote changes meaning each time. | |
1550 (setq tail (substring tail 1)) | |
1551 (setq head (concat head (if pair (cdr pair) ch))))) | |
1552 head))) | |
1553 | |
1554 (defun cal-tex-hfill () "Insert hfill." (insert "\\hfill")) | |
1555 | |
1556 (defun cal-tex-newpage () "Insert newpage." (insert "\\newpage%\n")) | |
1557 | |
1558 (defun cal-tex-noindent () "Insert noindent." (insert "\\noindent")) | |
1559 | |
1560 (defun cal-tex-vspace (space) | |
1561 "Insert vspace command to move SPACE vertically." | |
1562 (insert "\\vspace*{" space "}") | |
1563 (cal-tex-comment)) | |
1564 | |
1565 (defun cal-tex-hspace (space) | |
1566 "Insert hspace command to move SPACE horizontally." | |
1567 (insert "\\hspace*{" space "}") | |
1568 (cal-tex-comment)) | |
1569 | |
1570 (defun cal-tex-comment (&optional comment) | |
1571 "Insert % at end of line, include COMMENT if present, and move | |
1572 to next line." | |
1573 (insert "% ") | |
1574 (if comment | |
1575 (insert comment)) | |
1576 (insert "\n")) | |
1577 | |
1578 (defun cal-tex-banner (comment) | |
1579 "Insert the COMMENT separated by blank lines." | |
1580 (cal-tex-comment) | |
1581 (cal-tex-comment) | |
1582 (cal-tex-comment (concat "\t\t\t" comment)) | |
1583 (cal-tex-comment)) | |
1584 | |
1585 | |
1586 (defun cal-tex-nl (&optional skip comment) | |
1587 "End a line with \\. If SKIP, then add that much spacing. | |
1588 Add COMMENT if present" | |
1589 (insert "\\\\") | |
1590 (if skip | |
1591 (insert "[" skip "]")) | |
1592 (cal-tex-comment comment)) | |
1593 | |
1594 (defun cal-tex-arg (&optional text) | |
1595 "Insert optional TEXT surrounded by braces." | |
1596 (insert "{") | |
1597 (if text (insert text)) | |
1598 (insert "}")) | |
1599 | |
1600 (defun cal-tex-cmd (cmd &optional arg) | |
1601 "Insert LaTeX CMD, with optional ARG, and end with %" | |
1602 (insert cmd) | |
1603 (cal-tex-arg arg) | |
1604 (cal-tex-comment)) | |
1605 | |
1606 ;;; | |
1607 ;;; Environments | |
1608 ;;; | |
1609 | |
1610 (defun cal-tex-b-document () | |
1611 "Insert beginning of document." | |
1612 (cal-tex-cmd "\\begin{document}")) | |
1613 | |
1614 (defun cal-tex-e-document () | |
1615 "Insert end of document." | |
1616 (cal-tex-cmd "\\end{document}")) | |
1617 | |
1618 (defun cal-tex-b-center () | |
1619 "Insert beginning of centered block." | |
1620 (cal-tex-cmd "\\begin{center}")) | |
1621 | |
1622 (defun cal-tex-e-center () | |
1623 "Insert end of centered block." | |
1624 (cal-tex-comment) | |
1625 (cal-tex-cmd "\\end{center}")) | |
1626 | |
1627 | |
1628 ;;; | |
1629 ;;; Boxes | |
1630 ;;; | |
1631 | |
1632 | |
1633 (defun cal-tex-b-parbox (position width) | |
1634 "Insert parbox with parameters POSITION and WIDTH." | |
1635 (insert "\\parbox[" position "]{" width "}{") | |
1636 (cal-tex-comment)) | |
1637 | |
1638 (defun cal-tex-e-parbox (&optional height) | |
1639 "Insert end of parbox. Force it to be a given HEIGHT." | |
1640 (cal-tex-comment) | |
1641 (if height | |
1642 (cal-tex-rule "0mm" "0mm" height)) | |
1643 (insert "}") | |
1644 (cal-tex-comment "end parbox")) | |
1645 | |
1646 (defun cal-tex-b-framebox ( width position ) | |
1647 "Insert framebox with parameters WIDTH and POSITION (clr)." | |
1648 (insert "\\framebox[" width "][" position "]{" ) | |
1649 (cal-tex-comment)) | |
1650 | |
1651 (defun cal-tex-e-framebox () | |
1652 "Insert end of framebox." | |
1653 (cal-tex-comment) | |
1654 (insert "}") | |
1655 (cal-tex-comment "end framebox")) | |
1656 | |
1657 | |
1658 (defun cal-tex-b-makebox ( width position ) | |
1659 "Insert makebox with parameters WIDTH and POSITION (clr)." | |
1660 (insert "\\makebox[" width "][" position "]{" ) | |
1661 (cal-tex-comment)) | |
1662 | |
1663 (defun cal-tex-e-makebox () | |
1664 "Insert end of makebox." | |
1665 (cal-tex-comment) | |
1666 (insert "}") | |
1667 (cal-tex-comment "end makebox")) | |
1668 | |
1669 | |
1670 (defun cal-tex-rule (lower width height) | |
1671 "Insert a rule with parameters LOWER WIDTH HEIGHT." | |
1672 (insert "\\rule[" lower "]{" width "}{" height "}")) | |
1673 | |
1674 ;;; | |
1675 ;;; Fonts | |
1676 ;;; | |
1677 | |
1678 (defun cal-tex-em (string) | |
1679 "Insert STRING in bf font." | |
1680 (insert "{\\em " string "}")) | |
1681 | |
1682 (defun cal-tex-bf (string) | |
1683 "Insert STRING in bf font." | |
1684 (insert "{\\bf " string "}")) | |
1685 | |
1686 (defun cal-tex-scriptsize (string) | |
1687 "Insert STRING in scriptsize font." | |
1688 (insert "{\\scriptsize " string "}")) | |
1689 | |
1690 (defun cal-tex-huge (string) | |
1691 "Insert STRING in huge size." | |
1692 (insert "{\\huge " string "}")) | |
1693 | |
1694 (defun cal-tex-Huge (string) | |
1695 "Insert STRING in Huge size." | |
1696 (insert "{\\Huge " string "}")) | |
1697 | |
1698 (defun cal-tex-Huge-bf (string) | |
1699 "Insert STRING in Huge bf size." | |
1700 (insert "{\\Huge\\bf " string "}")) | |
1701 | |
1702 (defun cal-tex-large (string) | |
1703 "Insert STRING in large size." | |
1704 (insert "{\\large " string "}")) | |
1705 | |
1706 (defun cal-tex-large-bf (string) | |
1707 "Insert STRING in large bf size." | |
1708 (insert "{\\large\\bf " string "}")) | |
1709 | |
1710 (provide 'cal-tex) | |
1711 | |
1712 ;;; cal-tex.el ends here |