yatex
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 diff
1.1 --- a/yatexadd.el Sun Jan 15 09:47:56 2012 +0900 1.2 +++ b/yatexadd.el Sun Jan 15 17:00:13 2012 +0900 1.3 @@ -2,7 +2,7 @@ 1.4 ;;; YaTeX add-in functions. 1.5 ;;; yatexadd.el rev.19 1.6 ;;; (c)1991-2011 by HIROSE Yuuji.[yuuji@yatex.org] 1.7 -;;; Last modified Sun Jan 15 09:39:36 2012 on fusion 1.8 +;;; Last modified Sun Jan 15 16:24:33 2012 on fusion 1.9 ;;; $Id$ 1.10 1.11 ;;; 1.12 @@ -99,23 +99,45 @@ 1.13 (let ((pos (YaTeX:read-oneof oneof))) 1.14 (if (string= pos "") "" (concat "[" pos "]")))) 1.15 1.16 +;;; 1.17 +;; Functions for figure environemnt 1.18 +;;; 1.19 +(defvar YaTeX:figure-caption-first nil 1.20 + "Non-nil indicates put caption before figure.") 1.21 +(defun YaTeX:figure (&optional type firstp) 1.22 + "YaTeX add-in function for figure(*) environment." 1.23 + (let*((caption "") (label "") (opts "") 1.24 + (top (if type firstp YaTeX:figure-caption-first)) 1.25 + (tl (or type "Figure")) 1.26 + (heremsg (format "%% %s here" tl))) 1.27 + (setq label (read-string (concat tl " Label: "))) 1.28 + (if (string= "" label) 1.29 + (setq YaTeX-section-name "label") 1.30 + (setq opts (format "\n\\label{%s}" label))) 1.31 + (setq caption (read-string (concat tl " Caption: "))) 1.32 + (if (string= "" caption) 1.33 + (setq YaTeX-section-name "caption") 1.34 + (setq caption (format "\\caption{%s}" caption) 1.35 + opts (format "%s\n%s\n%s" 1.36 + opts 1.37 + (if top caption heremsg) 1.38 + (if top heremsg caption))) 1.39 + (format "\\caption{%s}" caption)) 1.40 + opts)) 1.41 + 1.42 +(fset 'YaTeX:figure* 'YaTeX:figure) 1.43 + 1.44 +;;; 1.45 +;; Functions for table environemnt 1.46 +;;; 1.47 +(defvar YaTeX:table-caption-first t 1.48 + "*Non-nil indicates put caption before tabular.") 1.49 (defun YaTeX:table () 1.50 "YaTeX add-in function for table environment." 1.51 (cond 1.52 ((eq major-mode 'yatex-mode) 1.53 - (let (pos (caption "") (label "") (opts "")) 1.54 - (setq pos (YaTeX:read-position "htbp") 1.55 - caption (read-string "Table Caption: ")) 1.56 - (if (string= "" caption) 1.57 - (setq YaTeX-section-name "caption") 1.58 - (setq opts (format "\n\\caption{%s}" caption))) 1.59 - (setq label (read-string "Label: ")) 1.60 - (if (string= "" label) 1.61 - (setq YaTeX-section-name "label") 1.62 - (setq opts (format "%s\n\\label{%s}" opts label))) 1.63 - (setq YaTeX-env-name "tabular" 1.64 - YaTeX-section-name "caption") 1.65 - (concat pos opts))) 1.66 + (setq YaTeX-env-name "tabular") 1.67 + (YaTeX:figure "Table" YaTeX:table-caption-first)) 1.68 ((eq major-mode 'texinfo-mode) 1.69 (concat " " 1.70 (completing-read 1.71 @@ -124,25 +146,6 @@ 1.72 nil nil "@"))))) 1.73 (fset 'YaTeX:table* 'YaTeX:table) 1.74 1.75 -;;; 1.76 -;; Functions for figure environemnt 1.77 -;;; 1.78 -(defun YaTeX:figure () 1.79 - "YaTeX add-in function for figure(*) environment." 1.80 - (let ((caption "") (label "") (opts "")) 1.81 - (setq label (read-string "Figure Label: ")) 1.82 - (if (string= "" label) 1.83 - (setq YaTeX-section-name "label") 1.84 - (setq opts (format "\n\\label{%s}" label))) 1.85 - (setq caption (read-string "Figure Caption: ")) 1.86 - (if (string= "" caption) 1.87 - (setq YaTeX-section-name "caption") 1.88 - (setq opts (format "%s\n%% figure here\n\\caption{%s}" opts caption))) 1.89 - opts)) 1.90 - 1.91 -(fset 'YaTeX:figure* 'YaTeX:figure) 1.92 - 1.93 - 1.94 (defun YaTeX:description () 1.95 "Truly poor service:-)" 1.96 (setq YaTeX-single-command "item[]")