changeset 220:4bb77d7ee8f0 dev

Modify YaTeX:table and YaTeX:figure. User can control the place, before or after, of caption via variable YaTeX:table-caption-first or YaTeX:figure-caption-first.
author yuuji@fusion.yk.gentei.org
date Sun, 15 Jan 2012 17:00:13 +0900
parents ad4e0a008972
children 3f991b0bdcda
files yatexadd.el
diffstat 1 files changed, 36 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/yatexadd.el	Sun Jan 15 09:47:56 2012 +0900
+++ b/yatexadd.el	Sun Jan 15 17:00:13 2012 +0900
@@ -2,7 +2,7 @@
 ;;; YaTeX add-in functions.
 ;;; yatexadd.el rev.19
 ;;; (c)1991-2011 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Sun Jan 15 09:39:36 2012 on fusion
+;;; Last modified Sun Jan 15 16:24:33 2012 on fusion
 ;;; $Id$
 
 ;;;
@@ -99,23 +99,45 @@
   (let ((pos (YaTeX:read-oneof oneof)))
     (if (string= pos "")  "" (concat "[" pos "]"))))
 
+;;;
+;; Functions for figure environemnt
+;;;
+(defvar YaTeX:figure-caption-first nil
+  "Non-nil indicates put caption before figure.")
+(defun YaTeX:figure (&optional type firstp)
+  "YaTeX add-in function for figure(*) environment."
+  (let*((caption "") (label "") (opts "")
+	(top (if type firstp YaTeX:figure-caption-first))
+	(tl (or type "Figure"))
+	(heremsg (format "%% %s here" tl)))
+    (setq label (read-string (concat tl " Label: ")))
+    (if (string= "" label)
+	(setq YaTeX-section-name "label")
+      (setq opts (format "\n\\label{%s}" label)))
+    (setq caption (read-string (concat tl " Caption: ")))
+    (if (string= "" caption)
+	(setq YaTeX-section-name "caption")
+      (setq caption (format "\\caption{%s}" caption)
+	    opts (format "%s\n%s\n%s"
+			 opts
+			 (if top caption heremsg)
+			 (if top heremsg caption)))
+      (format "\\caption{%s}" caption))
+    opts))
+
+(fset 'YaTeX:figure* 'YaTeX:figure)
+
+;;;
+;; Functions for table environemnt
+;;;
+(defvar YaTeX:table-caption-first t
+  "*Non-nil indicates put caption before tabular.")
 (defun YaTeX:table ()
   "YaTeX add-in function for table environment."
   (cond
    ((eq major-mode 'yatex-mode)
-    (let (pos (caption "") (label "") (opts ""))
-      (setq pos (YaTeX:read-position "htbp")
-	    caption (read-string "Table Caption: "))
-      (if (string= "" caption)
-	  (setq YaTeX-section-name "caption")
-	(setq opts (format "\n\\caption{%s}" caption)))
-      (setq label (read-string "Label: "))
-      (if (string= "" label)
-	  (setq YaTeX-section-name "label")
-	(setq opts (format "%s\n\\label{%s}" opts label)))
-      (setq YaTeX-env-name "tabular"
-	    YaTeX-section-name "caption")
-      (concat pos opts)))
+    (setq YaTeX-env-name "tabular")
+    (YaTeX:figure "Table" YaTeX:table-caption-first))
    ((eq major-mode 'texinfo-mode)
     (concat " "
 	    (completing-read
@@ -124,25 +146,6 @@
 	     nil nil "@")))))
 (fset 'YaTeX:table* 'YaTeX:table)
 
-;;;
-;; Functions for figure environemnt
-;;;
-(defun YaTeX:figure ()
-  "YaTeX add-in function for figure(*) environment."
-  (let ((caption "") (label "") (opts ""))
-    (setq label (read-string "Figure Label: "))
-    (if (string= "" label)
-	(setq YaTeX-section-name "label")
-      (setq opts (format "\n\\label{%s}" label)))
-    (setq caption (read-string "Figure Caption: "))
-    (if (string= "" caption)
-	(setq YaTeX-section-name "caption")
-      (setq opts (format "%s\n%% figure here\n\\caption{%s}" opts caption)))
-    opts))
-
-(fset 'YaTeX:figure* 'YaTeX:figure)
-
-
 (defun YaTeX:description ()
   "Truly poor service:-)"
   (setq YaTeX-single-command "item[]")

yatex.org