changeset 424:af4fa99fabd3 dev

Beamer: column/columns
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 31 Aug 2015 22:23:02 +0900
parents e1e67b1b70e6
children 3c29f87e383b
files yatex.el yatexadd.el
diffstat 2 files changed, 56 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/yatex.el	Mon Aug 31 11:58:39 2015 +0900
+++ b/yatex.el	Mon Aug 31 22:23:02 2015 +0900
@@ -1,6 +1,6 @@
 ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*-
 ;;; (c)1991-2015 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Fri Aug 28 21:02:24 2015 on zxr
+;;; Last modified Mon Aug 31 11:59:17 2015 on zxr
 ;;; $Id$
 ;;; The latest version of this software is always available at;
 ;;; http://www.yatex.org/
@@ -361,7 +361,7 @@
      ("minipage")
      ("supertabular")
      ("wrapfigure") ("wraptable")
-     ("frame") ("block") ("example")				;beamer
+     ("frame") ("block") ("example") ("columns") ("column")	;beamer
      )
    (if YaTeX-use-LaTeX2e
        '(("comment")			;defined in version
--- a/yatexadd.el	Mon Aug 31 11:58:39 2015 +0900
+++ b/yatexadd.el	Mon Aug 31 22:23:02 2015 +0900
@@ -1,6 +1,6 @@
 ;;; yatexadd.el --- YaTeX add-in functions -*- coding: sjis -*-
 ;;; (c)1991-2015 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Mon Aug 31 11:57:05 2015 on zxr
+;;; Last modified Mon Aug 31 22:22:33 2015 on zxr
 ;;; $Id$
 
 ;;; Code:
@@ -2121,11 +2121,64 @@
 	      "Frame option: " YaTeX:frame-option-alist))
 	(title (YaTeX-read-string-or-skip "Title: "))
 	(subtitle (YaTeX-read-string-or-skip "Subtitle: ")))
+    (setq YaTeX-env-name "columns")
     (concat
      (if (string< "" opt)	(concat "[" opt "]"))
      (if (string< "" title)	(concat "{" title "}"))
      (if (string< "" subtitle)	(concat "{" subtitle "}")))))
 
+(defun YaTeX:column-read-width ()
+  "Completing function for column environment/macro of Beamer"
+  (let ((md (match-data)) (colsinf (YaTeX-quick-in-environment-p "columns"))
+	(colw (float 1)) defw cw)
+    (unwind-protect
+	(progn
+	  (save-excursion
+	    (while (YaTeX-re-search-active-backward
+		    (concat
+		     "\\\\begin{column}{\\([.0-9]+\\)\\(\\\\.*width\\)}"
+		     "\\|"
+		     "\\\\column{\\([.0-9]+\\)\\(\\\\.*width\\)}")
+		    YaTeX-comment-prefix
+		    (cdr colsinf) t)
+	      (setq colw (- colw (string-to-number
+				  (or (YaTeX-match-string 1)
+				      (YaTeX-match-string 3)))))))
+	  (setq defw (format "%.1f%s"
+			     (if (= colw (float 1))
+				 (string-to-number "0.5")
+			       colw)
+			     (or (YaTeX-match-string 2)
+				 (YaTeX-match-string 4)
+				 "\\textwidth"))
+		cw (YaTeX:read-length
+		    (format "Column width(default: %s): " defw)))
+	  (if (string= "" cw) (setq cw defw))
+	  (prog1
+	      cw
+	    (setq YaTeX-section-name "column")))
+      (store-match-data md))))
+
+(defun YaTeX:column ()
+  (if (eq YaTeX-current-completion-type 'begin)
+      (concat "{" (YaTeX:column-read-width) "}")))
+(defun YaTeX::column (argp)
+  (cond
+   ((= argp 1) (YaTeX:column-read-width))))
+(defvar YaTeX:columns-option-alist
+  '(("t") ("T") ("b") ("c") ("onlytextwidth") ("totalwidth=0.9\\linewidth"))
+  "*Default option alist for completing columns environment of Beamer")
+
+(defun YaTeX:columns ()
+  (setq YaTeX-section-name "column"
+	YaTeX-env-name "column")
+  (let*((minibuffer-local-completion-map YaTeX-minibuffer-completion-map)
+	(delim ",=")
+	(tbl (append YaTeX:columns-option-alist)) ;XX
+	(opt (YaTeX-completing-read-or-skip "columns option: " tbl)))
+    (if (string< "" opt)
+	(concat "[" opt "]"))))
+
 ;;; -------------------- math-mode stuff --------------------
 (defun YaTeX::tilde (&optional pos)
   "For accent macros in mathmode"

yatex.org