aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Belaïche2017-09-15 23:51:05 +0200
committerVincent Belaïche2017-09-15 23:51:05 +0200
commitd1458d0f40f481e0ac55a55e7567d6e51438b583 (patch)
tree53a450bbd8661558ecfdacace757ee8e96143b96
parentc87331a1c04aa4be55be7b944680e4ec486f5b04 (diff)
downloademacs-d1458d0f40f481e0ac55a55e7567d6e51438b583.tar.gz
emacs-d1458d0f40f481e0ac55a55e7567d6e51438b583.zip
Make landscape layout with geometry package rather than a PostScript special.
* lisp/calendar/cal-tex.el (cal-tex-preamble): Make 12pt the default class option. (cal-tex-year, cal-tex-cursor-month-landscape): Pass landscape request to `cal-tex-insert-preamble' function call within the class option string. (cal-tex-cursor-month): Don't pass any longer "12pt" argument to `cal-tex-insert-preamble' function, as it is default. (cal-tex-insert-preamble): Suppress landscape and size argument, and replace them by a class-options string argument. Do not insert any longer "\special{landscape}" in case of landscape layout, as the job is made by the geometry package.
-rw-r--r--lisp/calendar/cal-tex.el60
1 files changed, 42 insertions, 18 deletions
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 1ea10bf9d70..689ba0f33a9 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -259,12 +259,33 @@ This definition is the heart of the calendar!")
259(defun cal-tex-preamble (&optional args) 259(defun cal-tex-preamble (&optional args)
260 "Insert the LaTeX calendar preamble into `cal-tex-buffer'. 260 "Insert the LaTeX calendar preamble into `cal-tex-buffer'.
261Preamble includes initial definitions for various LaTeX commands. 261Preamble includes initial definitions for various LaTeX commands.
262Optional string ARGS are included as options for the article document class." 262Optional string ARGS are included as options for the article
263document class with inclusion of default values \"12pt\" for
264size, and \"a4paper\" for paper unless size or paper are already
265specified in ARGS. When ARGS is omitted, by default the option
266\"12pt,a4paper\" is passed. When ARGS has any other value, then
267no option is passed to the class.
268
269Insert the \"\\usepacakge{geometry}\" directive when ARGS
270contains the \"landscape\" string."
263 (set-buffer (generate-new-buffer cal-tex-buffer)) 271 (set-buffer (generate-new-buffer cal-tex-buffer))
264 (insert (format "\\documentclass%s{article}\n" 272 (save-match-data
265 (if (stringp args) 273 (insert (format "\\documentclass%s{article}\n"
266 (format "[%s]" args) 274 (cond
267 ""))) 275 ((stringp args)
276 ;; set default size
277 (unless (string-match "\\(^\\|,\\) *[0-9]+pt *\\(,\\|$\\)" args)
278 (setq args (concat args ",12pt")))
279 ;; set default paper
280 (unless (string-match "\\(^\\|,\\) *\\([ab][4-5]\\|le\\(tter\\|gal\\)\\|executive\\)paper *\\(,\\|$\\)" args)
281 (setq args (concat args ",a4paper")))
282 (when (string= (substring args 0 1) ",")
283 (setq args (substring args 1)))
284 (if (string= args "") "" (format "[%s]" args)))
285 ((null args) "[12pt]")
286 (t ""))))
287 (if (and (stringp args) (string-match "\\<landscape\\>" args))
288 (insert "\\usepackage{geometry}\n")))
268 (if (stringp cal-tex-preamble-extra) 289 (if (stringp cal-tex-preamble-extra)
269 (insert cal-tex-preamble-extra "\n")) 290 (insert cal-tex-preamble-extra "\n"))
270 ;; FIXME boxwidth and boxheight unused? 291 ;; FIXME boxwidth and boxheight unused?
@@ -320,7 +341,7 @@ Optional EVENT indicates a buffer position to use instead of point."
320There are four rows of three months each, unless optional 341There are four rows of three months each, unless optional
321LANDSCAPE is non-nil, in which case the calendar is printed in 342LANDSCAPE is non-nil, in which case the calendar is printed in
322landscape mode with three rows of four months each." 343landscape mode with three rows of four months each."
323 (cal-tex-insert-preamble 1 landscape "12pt") 344 (cal-tex-insert-preamble 1 (and landscape "landscape"))
324 (if landscape 345 (if landscape
325 (cal-tex-vspace "-.6cm") 346 (cal-tex-vspace "-.6cm")
326 (cal-tex-vspace "-3.1cm")) 347 (cal-tex-vspace "-3.1cm"))
@@ -476,7 +497,7 @@ Optional EVENT indicates a buffer position to use instead of point."
476 (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2))) 497 (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2)))
477 (holidays (if cal-tex-holidays (holiday-in-range d1 d2))) 498 (holidays (if cal-tex-holidays (holiday-in-range d1 d2)))
478 other-month other-year small-months-at-start) 499 other-month other-year small-months-at-start)
479 (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt") 500 (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) "landscape")
480 (cal-tex-cmd cal-tex-cal-one-month) 501 (cal-tex-cmd cal-tex-cal-one-month)
481 (dotimes (i n) 502 (dotimes (i n)
482 (setq other-month month 503 (setq other-month month
@@ -515,7 +536,7 @@ Optional EVENT indicates a buffer position to use instead of point."
515 (calendar-increment-month month year 1) 536 (calendar-increment-month month year 1)
516 (cal-tex-vspace "-2cm") 537 (cal-tex-vspace "-2cm")
517 (cal-tex-insert-preamble 538 (cal-tex-insert-preamble
518 (cal-tex-number-weeks month year 1) t "12pt" t)))) 539 (cal-tex-number-weeks month year 1) "landscape" t))))
519 (cal-tex-end-document) 540 (cal-tex-end-document)
520 (run-hooks 'cal-tex-hook)) 541 (run-hooks 'cal-tex-hook))
521 542
@@ -545,7 +566,7 @@ indicates a buffer position to use instead of point."
545 end-year)))) 566 end-year))))
546 (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2))) 567 (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2)))
547 (holidays (if cal-tex-holidays (holiday-in-range d1 d2)))) 568 (holidays (if cal-tex-holidays (holiday-in-range d1 d2))))
548 (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil "12pt") 569 (cal-tex-insert-preamble (cal-tex-number-weeks month year n))
549 (if (> n 1) 570 (if (> n 1)
550 (cal-tex-cmd cal-tex-cal-multi-month) 571 (cal-tex-cmd cal-tex-cal-multi-month)
551 (cal-tex-cmd cal-tex-cal-one-month)) 572 (cal-tex-cmd cal-tex-cal-one-month))
@@ -1615,24 +1636,27 @@ informative header, and run HOOK."
1615\t\tM-x tex-buffer RET 1636\t\tM-x tex-buffer RET
1616\t\tM-x tex-print RET"))) 1637\t\tM-x tex-print RET")))
1617 1638
1618(defun cal-tex-insert-preamble (weeks landscape size &optional append) 1639(defun cal-tex-insert-preamble (weeks &optional class-options append)
1619 "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'. 1640 "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'.
1620Select the output buffer, and insert the preamble for a calendar 1641Select the output buffer, and insert the preamble for a calendar
1621of WEEKS weeks. Insert code for landscape mode if LANDSCAPE is 1642of WEEKS weeks. Pass string CLASS-OPTIONS as options for the
1622non-nil. Use point-size SIZE. Optional argument APPEND, if 1643article document class. If it contains \"landscape\", use the
1623non-nil, means add to end of buffer without erasing current contents." 1644geometry package to produce landscape format. Optional argument
1624 (let ((width "18cm") 1645APPEND, if non-nil, means add to end of buffer without erasing
1646current contents."
1647 (let ((landscape (and class-options
1648 (string-match "\\<landscape\\>" class-options)))
1649 (width "18cm")
1625 (height "24cm")) 1650 (height "24cm"))
1626 (when landscape 1651 (when landscape
1627 (setq width "24cm" 1652 (let ((swap width))
1628 height "18cm")) 1653 (setq width height height swap)))
1629 (unless append 1654 (unless append
1630 (cal-tex-preamble size) 1655 (cal-tex-preamble class-options)
1631 (if (not landscape) 1656 (if (not landscape)
1632 (progn 1657 (progn
1633 (cal-tex-cmd "\\oddsidemargin -1.75cm") 1658 (cal-tex-cmd "\\oddsidemargin -1.75cm")
1634 (cal-tex-cmd "\\def\\holidaymult" ".06")) 1659 (cal-tex-cmd "\\def\\holidaymult" ".06"))
1635 (cal-tex-cmd "\\special" "landscape")
1636 (cal-tex-cmd "\\textwidth 9.5in") 1660 (cal-tex-cmd "\\textwidth 9.5in")
1637 (cal-tex-cmd "\\textheight 7in") 1661 (cal-tex-cmd "\\textheight 7in")
1638 (cal-tex-comment) 1662 (cal-tex-comment)