yatex

changeset 8:c746646cecf5

Restrict YaTeX:framebox in picture environment.
author yuuji
date Tue, 04 May 1993 13:00:17 +0000
parents 9a56acb6c287
children 7becca042f80
files docs/yatexadd.doc yatexadd.el
diffstat 2 files changed, 175 insertions(+), 32 deletions(-) [+]
line diff
     1.1 --- a/docs/yatexadd.doc	Tue May 04 12:57:27 1993 +0000
     1.2 +++ b/docs/yatexadd.doc	Tue May 04 13:00:17 1993 +0000
     1.3 @@ -1,25 +1,20 @@
     1.4  ------------------------------------------------------------------------
     1.5  			野鳥用付加関数の作成方法
     1.6  ------------------------------------------------------------------------
     1.7 -筆者註: ・付加関数の呼び出し方の仕様は、まだ模索段階です。
     1.8 -	・yatexadd.el のサンプル関数仕様も、大きく変更する可能性があります。
     1.9 -	・もし、本バージョンの yatexadd を手にされた場合は、今後の付加関数
    1.10 -	  の仕様について、御意見をお聞かせください。
    1.11 -	・とりあえず、begin型補完のみの対応です。
    1.12  
    1.13  
    1.14  【付加関数とは】
    1.15  
    1.16 -	  begin 型補完で、tabular 環境を入力している時に、「"c|c|c" とか、 
    1.17 -	また、table 環境の入力時に"[tbp]" とかも一緒に入力すればいいのに」
    1.18 -	などと思うことはありませんか。もちろんこれを自動入力する関数は簡単
    1.19 -	にサポートできるでしょう。
    1.20 +	  begin 型補完で、「tabular 環境を入力している時に、"{|c|c|c|}" と
    1.21 +	か、また、table 環境の入力時に"[tbp]" とかも一緒に入力すればいいの
    1.22 +	に」などと思うことはありませんか。もちろんこれを自動入力する関数は
    1.23 +	簡単にサポートできるでしょう。
    1.24  
    1.25  	  しかし、tabular 環境に限らず、LaTeX の環境の引数には、各人お決ま
    1.26  	りのフォーマットがあるものです。たとえば凝った表を書く時の tabular
    1.27  	環境の引数は、かなり複雑なので、上のような自動入力関数よりも、
    1.28  
    1.29 -		"{@{\vrule width 1pt\ }|||@{\vrule width 1pt}}"
    1.30 +		"{@{\vrule width 1pt\ }|||@{\ \vrule width 1pt}}"
    1.31  
    1.32  	を挿入するだけの単純な関数のほうが、嬉しい人もいるでしょう。あるい
    1.33  	は、「そんなの要らない。他の tabular をコピーして来たほうが早い。」
    1.34 @@ -35,7 +30,10 @@
    1.35  【準備】
    1.36  
    1.37  	  さすがに、関数を書くだけでは使えません:-)。yatex-mode 起動時には、
    1.38 -	その関数を定義したファイルがロードされていなくてはなりません。 
    1.39 +	その関数を定義したファイルがロードされていなくてはなりません。関数
    1.40 +	を定義するファイル名を yatexadd.el(またはバイトコンパイルした形式
    1.41 +	のyatexadd.elc)にし、そのファイルを load-path 中に置いておけば、 
    1.42 +	野鳥が自動的にロードします。それ以外のファイル名にする場合は、
    1.43  	yatex-mode-hook に、付加関数を定義する Emacs-Lisp ファイルをロード
    1.44  	するような仕掛けを書いておくのがよいでしょう。
    1.45  
    1.46 @@ -49,8 +47,46 @@
    1.47  
    1.48  【呼ばれ方】
    1.49  
    1.50 -	  begin型補完の場合 \begin{環境名} が自動入力された直後に呼び出さ
    1.51 -	れます。
    1.52 +	  野鳥本体は、begin型補完とsection型補完、およびmaketitle型補完の
    1.53 +	入力時に付加関数の存在を調べてから呼び出します。begin型補完の場合 
    1.54 +	\begin{環境名} が自動入力された直後に呼び出されます。section型補完
    1.55 +	では第一引数の補完の直前、maketitle型補完の場合は、コマンド名の直
    1.56 +	後(一つのスペースを挿入する直前)に呼び出されます。
    1.57 +
    1.58 +
    1.59 +【関数定義】
    1.60 +
    1.61 +	  begin型補完では、\begin{環境名}の直後に付加する文字列、section型
    1.62 +	補完では、LaTeXコマンド名と第一引数の間に位置する文字列、maketitle
    1.63 +	型補完では、LaTeXコマンド名の直後に位置する文字列を返すような関数
    1.64 +	を定義して下さい。
    1.65 +	(例)
    1.66 +		\begin{table}[ht]
    1.67 +		             ~~~~
    1.68 +		\put(100,200){}
    1.69 +		    ~~~~~~~~~
    1.70 +		\sum_{i=0}^{n} 
    1.71 +		    ~~~~~~~~~~
    1.72 +	たんに、いつでも {|c|c|c|} を入れるだけで良いのなら、
    1.73 +
    1.74 +		(defun YaTeX:tabular ()
    1.75 +		  "{|c|c|c|}")
    1.76 +
    1.77 +	とだけ、書けばよく、前述の、複雑な定型 tabular フォーマットを挿入
    1.78 +	するための関数を定義する場合は、次のようにします。
    1.79 +
    1.80 +		(defun YaTeX:tabular ()
    1.81 +		  "{@{\\vrule width 1pt\\ }|||@{\\ \\vrule width 1pt}}")
    1.82 +
    1.83 +	この時、Emacs-Lisp 中の文字列では、\ 自身は、\\ と表記することなどに
    1.84 +	注意して下さい。
    1.85 +
    1.86 +	  また、{} の中を、補完時に直接キーボードから読み込ませたい時は、
    1.87 +
    1.88 +		(defun YaTeX:tabular ()
    1.89 +		  (concat "{" (read-string "Rule: ") "}"))
    1.90 +
    1.91 +	などとすれば良いでしょう。
    1.92  
    1.93  
    1.94  【参考】
    1.95 @@ -58,6 +94,30 @@
    1.96  	  付加関数の定義の例を yatexadd.el に用意しました。実際に独自の付
    1.97  	加関数を定義する時の参考として下さい。
    1.98  
    1.99 +	  有用と思われる関数について、簡単に説明します。
   1.100 +
   1.101 +	・関数	YaTeX:read-position
   1.102 +	  引数	[] の中に入れてもよい文字を羅列した文字列。
   1.103 +	  説明	[htb] などのような location 指定を作成します。何も入力せず
   1.104 +		リターンを押すと、[]自体も省略されます。[]の中に来るべき文
   1.105 +		字が htbp に限られているなら、(YaTeX:read-position "htbp")
   1.106 +		と呼び出します。
   1.107 +
   1.108 +	・関数	YaTeX:read-coordinates
   1.109 +	  引数	基本プロンプト, X座標プロンプト, Y座標プロンプト(全て省略可)
   1.110 +	  説明	「基本プロンプト X座標プロンプト:」というプロンプトを出し
   1.111 +		て、X座標を読み込み、「基本プロンプト Y座標プロンプト:」を
   1.112 +		出して、Y座標を読み込み、(X座標,Y座標) の様な形式を作成します。
   1.113 +		何も入力せずリターンを押しても、(,)が返されます。
   1.114 +		各プロンプトのデフォルトはそれぞれ、Dimension, X, Y です。
   1.115 +
   1.116 +	・関数	YaTeX:check-comletion-type
   1.117 +	  引数	'begin または、'section または、'maketitle
   1.118 +	  説明	付加関数が呼ばれる時に、行われている補完の形式が、引数で与
   1.119 +		えたものであるかどうか調べ、そうでない場合にエラー終了する。
   1.120 +		なお、変数 YaTeX-current-completion-type に現在の補完の型
   1.121 +		を表わすシンボル(この関数の引数と同様)が格納されています。
   1.122 +
   1.123  
   1.124  【最後に】
   1.125  
   1.126 @@ -65,10 +125,7 @@
   1.127  	ら、筆者までお送り下さい。次の yatexadd.el に取り込んで行きたいと
   1.128  	思います。
   1.129  
   1.130 -【註】
   1.131 -
   1.132 -	  yatexadd は βversionです。
   1.133  
   1.134  								   広瀬雄二
   1.135 -							yuujI@ae.keio.ac.jp
   1.136 +							yuuji@ae.keio.ac.jp
   1.137  							pcs39334(ASCII-NET)
     2.1 --- a/yatexadd.el	Tue May 04 12:57:27 1993 +0000
     2.2 +++ b/yatexadd.el	Tue May 04 13:00:17 1993 +0000
     2.3 @@ -1,8 +1,9 @@
     2.4  ;;; -*- Emacs-Lisp -*-
     2.5 -;;; YaTeX add in functions.
     2.6 -;;; yatexadd.el rev.2
     2.7 +;;; YaTeX add-in functions.
     2.8 +;;; yatexadd.el rev.3
     2.9  ;;; (c)1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
    2.10 -;;; Last modified Fri Feb  5 09:36:06 1993 on gloria
    2.11 +;;; Last modified Tue May  4 21:50:37 1993 on figaro
    2.12 +;;; $Id$
    2.13  
    2.14  (provide 'yatexadd)
    2.15  
    2.16 @@ -14,46 +15,131 @@
    2.17    "*Your favorite default rule format."
    2.18  )
    2.19  (defun YaTeX:tabular ()
    2.20 -  "YaTeX add in function for tabular environment."
    2.21 -  (let (bars (rule "") (j 0) loc)
    2.22 +  "YaTeX add-in function for tabular environment."
    2.23 +  (let (bars (rule "") (j 0) (loc (YaTeX:read-position "tb")))
    2.24      (setq bars (string-to-int (read-string "Number of `|': ")))
    2.25      (if (> bars 0)
    2.26  	(while (< j bars) (setq rule (concat rule "|")) (setq j (1+ j)))
    2.27        (setq rule YaTeX:tabular-default-rule))
    2.28      (setq rule (read-string "rule format: " rule))
    2.29  
    2.30 -    (insert (format "{%s}" rule))
    2.31 -    (message ""))
    2.32 +    (message "")
    2.33 +    (format "%s{%s}" loc rule))
    2.34  )
    2.35  
    2.36 -(defun YaTeX:table ()
    2.37 -  (let ((pos ""))
    2.38 -    (message "Position []:")
    2.39 +(defun YaTeX:read-position (oneof)
    2.40 +  (let ((pos "") loc)
    2.41      (while (not (string-match
    2.42 -		 (setq loc (read-key-sequence (format "Position [%s]: " pos)))
    2.43 +		 (setq loc (read-key-sequence
    2.44 +			    (format "Position (`%s') [%s]: " oneof pos)))
    2.45  		 "\r\^g\n"))
    2.46        (cond
    2.47 -       ((string-match loc "htbp")
    2.48 +       ((string-match loc oneof)
    2.49  	(if (not (string-match loc pos))
    2.50  	    (setq pos (concat pos loc))))
    2.51         ((and (string-match loc "\C-h\C-?") (> (length pos) 0))
    2.52  	(setq pos (substring pos 0 (1- (length pos)))))
    2.53         (t
    2.54  	(ding)
    2.55 -	(message "Please input one of `htbp'.")
    2.56 +	(message "Please input one of `%s'." oneof)
    2.57  	(sit-for 3))))
    2.58 -    (if (string= pos "") nil
    2.59 -      (insert "[" pos "]")))
    2.60 +    (message "")
    2.61 +    (if (string= pos "") ""
    2.62 +      (concat "[" pos "]")))
    2.63 +)
    2.64 +
    2.65 +(defun YaTeX:table ()
    2.66 +  "YaTeX add-in function for table environment."
    2.67 +  (YaTeX:read-position "htbp")
    2.68  )
    2.69  
    2.70  (defun YaTeX:description ()
    2.71    "Truly poor service:-)"
    2.72    (setq single-command "item[]")
    2.73 +  ""
    2.74  )
    2.75  
    2.76  (defun YaTeX:itemize ()
    2.77    "It's also poor service."
    2.78    (setq single-command "item")
    2.79 +  ""
    2.80  )
    2.81  
    2.82  (fset 'YaTeX:enumerate 'YaTeX:itemize)
    2.83 +
    2.84 +;;;
    2.85 +;;Sample functions for section-type command.
    2.86 +;;;
    2.87 +(defun YaTeX:multiput ()
    2.88 +  (concat (YaTeX:read-coordinates "Pos")
    2.89 +	  (YaTeX:read-coordinates "Step")
    2.90 +	  "{" (read-string "How many times: ") "}")
    2.91 +)
    2.92 +
    2.93 +(defun YaTeX:put ()
    2.94 +  (YaTeX:read-coordinates "Pos")
    2.95 +)
    2.96 +
    2.97 +(defun YaTeX:makebox ()
    2.98 +  (concat (YaTeX:read-coordinates "Dimension")
    2.99 +	  (YaTeX:read-position "lrtb"))
   2.100 +)
   2.101 +
   2.102 +(defun YaTeX:framebox ()
   2.103 +  (if (YaTeX-quick-in-environment-p "picture")
   2.104 +      (YaTeX:makebox))
   2.105 +)
   2.106 +
   2.107 +(defun YaTeX:dashbox ()
   2.108 +  (concat "{" (read-string "Dash dimension: ") "}"
   2.109 +	  (YaTeX:read-coordinates "Dimension"))
   2.110 +)
   2.111 +
   2.112 +(defun YaTeX:read-coordinates (&optional mes varX varY)
   2.113 +  (concat
   2.114 +   "("
   2.115 +   (read-string (format "%s %s: " (or mes "Dimension") (or varX "X")))
   2.116 +   ","
   2.117 +   (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y")))
   2.118 +   ")")
   2.119 +)
   2.120 +
   2.121 +;;;
   2.122 +;;Sample functions for maketitle-type command.
   2.123 +;;;
   2.124 +(defun YaTeX:sum ()
   2.125 +  "Read range of summation."
   2.126 +  (YaTeX:check-completion-type 'maketitle)
   2.127 +  (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))
   2.128 +)
   2.129 +
   2.130 +(fset 'YaTeX:int 'YaTeX:sum)
   2.131 +
   2.132 +(defun YaTeX:lim ()
   2.133 +  "Insert limit notation of \\lim."
   2.134 +  (YaTeX:check-completion-type 'maketitle)
   2.135 +  (let ((var (read-string "Variable: ")) limit)
   2.136 +    (if (string= "" var) ""
   2.137 +      (setq limit (read-string "Limit ($ means infinity): "))
   2.138 +      (if (string= "$" limit) (setq limit "\\infty"))
   2.139 +      (concat "_{" var " \\rightarrow " limit "}")))
   2.140 +)
   2.141 +
   2.142 +(defun YaTeX:gcd ()
   2.143 +  "Add-in function for \\gcd(m,n)."
   2.144 +  (YaTeX:check-completion-type 'maketitle)
   2.145 +  (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")
   2.146 +)
   2.147 +
   2.148 +(defun YaTeX:read-boundary (ULchar)
   2.149 +  "Read boundary usage by _ or ^.  _ or ^ is indicated by argument ULchar."
   2.150 +  (let ((bndry (read-string (concat ULchar "{...}: "))))
   2.151 +    (if (string= bndry "") ""
   2.152 +      (concat ULchar "{" bndry "}")))
   2.153 +)
   2.154 +
   2.155 +(defun YaTeX:check-completion-type (type)
   2.156 +  "Check valid completion type."
   2.157 +  (if (not (eq type YaTeX-current-completion-type))
   2.158 +      (error "This should be completed with %s-type completion." type))
   2.159 +)