File: psfig.el

package info (click to toggle)
auctex 11.91-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,952 kB
  • sloc: lisp: 45,907; makefile: 890; sh: 112; perl: 90
file content (84 lines) | stat: -rw-r--r-- 2,634 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;;; psfig.el - Support for the psfig style option.

;; Copyright (C) 2013-2014 Free Software Foundation, Inc.

;; Contributed by Marc Gemis <makke@wins.uia.ac.be>
;; Please direct comments to him.

;;; Code:

(TeX-add-style-hook "psfig"
 (function
  (lambda ()
	;; probable some of the following symbols may be removed
    (TeX-add-symbols "protect" "figurepath"  "fbox"
		     "other" "letter" "other" "then" "Sine" "Cosine"
		     "psdraft" "psfull" "psscalefirst" "psrotatefirst"
		     "psnodraftbox" "psdraftbox" "pssilent" "psnoisy"
		     "minmaxtest"
     '("psfig" TeX-arg-psfig)
     '("psfigurepath" t)
		     )
    (LaTeX-add-environments
     '("psfigure" LaTeX-env-psfigure)
     )
    ))
 LaTeX-dialect)

(defun TeX-arg-psfig (_optional)
   "Ask for file, width and length. Insert psfig macro"
   (let ((psfile (read-file-name "PS-file: " "" "" nil))
	 (figwidth (TeX-read-string "Figure width: "))
	 (figheight (TeX-read-string "Figure height: "))
	 )

     (insert TeX-grop "figure=" psfile)
     (if (not (zerop (length figwidth)))
	 (insert ",width=" figwidth))
     (if (not (zerop (length figheight)))
	 (insert ",height=" figheight))
     (insert TeX-grcl)
     )
   )


(defun LaTeX-env-psfigure (_environment)
  "Create  with \\label and \\caption and \\psfig commands."
  (let* ((float (TeX-read-string "Float to: " LaTeX-float))
         (caption (TeX-read-string "Caption: "))
         (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length)
                          (TeX-read-string "(Optional) Short caption: ")))
         (label (TeX-read-string "Label: " LaTeX-figure-label))
         ; gf: ask if this should be centered
         (psfile (read-file-name "PS-file: " "" "" nil))
         (figwidth (TeX-read-string "Figure width: "))
         (figheight (TeX-read-string "Figure height: "))
         )

    (setq LaTeX-float (if (zerop (length float))
			  LaTeX-float
			float))

    (LaTeX-insert-environment "figure"
			      (concat LaTeX-optop LaTeX-float LaTeX-optcl))

    (insert TeX-esc "centerline" TeX-grop TeX-esc "psfig" TeX-grop
	    "figure=" psfile)
    (if (not (zerop (length figwidth)))
	(insert ",width=" figwidth))
    (if (not (zerop (length figheight)))
	(insert ",height=" figheight))
    (insert TeX-grcl TeX-grcl)
    (if (zerop (length caption))
	()
      (newline-and-indent)
      (insert (LaTeX-compose-caption-macro caption short-caption)))
    (if (or (zerop (length label))
	    (equal LaTeX-figure-label label))
	()
      (newline-and-indent)
      (insert TeX-esc "label" TeX-grop label TeX-grcl))

    (forward-line 2)))

;;; psfig.el ends here