1 ;;; psfig.el - Support for the psfig style option.
3 ;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
5 ;; Contributed by Marc Gemis <makke@wins.uia.ac.be>
6 ;; Please direct comments to him.
10 (TeX-add-style-hook "psfig"
13 ;; probable some of the following symbols may be removed
14 (TeX-add-symbols "protect" "figurepath" "fbox"
15 "other" "letter" "other" "then" "Sine" "Cosine"
16 "psdraft" "psfull" "psscalefirst" "psrotatefirst"
17 "psnodraftbox" "psdraftbox" "pssilent" "psnoisy"
19 '("psfig" TeX-arg-psfig)
22 (LaTeX-add-environments
23 '("psfigure" LaTeX-env-psfigure)
28 (defun TeX-arg-psfig (_optional)
29 "Ask for file, width and length. Insert psfig macro"
30 (let ((psfile (read-file-name "PS-file: " "" "" nil))
31 (figwidth (TeX-read-string "Figure width: "))
32 (figheight (TeX-read-string "Figure height: "))
35 (insert TeX-grop "figure=" psfile)
36 (if (not (zerop (length figwidth)))
37 (insert ",width=" figwidth))
38 (if (not (zerop (length figheight)))
39 (insert ",height=" figheight))
45 (defun LaTeX-env-psfigure (_environment)
46 "Create with \\label and \\caption and \\psfig commands."
47 (let* ((float (TeX-read-string "Float to: " LaTeX-float))
48 (caption (TeX-read-string "Caption: "))
49 (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length)
50 (TeX-read-string "(Optional) Short caption: ")))
51 (label (TeX-read-string "Label: " LaTeX-figure-label))
52 ; gf: ask if this should be centered
53 (psfile (read-file-name "PS-file: " "" "" nil))
54 (figwidth (TeX-read-string "Figure width: "))
55 (figheight (TeX-read-string "Figure height: "))
58 (setq LaTeX-float (if (zerop (length float))
62 (LaTeX-insert-environment "figure"
63 (concat LaTeX-optop LaTeX-float LaTeX-optcl))
65 (insert TeX-esc "centerline" TeX-grop TeX-esc "psfig" TeX-grop
67 (if (not (zerop (length figwidth)))
68 (insert ",width=" figwidth))
69 (if (not (zerop (length figheight)))
70 (insert ",height=" figheight))
71 (insert TeX-grcl TeX-grcl)
72 (if (zerop (length caption))
75 (insert (LaTeX-compose-caption-macro caption short-caption)))
76 (if (or (zerop (length label))
77 (equal LaTeX-figure-label label))
80 (insert TeX-esc "label" TeX-grop label TeX-grcl))
84 ;;; psfig.el ends here