Initial Commit
[packages] / xemacs-packages / auctex / style / psfig.el
1 ;;; psfig.el - Support for the psfig style option.
2
3 ;; Contributed by Marc Gemis <makke@wins.uia.ac.be>
4 ;; Please direct comments to him.
5
6 ;;; Code:
7
8 (TeX-add-style-hook "psfig"
9  (function
10   (lambda ()
11         ;; probable some of the following symbols may be removed
12     (TeX-add-symbols "protect" "figurepath"  "fbox"
13                      "other" "letter" "other" "then" "Sine" "Cosine"
14                      "psdraft" "psfull" "psscalefirst" "psrotatefirst"
15                      "psnodraftbox" "psdraftbox" "pssilent" "psnoisy"
16                      "minmaxtest"
17      '("psfig" TeX-arg-psfig)
18      '("psfigurepath" t)
19                      )
20     (LaTeX-add-environments
21      '("psfigure" LaTeX-env-psfigure)
22      )
23     ))
24  LaTeX-dialect)
25
26 (defun TeX-arg-psfig (optional)
27    "Ask for file, width and length. Insert psfig macro"
28    (let ((psfile (read-file-name "PS-file: " "" "" nil))
29          (figwidth (read-string "Figure width: "))
30          (figheight (read-string "Figure height: "))
31          )
32
33      (insert TeX-grop "figure=" psfile)
34      (if (not (zerop (length figwidth)))
35          (insert ",width=" figwidth))
36      (if (not (zerop (length figheight)))
37          (insert ",height=" figheight))
38      (insert TeX-grcl)
39      )
40    )
41
42
43 (defun LaTeX-env-psfigure (environment)
44   "Create  with \\label and \\caption and \\psfig commands."
45   (let ((float (read-string "Float to: " LaTeX-float))
46         (caption (read-string "Caption: "))
47         (label (read-string "Label: " LaTeX-figure-label))
48         ; gf: ask if this should be centered
49         (psfile (read-file-name "PS-file: " "" "" nil))
50         (figwidth (read-string "Figure width: "))
51         (figheight (read-string "Figure height: "))
52         )
53
54     (setq LaTeX-float (if (zerop (length float))
55                           LaTeX-float
56                         float))
57
58     (LaTeX-insert-environment "figure"
59                               (concat LaTeX-optop LaTeX-float LaTeX-optcl))
60
61     (insert TeX-esc "centerline" TeX-grop TeX-esc "psfig" TeX-grop
62             "figure=" psfile)
63     (if (not (zerop (length figwidth)))
64         (insert ",width=" figwidth))
65     (if (not (zerop (length figheight)))
66         (insert ",height=" figheight))
67     (insert TeX-grcl TeX-grcl)
68     (if (zerop (length caption))
69         ()
70       (newline-and-indent)
71       (insert TeX-esc "caption" TeX-grop caption TeX-grcl))
72     (if (or (zerop (length label))
73             (equal LaTeX-figure-label label))
74         ()
75       (newline-and-indent)
76       (insert TeX-esc "label" TeX-grop label TeX-grcl))
77
78     (forward-line 2)))
79
80 ;;; psfig.el ends here