changeset 80:9b4354af748c

Too many changes from 1.72. See yatex.new. (Japanese)
author yuuji
date Sun, 24 Dec 2006 06:16:52 +0000
parents 0734be649cb8
children dacfb49eec6e
files docs/htmlqa docs/htmlqa.eng docs/qanda docs/yatex.ref docs/yatexe.tex docs/yatexj.tex help/YATEXHLP.eng help/YATEXHLP.jp yahtml.el yatex.new yatex19.el yatexadd.el yatexenv.el yatexhks.el yatexhlp.el yatexlib.el yatexmth.el yatexpkg.el yatexprc.el
diffstat 19 files changed, 2517 insertions(+), 543 deletions(-) [+]
line wrap: on
line diff
--- a/docs/htmlqa	Thu Dec 25 04:10:32 2003 +0000
+++ b/docs/htmlqa	Sun Dec 24 06:16:52 2006 +0000
@@ -126,7 +126,7 @@
 	の機能強化版 auto-insert-tkld を使いましょう。後者は、
 	ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z
 	で入手できます。
-	http://www-nagao.kuee.kyoto-u.ac.jp/member/tsuchiya/elisp/yahtml-mode.html
+	http://namazu.org/~tsuchiya/elisp/yahtml-mode.html
 	に設定例が書いてあります。
 	
 ■その他
--- a/docs/htmlqa.eng	Thu Dec 25 04:10:32 2003 +0000
+++ b/docs/htmlqa.eng	Sun Dec 24 06:16:52 2006 +0000
@@ -63,7 +63,7 @@
 	option is to use auto-insert-tkld.  The latter can be found at
 	ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z
 	Examples in Japanese are at
-	http://www-nagao.kuee.kyoto-u.ac.jp/member/tsuchiya/elisp/yahtml-mode.html
+	http://namazu.org/~tsuchiya/elisp/yahtml-mode.html
 	
 [ETC]
 ============
--- a/docs/qanda	Thu Dec 25 04:10:32 2003 +0000
+++ b/docs/qanda	Sun Dec 24 06:16:52 2006 +0000
@@ -4,7 +4,9 @@
 %% C-u C-x $ とすると質問項目だけ表示されます。C-x $ で元に戻ります。
 %%
 
-(新項目:・font-lock はどうやって使えばいいんでしょ?
+(新項目:・RefTeXは使えますか?
+	・自分で定義したカウンタを\ref補完でのラベル候補対象として認識させたい
+	・font-lock はどうやって使えばいいんでしょ?
 	・XEmacsでも色は着きますか?
 	・{\it }内部では斜体に {\bf }では太字になるという噂を聞いたんですが…)
 
@@ -277,6 +279,96 @@
 	を .emacs に入れてみましょう。
 	
 	
+・RefTeXは使えますか?
+	
+	使っている人はいるみたいですから使えるんじゃないでしょうか。でも
+	ですね、野鳥の \ref 補完があれば、RefTeXなんぞ要らないと思います
+	よ。これからは\label{}はいちいち自分では作らずにいきなり[prefix]
+	s で \ref を打ち込みましょう。勝手にラベルを打てそうなところを探
+	して勝手にラベルを打ってその名前を\refに入れてくれます。\ref補完
+	は \label{} と \ref{} 両方同時に補完入力します。
+	
+	でですね、\ref補完の方がしょぼいと思うなら改良しますよ。「RefTeX
+	の方が色がついてかっちょええ」という問題以外ならすぐに頑張ります。
+	
+・自分で定義したカウンタを\ref補完でのラベル候補対象として認識させたい
+	
+	おお、これは高度な質問でござるよ。ちみすごいね。え、質問の意味が
+	分からん? じゃLaTeXのおべんきょーから。
+	
+	たとえば、プログラムリストなんかには図表と同じように番号を付けた
+	い。そゆときあるっしょ。そういうときには定理型環境を newtheorem 
+	で定義するですよ。たとえば、セクション番号に連動してつくようなプ
+	ログラムリスト環境を作りたいとしましょ−。そしたらこうします。
+	
+	\newtheorem{Program}{リスト}[section]
+	
+	こうすると \begin{Program} ... \end{Program} とするとタイプセッ
+	ト結果が
+	
+		リスト 2.4.1 ...
+	
+	なんてなるわけですな。かっちょえー。さて、このままだとこの2.4.1 
+	という番号を\refで引っ張るためには\labelを作らないとあかんわけで
+	すよ。でもどうせ自分で環境を定義するならlabelも自動的に定義しちゃ
+	うようなマクロを定義しちゃった方が御便利なわけですよ。 もっとい
+	うと独自に定義したカウンタのどの位置に \label を打たせるかを野鳥
+	に判断させるためのパターンを書くのはものすごくむずかしいので、ラ
+	ベルを定義するためのマクロのパターンを教えた方がやりやすいわけで
+	す。ということで、暗黙でラベルも打たせるような環境を定義すると、
+	こんな感じ。
+
+	\newenvironment{program}[1]{
+	\begin{table}[tbp]
+	\begin{Program}\filename{#1}\nopagebreak[4]\label{#1}\end{Program}
+	\nopagebreak[4]
+	\begin{breakbox}\small
+	}{
+	\end{breakbox}
+	\end{table}
+	}
+	
+	この小文字 program 環境は
+	
+	\begin{program}{foo.c}
+	\begin{verbatim}
+	#include <stdio.h>
+	\end{verbatim}
+	\end{program}
+	
+	みたいにするとタイプセット結果が
+	
+		リスト 2.4.1 foo.c
+		┌──────────────┐
+		│#include <stdio.h>          │
+		└──────────────┘
+	
+	てな具合になるわけですよ。おおかちょええ。さて、小文字program環
+	境のマクロ定義を良く見ると環境に渡した foo.c はそのまま
+	\label{#1} でラベルとして自動的に打たれることになる。あ、pLaTeX 
+	のラベルは日本語もOKよ。で、その暗黙のうちに打たれたラベル名を野
+	鳥に教えるというのがスマートなやり方です。これを定義するのが変数
+	YaTeX::ref-labeling-regexp-alist-private なり。これには
+	
+	(正規表現 . ラベル名のグループ番号)
+	
+	という組(consセル)がたくさん集まったリストを定義する。たとえば、
+	上記のprogram環境の第1引数を拾わせるには
+	
+	(setq YaTeX::ref-labeling-regexp-alist-private
+	      '(("\\\\begin{program}{\\([^}]+\\)}" . 1)))
+	
+	とします。program環境の第一引数の部分の正規表現が
+	
+		{\\([^}]+\\)}
+	
+	の部分で、\\( \\) のグループ化された正規表現 [^}]+ つまり、閉じ
+	中括弧以外の文字が続くところ、がラベル名として取り出せるわけです。
+	ということで、上記のようなLaTeXマクロの定義と
+	YaTeX::ref-labeling-regexp-alist-private の定義で無事、自分なり
+	のカウンタとそのラベル名を\ref補完に取り込めるわけです。最初は面
+	倒臭いけど、一度定義しちゃえば一生モノでっせ!
+	
 ■Mule2 関連
 ・Mule2+hilit19を使っている時に数式が暗くて良く読めない。
 	
@@ -493,7 +585,7 @@
 	Emacs.Font: fontset-tt
 	
 	これにより、やはり野鳥が自動的に和文 italic, bold フォントを検索
-	し、
+	し、画面表示上の見映えを変えるようにしてくれます。
 	
 	Windowsではもっとフォント環境が充実しているのでより簡単に設定で
 	きるのではないかと思いますが、私はそのやり方を知りません。ご存知
@@ -556,8 +648,8 @@
 	  n や p でごちゃごちゃやります。
 	
 	こんな感じですかね。
-	あとは、イメージ補完、数式モード自動判定なんてのもAUCにはありま
-	せん。
+	あとは、イメージ補完、数式モード自動判定、先回りusepackageなんて
+	のもAUCにはありません。
 	
 ・なんで構成ファイルがいまさらSJISなの? だっせー。
 	
@@ -572,13 +664,6 @@
 	慮してしまう可能性を考えると、やはり野鳥はSJISであり続けるべきだ
 	と思います。
 	
-	Emacs20の一部のバージョンで、文字列に漢字を含むEmacs-Lispファイ
-	ルをバイトコンパイルすると化けてしまうものがあるのは知っています
-	が、それはEmacs20の非です。しかしそれはいずれ直されるであろうバ
-	グであり、Emacs20を使いこなしているヴェテランのちょっとした手間
-	を軽減するためにJISコードなどに変更して、Emacs初心者に対する益を
-	失いたくありません。
-	
 	そういうわけで、野鳥ではダサくても嫌いでも、SJISを使います。
 	
 ・メイリングリストはないんですか?
--- a/docs/yatex.ref	Thu Dec 25 04:10:32 2003 +0000
+++ b/docs/yatex.ref	Sun Dec 24 06:16:52 2006 +0000
@@ -157,6 +157,7 @@
 
 
 	◆インクルード構造ブラウズ	[prefix] d
+	◆font-lockし直しメニュー	[prefix] u
 
 							       広瀬雄二
 						       yuuji@yatex.org
--- a/docs/yatexe.tex	Thu Dec 25 04:10:32 2003 +0000
+++ b/docs/yatexe.tex	Sun Dec 24 06:16:52 2006 +0000
@@ -5,7 +5,7 @@
 
 @iftex
 @c @syncodeindex fn cp
-@c Last modified Fri Sep 12 12:04:11 2003 on firestorm
+@c Last modified Wed Jul 20 21:27:50 2005 on firestorm
 @syncodeindex vr cp
 @end iftex
 
@@ -88,6 +88,10 @@
 @item Online help for the popular La@TeX{} commands
       (@kbd{C-c ?}, @kbd{C-c /})
 @item Document files hierarchy browser (@kbd{C-c d})
+@item Adding automatically \usepackage corresponding to inputting LaTeX
+      macro with completion
+@item Allow you to forget creating \label{}s, \ref or \cite completion
+      automatically generate labels.
 @end itemize
 
 @node Installation, Typesetting, Main features, Top
@@ -268,6 +272,10 @@
 @noindent
 Note that YaTeX  assumes the component  before the  last period of
 the last word in this line as base name of the main La@TeX{} source.
+The @code{%f} notation in this line is replaced by main file name, and
+@code{%r} replaced by root name of main file name.  If you specify
+@code{%f} or @code{%r}, YaTeX always ask you the name of main file at the
+first typesetting.
 
   To make best use of the feature of inter-file jumping by
 @kbd{[prefix] g} (see @ref{Cursor jump}), take described below into
@@ -1812,6 +1820,53 @@
 Consult the value of @code{YaTeX-package-alist-default} as an example.
 @end defvar
 
+@defvar YaTeX-tabular-indentation
+At indentation by @kbd{C-i} in tabular or array environment, 
+YaTeX put the additional spaces to the normail indentation depth.
+The number of additional spaces is the product of YaTeX-tabular-indentation
+and the number of column position in tabular.
+@end defvar
+
+@defvar YaTeX-noindent-env-regexp
+Regexp of environment names that should begin with no indentation.
+All verbatime-like environment name should match with.
+@end defvar
+
+@defvar YaTeX-ref-default-label-string
+Default \\ref time string format.
+This format is like strftime(3) but allowed conversion char are as follows;
+%y -> Last 2 digit of year,  %b -> Month name,  %m -> Monthe number(1-12),
+%d -> Day,  %H -> Hour,  %M -> Minute,  %S -> Second,
+%qx -> alphabetical-decimal conversion of yymmdd.
+%qX -> alphabetical-decimal conversion of HHMMSS.
+Beware defualt label-string should be always unique.  So this format string
+should have both time part (%H+%M+%S or %qX) and date
+part (%y+(%b|%m)+%d or %qx).
+@end defvar
+
+@defvar YaTeX-ref-generate-label-function
+Function to generate default label string for unnamed \\label{}s.
+The function pointed to this value should take two arguments.
+First argument is LaTeX macro's name, second is macro's argument.
+Here is an example for using this value.
+@lisp
+  (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label)
+  (defun my-yatex-generate-label (command value)
+    (and (string= command "caption")
+         (re-search-backward "\\\\begin{\\(figure\\|table\\)}" nil t)
+         (setq command (match-string 1)))
+    (let ((alist '(("chapter" . "chap")
+                   ("section" . "sec")
+                   ("subsection" . "subsec")
+                   ("figure" . "fig")
+                   ("table" . "tbl"))))
+      (if (setq command (cdr (assoc command alist)))
+          (concat command ":" value)
+        (YaTeX::ref-generate-label nil nil))))
+@end lisp
+@end defvar
+
+
 @node Sample definitions, Hook variables, All customizable variables, Lisp variables
 @comment  node-name,  next,  previous,  up
 @subsection Sample definitions
@@ -2315,16 +2370,18 @@
 @comment  node-name,  next,  previous,  up
 @chapter Copying
 
-  This program  is distributed   as a   free  software.   You  can
-redistribute this software freely but with NO warranty to anything
-as a result  of using this  software.   However, any  reports  and
-suggestions are  welcome as  long as I   feel  interests in   this
-software.   My possible  e-mail address is  `yuuji@@yatex.org'.
-(up to Sep.2003 at least)  And there is mailing list for YaTeX.
-Although the common language is Japanese, questions in English will be
-welcome.  To join the ML, send the mail whose subject is `append' to
-the address `yatex@@yatex.org.  If you have some
-question, please ask to `yatex-admin@@yatex.org'.
+  This   program   is  distributed   as   a   free   software.   You   can
+use/copy/modify/redistribute this software freely  but with NO warranty to
+anything  as a result  of using  this software.   Adopting code  from this
+program is  also free.  But  I would not  do contract act.
+
+Any reports  and suggestions are  welcome as long  as I feel  interests in
+this software.  My possible  e-mail address is `yuuji@@yatex.org'.  (as of
+Jan.2004)  And there  is  mailing  list for  YaTeX.   Although the  common
+language is Japanese,  questions in English will be  welcome.  To join the
+ML,   send  the   mail  whose   subject   is  `append'   to  the   address
+`yatex@@yatex.org.    If   you  have   some   question,   please  ask   to
+`yatex-admin@@yatex.org'.
 
   The specification of this software will be surely modified
 (depending on my feelings) without notice :-p.
--- a/docs/yatexj.tex	Thu Dec 25 04:10:32 2003 +0000
+++ b/docs/yatexj.tex	Sun Dec 24 06:16:52 2006 +0000
@@ -10,7 +10,7 @@
 @c ノードいじったら C-l C-u C-n 全部のノード更新 C-l C-u C-e
 @c メニュー増やしたら C-l C-u C-m 全部のメニュー更新 C-l C-u C-a
 @c フォーマットするときは C-l C-e C-b
-@c Last modified Fri Aug 29 01:55:00 2003 on firestorm
+@c Last modified Wed Jul 20 21:25:48 2005 on firestorm
 @syncodeindex vr cp
 @end iftex
 
@@ -20,7 +20,7 @@
 @subtitle Yet Another tex-mode for emacs
 @title 『野鳥』
 @subtitle // YaTeX //
-@author @copyright{} 1991-2003 by    HIROSE, Yuuji [yuuji@@yatex.org]
+@author @copyright{} 1991-2004 by    HIROSE, Yuuji [yuuji@@yatex.org]
 @end titlepage
 
 @node Top, Intro, (dir), (dir)
@@ -139,6 +139,9 @@
 @item 標準的 La@TeX{} コマンドのオンラインヘルプ(@kbd{C-c ?}, @kbd{C-c /})
 @item ドキュメントのインクルード構造の視覚的表示とバッファ切り替え
 (@kbd{C-c d})
+@item 補完入力したマクロに応じて必要な \userpackage を入れてくれる先回り
+userpackage
+@item \labelを打つことはもう忘れよう! refやcite補完入力で自動生成します
 @end itemize
 
 @node Installation, Invocation, Main features, Top
@@ -368,6 +371,10 @@
 
 なお、この行の最後の単語のピリオド以前を「メインファイル」のベース
 ネームであると仮定します(上の2つの場合どちらも@file{main})。
+この行に記述した、@code{%f}はメインファイル名に、
+@code{%r} はメインファイルの拡張子を取り除いた部分に置換されます。
+ただし、@code{%f,%r}を利用した場合、初回タイプセット時に必ずメインファイル
+名の入力を促されます。
 
   @kbd{[prefix] g} (@ref{Cursor jump}参照) での
 ファイル間ジャンプを有効に機能させるため、入力ファイル分割時には次のことに
@@ -712,6 +719,7 @@
 * Enclose section-type command::  括り補完
 * Recursive completion::        再帰補完
 * view-sectioning::             セクション区切りのアウトライン表示
+* label-generation::            ラベル自動生成
 @end menu
 
 @node 2個以上の引数をとる section型コマンド, Enclose section-type command, section型補完, section型補完
@@ -765,7 +773,7 @@
 型コマンドの引数に更に La@TeX{} コマンドが来る場合にはミニバッファで野鳥の
 補完キーを再帰的に入力することで引数の入力も効率的に行なえます。
 
-@node view-sectioning,  , Recursive completion, section型補完
+@node view-sectioning, label-generation, Recursive completion, section型補完
 @comment  node-name,  next,  previous,  up
 @subsection セクション区切りのアウトライン表示
 @cindex アウトライン[あうとらいん]
@@ -817,6 +825,19 @@
 @cindex セクション区切り[せくしよんくきり]
 @cindex ジャンプ[しやんふ]
 
+@node label-generation,  , view-sectioning, section型補完
+@comment  node-name,  next,  previous,  up
+@subsection ラベル自動生成
+@cindex ラベル自動生成[らへるしとうせいせい]
+
+  @code{\ref@{@}} や @code{\cite{@@}} マクロをsection型補完で入れた場合
+参照先となり得るものを全て探してメニューにして選択できます。参照先には
+@code{\label@{@}}をつけておく必要はありません。もしあれば、そのラベルを
+使い、なければその場で参照先に@code{\label@{@}}を作らせてくれます。
+ラベル名を考えるのは苦痛に感じるものです。全てのカウンタにラベルを
+つけるのもたいへんです。もうラベル名に何をつけるか、ラベルをつけるかつけま
+いか、などということは忘れましょう!
+
 @node large型補完, maketitle型補完, section型補完, Completion
 @comment  node-name,  next,  previous,  up
 @section large型補完
@@ -1554,6 +1575,7 @@
 いでしょう。@file{yatexenv.el}内の関数 
 @code{YaTeX-intelligent-newline-itemize} の定義などを参考にしてください。
 
+
 @node Usepackage cheker, Changing mode of YaTeX, Intelligent newline, Top
 @comment  node-name,  next,  previous,  up
 @chapter 先回りusepackage
@@ -2017,6 +2039,50 @@
 の値参照。
 @end defvar
 
+@defvar YaTeX-tabular-indentation
+tabular/array 環境で現在行の先頭位置が表の第Nカラムのときは
+標準インデント位置から N*YaTeX-tabular-indentation 桁下げた
+インデントにする。
+@end defvar
+
+@defvar YaTeX-noindent-env-regexp
+別の環境内にあっても \begin{} が行頭から始まるべき環境名の正規表現。
+verbatim環境などを指定する。
+@end defvar
+
+@defvar YaTeX-ref-default-label-string
+\ref{} のラベル補完でラベル未設定のものに自動的に生成する
+ラベル名の書式。strftime(3)関数に似た日付ベースで指定する。
+利用できる書式は以下のとおり。
+%y -> 西暦下二桁,  %b -> 月の英名,  %m -> 月(1〜12)
+%d -> 日,  %H -> 時,  %M -> 分,  %S -> 秒,
+%qx -> アルファベットで26進数化した yymmdd.
+%qX -> アルファベットで26進数化した HHMMSS.
+デフォルトは "%H%M%S_%d%b%y"
+@end defvar
+
+@defvar YaTeX-ref-generate-label-function
+\ref{}のラベル名自動生成のときに使う関数のシンボル。
+デフォルトは標準の YaTeX::ref-generate-label 関数が割り当ててある。
+引数を2つ取る関数を定義して、この変数にセットするとその関数を呼んだ
+結果をデフォルトのラベル名候補とする。設定例:
+@lisp
+  (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label)
+  (defun my-yatex-generate-label (command value)
+    (and (string= command "caption")
+         (re-search-backward "\\\\begin{\\(figure\\|table\\)}" nil t)
+         (setq command (match-string 1)))
+    (let ((alist '(("chapter" . "chap")
+                   ("section" . "sec")
+                   ("subsection" . "subsec")
+                   ("figure" . "fig")
+                   ("table" . "tbl"))))
+      (if (setq command (cdr (assoc command alist)))
+          (concat command ":" value)
+        (YaTeX::ref-generate-label nil nil))))
+@end lisp
+@end defvar
+
 @node Sample definitions, Hook variables, All customizable variables, Lisp variables
 @comment  node-name,  next,  previous,  up
 @subsection カスタマイズ変数設定例
@@ -2104,11 +2170,15 @@
 
   本プログラムはフリーソフトウェアです。本プログラムを使用して生じたいかな
 る結果に対しても作者は責任を負わないこととします。転載等に関しては制限いた
-しません。常識的に扱ってください。また、使用している旨をメイルでお知らせい
-ただくと、作者は喜んでサポートに励むことでしょう。
+しません。常識的に扱ってください。また、本プログラムに含まれるコードを利用
+すること、改造することも自由に行なって構いませんが、流用することにより契約
+締結の必要が生じる場合、私はいかなる契約も締結しません。具体的にはGPLへの
+サインはしませんので、GNUに寄贈するものを作っている場合私の作品から取り込
+んだコードを流用すると苦労するかもしれません。いかなるコード流用も拒否しま
+せんが契約締結は辞退します。
 
   苦情、希望、バグ報告、感想等は歓迎いたします。
-連絡は yuuji@@yatex.org まで(2003年9月現在)。
+連絡は yuuji@@yatex.org まで(2004年1月現在)。
 継続的に使用してくださる方はメイリングリスト「fj野鳥の会」に
 是非加入してください。加入方法については本パッケージの @file{docs/qanda}
 ファイルの「その他」の章を御覧ください。
--- a/help/YATEXHLP.eng	Thu Dec 25 04:10:32 2003 +0000
+++ b/help/YATEXHLP.eng	Sun Dec 24 06:16:52 2006 +0000
@@ -2,7 +2,8 @@
 %%% YaTeX-LaTeX Help File(c)HIROSE Yuuji [yuuji@yatex.org]
 %%% You can translate this file for any device other than YaTeX via
 %%% any filter program.  But it is not allowed to remove copyright
-%%% notice and any existing dictionary entiries.
+%%% notice and any existing dictionary entiries which describes the
+%%% source of this file.
 %%%
 
 textfloatsep
@@ -374,16 +375,30 @@
 \setcounter{FOO}{VAL}
 Set counter FOO's value to VAL.
 
+<refer How to Introduce new counter>
+
 addtocounter
 \addtocounter{FOO}{VAL}
 Add value VAL to counter FOO.
 
+<refer How to Introduce new counter>
+
 newcounter
 \newcounter{COUNTER}[OLDCTR]
 Defines a new counter COUNTER.
 If an optional argument OLDCTR is given, COUNTER's value will be reset
 every time OLDCTR's value is changed by \stepcounter or \addtocounter.
 
+<refer How to Introduce new counter>
+
+How to Introduce new counter
+You'll get `Question n.' increasing n with \mondai, by setting as below.
+
+\newcounter{toi}
+\renewcommand{\thetoi}{Question \arabic{toi}.~ }
+\setcounter{toi}{0}
+\newcommand{\mondai}{\refstepcounter{toi}\thetoi}
+
 value
 \value{COUNTER}
 Returns value of COUNTER.  Must not be preceded by \protect.
@@ -442,7 +457,7 @@
 LABELs set in an item of the enumerate environment.
 
 pageref
-pageref{LABEL}
+\pageref{LABEL}
 Refer to the page number where \label{LABEL} exists.
 
 (
@@ -669,11 +684,13 @@
 makebox
 \makebox[WID][POS]{OBJECT}	\makebox(X,Y)[POS]{OBJECT}
 First form will place OBJECT at position POS and width WID in a \box.
-For POS, object will be placed flush-left if l, flush-right if r, and
-centered if nothing is given
-In the second form, object will be placed in a \hbox sized (X,Y) (in
+For POS, object will be placed flush-left if `l', flush-right if `r', 
+splattering words in the same space if `s', and centered if nothing is given
+in the second form, object will be placed in a \hbox sized (X,Y) (in
 \unitlength) within a picture environment.  POS is the same as the first form.
 
+
+
 mbox
 \mbox{OBJECT}
 Same as \makebox{OBJECT}.
@@ -695,7 +712,7 @@
 Same as \savebox.  \sbox is robust, and \savebox is fragile.
 
 framebox
-\framebox{OBJECT}
+\framebox[WID][POS]{OBJECT}	\framebox(X,Y)[POS]{OBJECT}
 Do the same thing as \makebox with a frame.
 The frame's width and space between the object are decided by \framerule
 and \framesep.  If used as \framebox(X,Y){OBJECT} in a picture
@@ -708,6 +725,13 @@
 Same as \framebox{OBJECT}.
 \fbox is robust, \framebox fragile.
 
+Rule width of \fbox can be controled by setting \fboxrule
+
+  {
+    \fboxrule=2\fboxrule
+    \fbox{contents of double width of rule}
+  }
+
 parbox
 \parbox[POS]{WIDTH}{TEXT}
 Make a box of width WIDTH using TEXT.  The box's position by POS is;
@@ -1218,8 +1242,17 @@
 
 documentstyle
 \documentstyle[OPTION1,OPTION2, ... ,OPTIONn]{STYLE}
-The user starts his file with the command as above
-which saves the OPTION's and \input's the file STYLE.STY.
+The user starts one's file with the command as above
+which loads the OPTION's respectively and \input's the file STYLE.sty.
+
+documentclass
+\documentclass[OPTION1,OPTION2, ... ,OPTIONn]{STYLE}
+In LaTeX2e, user starts one's file with the command as above
+which loads the OPTION's respectively and \input's the file STYLE.cls.
+
+usepackage
+\usepackage[OPTIONS]{PACKAGE}
+Use additional package `PACKAGE' with option `OPTION'.
 
 verb
 \verb#CONTENTS#
@@ -1287,6 +1320,17 @@
 \twocolumn[STRING]
 Clear page and start two-column typesetting.
 Optional argument [STRING] specifies the page-acrossing title.
+
+If you want to output one-column title page with two-column body,
+describe like this;
+\twocolumn[
+\begin{titlepage}
+{\LARGE YourTitle}
+\vspace*{1em}
+\begin{abstract} Your Abstract blah blah... \end{abstract}
+\end{titlepage}
+]
+
 ->onecolumn
 
 onecolumn
@@ -1457,7 +1501,255 @@
 
 <ref fancybox>
 
+quote
+\begin{quote} ... \end{quote}
+quotation without paragraph
 
+quotation
+\begin{quotation} ... \end{quotation}
+quoted environment which might contains paragraphs
+
+textcircled
+\textcircled{CHAR}
+Enclose `char' with small circle.  Because this circle is as large as one
+character, you had better encolose `CHAR' with {\small ...}, {\tiny ...},
+{\scriptsize ...}.
+
+hfill
+\hfill
+Insert a space as wide as possible.  Same as \hspace{\fill}.
+
+foo\hfill bar
+produces;
+        foo                                                     bar
+
+foo\hfill bar\hfill baz
+produces;
+        foo                        bar                          baz
+
+\hfill can't produce space at the beginning of the line because \hfill
+is a kind of \hspace{}.  If you make right-justified world in a line,
+write \hspace*{\fill}.
+
+hfil
+\hfil
+Same as \hfill, but little bit weak.
+
+vfill
+\vfill
+Make vertical space in utmost length , the same as \vspace{\fill}.
+cf. \hfill
+
+hrulefill
+\hrulefill
+Draw underline in utmost length.
+
+backslashbox
+\usepackage{slashbox}   \backslashbox{A}{B}
+Draw a back-slash in a column of tabular.
+\begin{tabular}
+\hline
+\backslashbox{A}{B} & hoge \\ \hline
+\end{tabular}
+
+     +----+--------+
+     | \ B|        |
+     | A\ |  hoge  |
+     +----+--------+
+
+
+slashbox
+\slashbox{A}{B}
+Draw long slash line in a column of tabular.
+See also backslashbox.
+
+ooalign
+{\ooalign{String1\crcr String2...}
+Set line spacing to zero and shift to double-strike mode.
+This can be used for generating circled character.
+Look this;
+
+\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
+
+\crcr is the equivalent of \\ for tabulars.
+Note that \ooalign change the spacing parameters.  So you should enclose
+\ooalign itself with { }.
+
+maru
+\maru{R}
+Circle one character.
+Declare the \newcommand as below;
+\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
+
+today
+\date{\today}
+Use this as the argument of \date{}.
+Set the document's date in title to today.
+
+NamedColor
+\textcolor[named]{COLOR}{TEXT}, for example.
+With `\usepackage{color}', you can use colors listed below.
+
+GreenYellow Yellow Goldenrod Dandelion Apricot Peach Melon YellowOrange
+Orange BurntOrange Bittersweet RedOrange Mahogany Maroon BrickRed Red
+OrangeRed RubineRed WildStrawberry Salmon CarnationPink Magenta
+VioletRed Rhodamine Mulberry RedViolet Fuchsia Lavender Thistle
+OrchidDarkOrchid Purple Plum Violet RoyalPurple BlueViolet Periwinkle
+CadetBlue CornflowerBlue MidnightBlue NavyBlue RoyalBlue Blue Cerulean
+Cyan ProcessBlue SkyBlue Turquoise TealBlue Aquamarine BlueGreen Emerald
+JungleGreen SeaGreen Green ForestGreen PineGreen LimeGreen YellowGreen
+SpringGreen OliveGreen RawSienna Sepia Brown Tan Gray Black White)
+
+See also http://www.yatex.org/help/color.tex
+
+textcolor
+\textcolor{COLOR}{TEXT}
+Put the TEXT colored with COLOR.
+
+<refer NamedColor>
+
+pagecolor
+\pagecolor{COLOR}
+Set background color of the page to COLOR.
+
+<refer NamedColor>
+
+color
+\color{COLOR}
+Set text color of the page to COLOR.
+
+<refer NamedColor>
+
+colorbox
+\colorbox{COLOR}{TEXT}
+Put TEXT in the box whose background color is COLRO.
+
+<refer NamedColor>
+
+fcolorbox
+\fcolorbox{FCOLOR}{BGCOLOR}{TEXT}
+Put text int the box whose frame color is FCOLOR and background BGCOLOR.
+
+<refer NamedColor>
+
+rotatebox
+\rotatebox{ANGLE}{TEXT}
+Put TEXT with rotated by ANGLE-degrees, unclockwise.
+Require `\usepackage{graphicx}'.
+
+resizebox
+\resizebox{WIDTH}{HEIGHT}{TEXT}
+Put TEXT enlarging/shrinking to WIDTH and HEIGHT.
+You can omit either of WIDHT or HEIGHT.  In that case, specify `!'.
+\resizebox{!}{40mm}{TEXT} outputs TEXT with 40mm in height.
+Require `\usepackage{graphicx}'.
+
+scalebox
+\scalebox{MAG}[V-MAG]{TEXT}
+Put TEXT maginifiyng by MAG.  V-MAG for vertical magnification factor is
+optional.  Negative values for magnification factor flip the TEXT
+in that direction.
+
+Require `\usepackage{graphicx}'.
+
+reflectbox
+\reflectbox{TEXT}
+Flip TEXT horizontally.
+Equivalent to \scalebox{-1}[1]{TEXT}.
+Require `\usepackage{graphicx}'.
+
+ulem
+\usepackage{ulem}
+\usepackage{ulem}
+The `ulem' package provides macros listed below.
+\uline{Underlined Text}
+\uwave{Waved-Unlderlined Text}
+\uuline{Double Underlined Text} 
+
+(Information by TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>)
+uline
+\uline{TEXT}
+Put TEXT with underline.
+
+<refer ulem>
+
+uwave
+\uwave{TEXT}
+Put TEXT with waved underline.
+
+<refer ulem>
+
+uuline
+\uuline{TEXT}
+Put TEXT with double underline.
+
+<refer ulem>
+showkeys.sty
+\usepackage[options]{showkeys}
+In margin area, output `(?)' marks for unlabeled math-expressions,
+`?label?' marks for unreferred labels.
+Optional arguments are one of;
+showrefs, norefs, showcites, nocites, msgs, nomsgs, chkunlbld,
+ignoreunlbld.
+msgs/nomsgs specifies whether output messages in  *.log file or not.
+
+`\usepackage{showkeys}' should be located before the declaration
+for AMS-LaTeX or HyperRef, if any.
+
+Another style `refcheck.sty' can also output labeling information
+including `\ref{***}' macros themselves.
+
+(Information by Masaki Shigemori <mshige@ucla.edu>)
+
+table*
+\begin{table*} ... \end{table*}
+Put tabular in one column at the top of page even if in twocolumn mode.
+
+figure*
+\begin{figure*} ... \end{figure*}
+Put figure in one column at the top of page even if in twocolumn mode.
+If you put figure bottom of page instead of top, use nidanfloat.sty
+instead.
+\begin{figure*}[b]
+ \includegraphics{blahblahblah}
+ \caption{foo bar baz}
+\end{figure*}
+
+includegraphics
+\usepackage{graphicx}  ... \includegraphics[Options]{graphicfile.eps}
+Include graphics$B!#(BRequires `graphicx' package.
+Possible [Options] are as follows.
+scale=X
+width=W
+height=H
+draft     (Frame only)
+angle=R
+origin=RotationOrigin  (One of `c', `tl', `tr', `bl' or `br')
+bb=llx lly urx ury    (Specify BoundingBox)
+viewport=llx lly urx ury  (Rerative to BoundingBox)
+trim=left bottom right top
+
+abstract
+\begin{abstract} ... \end{abstract}
+Output abstract
+
+\langle
+$\langle$
+         
+`<' in math-modes.
+
+\langle
+$rlangle$
+         
+`>' in math-modes.
+
+\slash
+\slash
+slash(/) itself.
+
+\textbackslash
+\textbackslash
+backslash(\) itself.
 
 YaTeX
 (setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist))
--- a/help/YATEXHLP.jp	Thu Dec 25 04:10:32 2003 +0000
+++ b/help/YATEXHLP.jp	Sun Dec 24 06:16:52 2006 +0000
@@ -44,6 +44,9 @@
 {}内の内容を\\で区切られた単位毎に積み重ねて表示する。
 [場所]は、l(左寄せ)、c(センタリング)、r(右寄せ)のいずれか。
 
+表(tabular)の中で縦書きに項目を入れたいときにも便利。
+
+
 newlength
 \newlength{NAME}
 NAMEという長さコマンドを新たに宣言する。
@@ -390,10 +393,15 @@
 \setcounter{FOO}{VAL}
 カウンタFOOの値をVALに設定する。
 
+<refer 新しいカウンタの作り方>
+
 addtocounter
 \addtocounter{FOO}{VAL}
 カウンタFOOの値にVALを加える。
 
+<refer 新しいカウンタの作り方>
+
+
 newcounter
 \newcounter{COUNTER}[OLDCTR]
 新しいカウンタCOUNTERを設定する。
@@ -401,6 +409,18 @@
 \stepcounter もしくは \addtocounter で変更されるたびにCOUNTERの値もリセッ
 トされる。
 
+<refer 新しいカウンタの作り方>
+
+新しいカウンタの作り方
+以下の定義で \mondai とすると、自動的にnをインクリメントして「第n問」を
+出力する。
+
+\newcounter{toi}
+\renewcommand{\thetoi}{第\arabic{toi}問~ }
+\setcounter{toi}{0}
+\newcommand{\mondai}{\refstepcounter{toi}\thetoi}
+
+
 value
 \value{COUNTER}
 COUNTERの値を返す。\protect を前置してはならない。
@@ -459,7 +479,7 @@
 enumerateされたitemで設定されたラベルにたいしては、item番号が返される。
 
 pageref
-pageref{LABEL}
+\pageref{LABEL}
 \label{LABEL}の存在するページ番号を参照する。
 
 (
@@ -692,6 +712,18 @@
 第2の書式では、picuture環境で大きさ(X,Y)の(\unitlengthを基準とする)
 \hbox にオブジェクトを配置する。配置位置POSは第1の書式と同様。
 
+LaTeX2e以降では第1の書式のPOSにsを指定でき、ボックス内に文字を均等割り付け
+してくれる。ボックスの幅は全角1字を表すzwを単位にすると便利だろう。
+\makebox[7zw][s]{山田太郎}\\
+\makebox[7zw][s]{木村花}\\
+\makebox[7zw][s]{広瀬 雄二}
+とすると
+	|山  田  太  郎|
+	|木    村    花|
+	|広 瀬    雄 二|
+
+という感じになる。
+
 mbox
 \mbox{オブジェクト}
 \makebox{オブジェクト}と同じ。
@@ -718,17 +750,40 @@
 \saveboxで\CMDに保存されたテキストを配置する。
 
 framebox
-\framebox{オブジェクト}
+\framebox[WID][POS]{オブジェクト}	\framebox(X,Y)[POS]{オブジェクト}
 「オブジェクト」に枠をつけて\makeboxと同様の処理をする。
 枠の線の太さは \framerule、オブジェクトとの間隔は \framesep で決まる。た
 だしpicture環境で \framebox(X,Y){オブジェクト}とした場合は、picture環境
 用の線の太さに従い、外枠とオブジェクトとの間隔は空けられない。
 
+LaTeX2e以降では第1の書式のPOSにsを指定でき、ボックス内に文字を均等割付
+してくれる。ボックスの幅は全角1字を表すzwを単位にすると便利だろう。
+\framebox[7zw][s]{山田太郎}\\
+\framebox[7zw][s]{木村花}\\
+\framebox[7zw][s]{広瀬 雄二}
+とすると
+	+--------------+
+	|山  田  太  郎|
+	+--------------+
+	|木    村    花|
+	+--------------+
+	|広 瀬    雄 二|
+	+--------------+
+
+という感じになる。
+
 fbox
 \fbox{オブジェクト}
 \framebox{オブジェクト}と同じ。
 \fboxはrobust, \frameboxはfragile
 
+\fbox の罫線の太さを変えるには,\fboxrule を変更します.
+
+  {
+    \fboxrule=2\fboxrule
+    \fbox{2倍の太さの罫線で囲まれたボックス}
+  }
+
 parbox
 \parbox[POS]{WIDTH}{TEXT}
 TEXTをWIDThの幅で組んでボックスを作成する。ボックスの位置はPOSによって
@@ -895,6 +950,18 @@
 tabular環境は、ページを跨ることができない。これを可能にするスタイルファ
 イルとして、supertab.styがある。
 
+l, c, r 指定した1つのカラムに2行以上の項目を入れたいときはparboxを利用する
+(shortstackを利用すると上にずれるのでraiseboxで調整しなければならない)。
+\begin{tabular}{lp{0.5\columnwidth}}
+ \parbox[t]{7em}{あ\\い} & あぶらかだぶらあぶらかだぶらあぶらかだぶら
+\end{tabular}
+は、以下のようにレイアウトされる。
+
+	あ	あぶらかだ
+	い	ぶらあぶら
+		かだぶら
+
+
 tabular*
 \begin{tabular*}{幅}{プリアンブル} ... \end{tabular*}
 幅を指定してtabular環境を作成。
@@ -1166,6 +1233,17 @@
 [OPTION...] を指定すると、STYLE.sty を読んだ後に、
 OPTIONn.sty が順次読み込まれる。
 
+documentclass
+\documentclass[OPTION1,OPTION2, ... ,OPTIONn]{STYLE}
+文書スタイルを指定する(LaTeX2e)。
+[OPTION...] を指定すると、STYLE.cls を読んだ後に、
+OPTIONn.sty が順次読み込まれる。
+
+usepackage
+\usepackage[オプション]{パッケージ}
+LaTeX2e の記法を拡張する「パッケージ」をロードする。
+
+
 verb
 \verb#内容#
 \verbの直後に来る文字と、次にあらわれる同じ文字とのあいだに挟まれたもの
@@ -1215,6 +1293,8 @@
 mm		ミリメートル
 pc		パイカ(=12pt)
 pt		ポイント(72.27pt=1インチ)
+zw		日本語全角1字の幅
+zh		日本語全角1字の高さ
 \fill		自然長は0だが、任意の長さに伸びることのできる伸縮長
 \stretch{X}	\fill のX倍
 
@@ -1226,6 +1306,17 @@
 \twocolumn[STRING]
 改頁したあと二段組みでの組版を開始する。
 [STRING]を指定すると、STRINGを二段ぶち抜きのタイトルとして出力。
+本文が二段組みでタイトルとアブストラクトのみを1段組にしたい場合は
+\twocolumn[
+\begin{titlepage}
+{\LARGE 和文タイトル等}
+\vspace*{1em}
+\begin{abstract} 和文抄録 \end{abstract}
+\renewcommand{\abstractname}{\textbf{Abstract}}
+\begin{abstract} 英文アブストラクト \end{abstract}
+\end{titlepage}
+]
+のようにすると良い。
 →onecolumn
 
 onecolumn
@@ -1396,10 +1487,288 @@
 \doublebox{STRING}
 二重四角枠で STRING を囲む。
 
+quote
+\begin{quote} ... \end{quote}
+段落を含まない引用
+
+quotation
+\begin{quotation} ... \end{quotation}
+段落を含む引用
+
+
 要 `\usepackage{fancybox}`
 
 <ref fancybox>
 
+textcircled
+\textcircled{文字}
+「文字」を丸枠で囲む。1文字と同じ大きさの丸枠なので
+{\small ...}, {\tiny ...}, {\scriptsize ...} などで括った方が良い。
+
+hfill
+\hfill
+できるだけ広い間隔を開ける。\hspace{\fill} と同じ。
+あ\hfill い
+とすると
+        あ                                                      い
+
+あ\hfill い\hfill う
+とすると
+        あ                         い                           う
+
+のように最大限に間隔を延ばしてくれる。ただし \hspace{} 相当なので
+行頭だとうまく行かない。右寄せしたいなら \hspace*{\fill} とする。
+
+hfil
+\hfil
+\hfill より弱い間隔開け。
+\hfill も参照のこと。
+
+vfill
+\vfill
+縦方向に最大限の空白を開ける。\vspace{\fill} と同じ。
+\hfill も参照のこと。
+
+hrulefill
+\hrulefill
+可能な限り長い下付罫線を引く。
+あんまりいい説明じゃないな。
+
+backslashbox
+\backslashbox{A}{B}
+tabular環境の(主に)左上のカラムで用いて右下がり斜線で区切った2項目を書く。
+要 \usepackage{slashbox}
+\begin{tabular}
+\hline
+\backslashbox{A}{B} & hoge \\ \hline
+\end{tabular}
+
+     +------+--------+
+     | \ B |        |
+     | A \ |  hoge  |
+     +------+--------+
+
+
+slashbox
+\slashbox{A}{B}
+tabular環境の(主に)右上のカラムで用いて右上がり斜線で区切った2項目を書く。
+backslashboxも参照せよ。
+
+ooalign
+{\ooalign{文字列1\crcr 文字列2……}
+行送りゼロの設定に変更して文字の重ね打ちを可能にする。
+○つき文字を作るための有名なマクロ \maru{} は便利。
+
+\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
+
+\crcr は\ooalign内での改行を意味する。\hfill は「最大に延びる空白」とい
+うことで、文字の左右に配置することでセンタリングの効果が得られる。
+\ooalign は改行幅などの長さパラメータをいじってしまうので全体を {} で
+括る必要があることに注意。
+
+maru
+\maru{あ}
+文字(1文字に限る)を○で囲む。プリアンブルで以下の \newcommand をせよ。
+\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
+
+today
+\date{\today}
+作成日の日付けの出力を指定する。プリアンブルで \date とともに使う。
+
+和暦
+\和暦
+\和暦 は日付けを元号での表記にする。
+\西暦 は西暦での表記にする。
+\maketitle より先に指定する。
+
+西暦
+\西暦
+<refer 和暦>
+
+colorの名前つきカラー
+\textcolor[named]{色名}{内容} など、[named] を指定する。
+
+\usepackage{color} によって使用可能。
+使える色は以下の通り。
+GreenYellow Yellow Goldenrod Dandelion Apricot Peach Melon YellowOrange
+Orange BurntOrange Bittersweet RedOrange Mahogany Maroon BrickRed Red
+OrangeRed RubineRed WildStrawberry Salmon CarnationPink Magenta
+VioletRed Rhodamine Mulberry RedViolet Fuchsia Lavender Thistle
+OrchidDarkOrchid Purple Plum Violet RoyalPurple BlueViolet Periwinkle
+CadetBlue CornflowerBlue MidnightBlue NavyBlue RoyalBlue Blue Cerulean
+Cyan ProcessBlue SkyBlue Turquoise TealBlue Aquamarine BlueGreen Emerald
+JungleGreen SeaGreen Green ForestGreen PineGreen LimeGreen YellowGreen
+SpringGreen OliveGreen RawSienna Sepia Brown Tan Gray Black White)
+
+色見本を出すソースが
+http://www.yatex.org/help/color.tex にあるので、試すと良い。
+
+textcolor
+\textcolor{色}{内容}
+文字の色を「色」に設定して「内容」を出力。
+
+<refer colorの名前つきカラー>
+
+pagecolor
+\pagecolor{色}
+ページの背景色を「色」に設定する。
+
+<refer colorの名前つきカラー>
+
+color
+\color{色}
+
+ページの文字食を「色」に設定する。
+
+<refer colorの名前つきカラー>
+
+colorbox
+\colorbox{色}{内容}
+「色」が背景のボックスを作りその中に「内容」を出力。
+
+
+<refer colorの名前つきカラー>
+
+fcolorbox
+\fcolorbox{枠の色}{背景色}{内容}
+枠と背景色を指定して「内容」を出力。
+
+<refer colorの名前つきカラー>
+
+rotatebox
+\rotatebox{角度}{内容}
+「内容」を「角度」回転して出力。
+要 `\usepackage{graphicx}'
+
+resizebox
+\resizebox{横の長さ}{縦の長さ}{内容}
+縦か横を省略したいときは ! を指定する。
+\resizebox{!}{40mm}{内容} とすると縦が40mmで縦横比を保存して拡大する。
+要 `\usepackage{graphicx}'
+
+scalebox
+\scalebox{倍率}[縦倍率]{内容}
+「内容」を「倍率」倍して出力。縦倍率は省略可能。
+倍率として負の数を指定すると反転。
+要 `\usepackage{graphicx}'
+
+reflectbox
+\reflectbox{内容}
+「内容」を左右反転して出力。\scalebox{-1}[1]{内容} と同じ。
+要 `\usepackage{graphicx}'
+
+ulem
+\usepackage{ulem}
+\usepackage{ulem} すると 以下のマクロが使える。
+\uline{通常の下線}
+\uwave{波線}
+\uuline{二重の下線} 
+
+\underlineと\ulineは前後に単語空白が挿入されるかどうかが異なっている。
+
+前\underline{中}後
+前\uline{中}後
+
+を typeset して比較してみると分かる。
+
+(情報提供 TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>)
+
+uline
+\uline{内容}
+「内容」にアンダーラインをつける。
+
+<refer ulem>
+
+uwave
+\uwave{内容}
+「内容」に波下線をつける。
+
+<refer ulem>
+
+uuline
+\uuline{内容}
+「内容」に二重アンダーラインをつける。
+
+<refer ulem>
+
+showkeys.sty
+\usepackage[options]{showkeys}
+ラベルが無い(unlabeled)数式には {?} がマージンに印刷される。
+引用されなかったラベルは ?label? のように印刷される。
+オプションには showrefs, norefs, showcites, nocites, msgs, nomsgs,
+chkunlbld, ignoreunlbld がある。msgs/nomsgs は .log ファイルに
+メッセージを書き込むか否か。その他のオプションは自明。
+
+AMS-LaTeX や HyperRef と同時に使えるが、これらよりも後に
+\usepackage しなくてはならない。
+
+似たような package に refcheck.sty というのがある。
+これだと \ref まで見える(でもかえってうざったいかも)。
+(情報提供 Masaki Shigemori <mshige@ucla.edu>)
+
+dots
+\dots
+点々
+\dotsにはいくつも種類があるので適切に使いわけましょう。
+
+\dotsc ... コンマで区切られた列が続くことを表わす点々. $A_1, A_2, \dotsc$
+\dotsb ... 二項演算子(+など)が続くことを表わす点々.$A_1+A_2+\dotsb$
+\dotsm ... 掛け算(演算子省略)が続くことを表わす点々.$A_1 A_2 \dotsm$
+\dotsi ... 積分が続くことを表わす点々 \[ \int_{A_1} int_{A_2} \dotsi \]
+
+(情報提供 Ryohei SETO <setoryohei@mac.com>)
+
+table*
+\begin{table*} ... \end{table*}
+二段組環境でも表を上段ぶち抜きで配置
+
+figure*
+\begin{figure*} ... \end{figure*}
+二段組環境でも図を上段ぶち抜きで配置([t]のみ)。
+下段([b])に置きたいときは nidanfloat.sty を使う。
+\begin{figure*}[b]
+ 〜〜\includegraphicsとか図をいれるマクロ〜〜
+ \caption{標題}
+\end{figure*}
+
+includegraphics
+\usepackage{graphicx}  ... \includegraphics[オプション]{graphicfile.eps}
+画像を取り込む。要 graphicx パッケージ。
+「オプション」は以下のものが指定可能。
+scale=拡大率
+width=幅
+height=高さ
+draft     (草稿モード; 枠だけ表示)
+angle=回転角
+origin=回転の中心位置  (c, tl, tr, bl, brのどれか)
+bb=llx lly urx ury    (BoundingBoxとなる矩形対角座標を指定)
+viewport=llx lly urx ury  (BoundingBox内の相対的座標で切り取る)
+trim=left bottom right top  (指定した幅を切り取る)
+
+abstract
+\begin{abstract} ... \end{abstract}
+抄録(アブストラクト)を出力する。
+和文抄録から英文に切り替えたいときは和文のabstract環境を終えたあとで
+\renewcommand{\abstractname}{\textbf{Abstract}}
+としてから再度abstract環境を始めると良い。
+
+\langle
+$\langle$
+         
+数式モードでの`〈'
+
+\langle
+$rlangle$
+         
+数式モードでの`〉'
+
+\slash
+\slash
+スラッシュそのもの
+
+\textbackslash
+\textbackslash
+バックスラッシュそのもの
 
 LaiTeX
 a Little Assistant Interface for TeX on Vz
@@ -1633,6 +2002,16 @@
 山尾貴則さん(東北大)
 	Meadowユーザのための詳細インストールドキュメントを書いて下さいました。
 
+重森正樹さん(東京大)
+	数え切れないバグレポートとコメントを頂きました。
+
+瀬戸亮平さん(立命館大)
+	Carbon Emacs(MacOS X) での使用のための情報をたくさん頂きました。
+	AMS-LaTeXで使う重要なマクロの情報をたくさん頂きました。
+
+
+
+
 yatex
 (setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist))
 <refer YaTeX>
--- a/yahtml.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yahtml.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,9 +1,9 @@
 ;;; -*- Emacs-Lisp -*-
-;;; (c) 1994-2003 by HIROSE Yuuji [yuuji@yatex.org]
-;;; Last modified Mon Nov 17 18:28:50 2003 on firestorm
+;;; (c) 1994-2006 by HIROSE Yuuji [yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:12:35 2006 on firestorm
 ;;; $Id$
 
-(defconst yahtml-revision-number "1.70"
+(defconst yahtml-revision-number "1.72"
   "Revision number of running yahtml.el")
 
 ;;;[Installation]
@@ -173,9 +173,8 @@
 ;;; --- customizable variable starts here ---
 (defvar yahtml-prefix "\C-c"
   "*Prefix key stroke of yahtml functions.")
-(defvar yahtml-image-viewer "xv" "*Image viewer program")
-(defvar yahtml-www-browser "netscape"
-  "*WWW Browser command")
+(defvar yahtml-image-viewer "display" "*Image viewer program")
+(defvar yahtml-www-browser "firefox" "*WWW Browser command")
 (defvar yahtml-kanji-code 2
   "*Kanji coding system number of html file; 1=sjis, 2=jis, 3=euc")
 ;;(defvar yahtml-coding-system
@@ -208,13 +207,19 @@
 (defvar yahtml-hate-too-deep-indentation nil
   "*Non-nil for this variable suppress deep indentation in listing environments.")
 
-(defvar yahtml-always-/p nil
+(defvar yahtml-always-/p t
   "*Those who always use <p> with </p> set this to t.")
+(defvar yahtml-always-/li nil
+  "*Those who always use <li> with </li> set this to t.")
+(defvar yahtml-always-/dt nil
+  "*Those who always use <dt> with </dt> set this to t.")
+(defvar yahtml-always-/dd nil
+  "*Those who always use <dd> with </dd> set this to t.")
 
 (defvar yahtml-p-prefered-env-regexp "^\\(body\\|dl\\|blockquote\\)"
   "*Regexp of envs where paragraphed sentences are prefered.")
 
-(defvar yahtml-template-file "~/http/template.html"
+(defvar yahtml-template-file "~/public_html/template.html"
   "*Template HTML file.  It'll be inserted to empty file.")
 
 (defvar yahtml-prefer-upcases nil
@@ -223,8 +228,7 @@
 (defvar yahtml-prefer-upcase-attributes nil
   "*Non-nil for preferring upcase attributes")
 
-(defvar yahtml-server-type 'apache
-  "*WWW server program type")
+(defvar yahtml-server-type 'apache "*WWW server program type")
 
 (defvar yahtml-apache-access-file ".htaccess"
   "*Server access file name for apache")
@@ -265,6 +269,10 @@
 (defvar yahtml-indentation-boundary "^\\s *<h[1-3]>"
   "*Boundary regexp for indentation calculation.")
 
+(defvar yahtml-html4-strict t
+  "*Non-nil means editing HTML 4.01 Strict.
+Completing read for obsoleted attributes disabled.")
+
 ;;; --- customizable variable ends here ---
 (defvar yahtml-prefix-map nil)
 (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.")
@@ -305,6 +313,7 @@
   (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment)
   (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment)
   (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline)
+  (define-key yahtml-mode-map "\M-\C-j" 'yahtml-intelligent-newline)
   (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line)
   (define-key yahtml-mode-map "&" 'yahtml-insert-amps)
   (let ((map yahtml-prefix-map))
@@ -337,6 +346,7 @@
       (yahtml-define-begend-key "bc" "center" map)
       (yahtml-define-begend-key "bd" "dl" map)
       (yahtml-define-begend-key "bu" "ul" map)
+      (yahtml-define-begend-key "bo" "ol" map)
       (yahtml-define-begend-key "b1" "h1" map)
       (yahtml-define-begend-key "b2" "h2" map)
       (yahtml-define-begend-key "b3" "h3" map)
@@ -344,7 +354,7 @@
       (yahtml-define-begend-key "bf" "form" map)
       (yahtml-define-begend-key "bs" "select" map)
       (yahtml-define-begend-key "bv" "div" map)
-      (yahtml-define-begend-key "bS" "div" map)
+      (yahtml-define-begend-key "bS" "span" map)
       (yahtml-define-begend-key "bp" "pre" map)
       (YaTeX-define-key "b " 'yahtml-insert-begend map)
       (YaTeX-define-key "B " 'yahtml-insert-begend-region map)
@@ -409,13 +419,17 @@
     ("UnorderedList" . "ul")
     ("DefinitionList" . "dl")
     ("Preformatted" . "pre")
-    ("table") ("thead") ("tbody") ("tfoot") ("caption") ("tr") ("th") ("td")
+    ("table") ("thead") ("tbody") ("tfoot") ("tr") ("th") ("td")
     ("address") 
     ("h1") ("h2") ("h3") ("h4") ("h5") ("h6")
     ;; ("p") ;This makes indentation screwed up!
-    ("style") ("div") ("object")
+    ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del")
     ))
 
+(if yahtml-html4-strict
+    (setq yahtml-env-table
+	  (delete (assoc "center" yahtml-env-table) yahtml-env-table)))
+
 ;(defvar yahtml-itemizing-regexp
 ;  "\\(ul\\|ol\\|dl\\)"
 ;  "Regexp of itemizing forms")
@@ -427,12 +441,23 @@
 (and yahtml-always-/p
      (or (assoc "p" yahtml-env-table)
 	 (setq yahtml-env-table (cons '("p") yahtml-env-table))))
+(and yahtml-always-/li
+     (or (assoc "li" yahtml-env-table)
+	 (setq yahtml-env-table (cons '("li") yahtml-env-table))))
+(and yahtml-always-/dt
+     (or (assoc "dt" yahtml-env-table)
+	 (setq yahtml-env-table (cons '("dt") yahtml-env-table))))
+(and yahtml-always-/dd
+     (or (assoc "dd" yahtml-env-table)
+	 (setq yahtml-env-table (cons '("dd") yahtml-env-table))))
 
 (defvar yahtml-typeface-table
   (append
-   '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") ("strike") ("s")
-     ("strong") ("var") ("b") ("i") ("tt") ("u") ("big") ("small") ("font")
-     ("sup") ("sub") ("span"))
+   '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") ("caption")
+     ("strong") ("var") ("b") ("i") ("tt") ("big") ("small")
+     ("sup") ("sub") ("span") ("abbr"))
+   (if (not yahtml-html4-strict)
+       '(("strike") ("s") ("u") ("font")))
    yahtml-env-table)
   "Default completion table of typeface designator")
 (defvar yahtml-user-typeface-table nil)
@@ -440,14 +465,17 @@
 (defvar yahtml-last-typeface-cmd "a")
 
 (defvar yahtml-single-cmd-table
-  '(("hr") ("br") ("option") ("p")
-    ("HorizontalLine" . "hr")
+  '(("hr") ("br") ("option")
+    ("HorizontalRule" . "hr")
     ("BreakLine" . "br")
-    ("Paragraph" . "p")
-    ("Item" . "li")
-    ("DefineTerm" . "dt")
-    ("Description" . "dd")
-    ("dd") ("dt") ("li")
+    ("exec" . "!--#exec")
+    ("!--#exec")
+    ("include" . "!--#include")
+    ("!--#include")
+;;     ("Item" . "li")
+;;     ("DefineTerm" . "dt")
+;;     ("Description" . "dd")
+;;     ("dd") ("dt") ("li")
     )
   "Default completion table of HTML single command.")
 (defvar yahtml-user-single-cmd-table nil)
@@ -537,6 +565,8 @@
 	    (setq charset 3))
 	   ((string-match "shift_jis" charset)
 	    (setq charset 1))
+	   ((string-match "utf-8" charset)
+	    (setq charset 4))
 	   (t (setq charset nil)))
 	  (setq dir "")))
     (if (featurep 'mule)
@@ -576,7 +606,9 @@
      ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system))
       (setq buffer-file-coding-system
 	    (or (and (fboundp 'set-auto-coding) buffer-file-name
-		     (save-excursion (set-auto-coding buffer-file-name (buffer-size))))
+		     (save-excursion
+		       (goto-char (point-min))
+		       (set-auto-coding buffer-file-name (buffer-size))))
 		coding)))
      ((featurep 'mule)
       (set-file-coding-system coding))
@@ -599,7 +631,7 @@
      (YaTeX-struct-begin . "<%1%2")
      (YaTeX-struct-end . "</%1>")
      (YaTeX-struct-name-regexp . yahtml-closable-regexp)
-     (YaTeX-comment-prefix . "<!--")
+     (YaTeX-comment-prefix . "<!--[^#]")
      (YaTeX-coding-system . yahtml-kanji-code) ;necessary?
      (YaTeX-typesetting-mode-map . yahtml-lint-buffer-map)
      (fill-prefix . yahtml-fill-prefix) (fill-column . yahtml-fill-column)
@@ -854,6 +886,16 @@
 	 (save-excursion (insert (format "</%s>" form))))
      (if (search-backward "\"\"" p t) (forward-char 1))))
 
+(defun yahtml-read-css (alist)
+  (let ((completion-ignore-case t) (delim " ")
+	(minibuffer-completion-table alist))
+    (read-from-minibuffer
+     (substitute-command-keys
+      (if YaTeX-japan
+	  "クラス(複数指定は\\[quoted-insert] SPCで区切る): "
+	"class(or class list delimited by \\[quoted-insert] SPC): "))
+     nil YaTeX-minibuffer-completion-map nil)))
+  
 ;;; ---------- Add-in ----------
 (defun yahtml-addin (form)
   "Check add-in function's existence and call it if exists."
@@ -863,9 +905,7 @@
 	   (not (equal last-command-char ?\C-j))
 	   (memq yahtml-current-completion-type '(multiline inline))
 	   (yahtml-make-optional-argument ;should be made generic?
-	    "class"
-	    (let ((completion-ignore-case t))
-	      (completing-read "class: " a))))
+	    "class" (yahtml-read-css a)))
       (if (and (intern-soft addin) (fboundp (intern-soft addin))
 	       (stringp (setq s (funcall (intern addin))))
 	       (string< "" s))
@@ -1060,7 +1100,8 @@
 (defvar yahtml-parameters-completion-alist
   '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center"))
     ("clear" ("left") ("right") ("center") ("all") ("none"))
-    ("src" . file)
+    ("lang" ("ja") ("en") ("kr") ("ch") ("fr"))
+    ("src" . file) ("file" . file)
     ("background" . file)
     ("class file name" . file) ("data" . file)
     ("method" ("POST") ("GET"))
@@ -1078,6 +1119,7 @@
 (defvar yahtml-content-types-alist
   '(("text/css") ("text/html") ("text/plain") ("text/richtext")
     ("text/sgml") ("text/xml")
+    ("text/javascript") ("text/tcl") ("text/vbscript")
     ("application/octet-stream") ("application/postscript") ("application/pdf")
     ("application/java")
     ("image/jpeg") ("image/gif") ("image/tiff") ("image/png") ("video/mpeg"))
@@ -1091,7 +1133,8 @@
 	 v)
     (cond
      ((eq alist 'file)
-      (read-file-name prompt "" default nil ""))
+      (let ((insert-default-directory))
+	(read-file-name prompt "" default nil "")))
      ((and alist (symbolp alist))
       (completing-read prompt (symbol-value alist) nil nil default))
      (alist
@@ -1101,25 +1144,47 @@
       
 (defun yahtml-make-optional-argument (opt arg)
   "Make optional argument string."
-  (if (string= "" arg)
+  (if (or (null arg) (string= "" arg))
       ""
     (concat " "
 	    (if yahtml-prefer-upcase-attributes (upcase opt) (downcase opt))
 	    "=\"" arg "\"")))
 
+(defun yahtml:html ()
+  "Add-in for <html>"
+  (setq yahtml-last-begend "head" yahtml-last-typeface-cmd "head")
+  (yahtml-make-optional-argument
+   "lang" (yahtml-read-parameter "lang" (if YaTeX-japan "ja"))))
+
+(defun yahtml:head ()
+  "Add-in for <head>"
+  (setq yahtml-last-begend "title" yahtml-last-typeface-cmd "title")
+  "")
+
 (defun yahtml:body ()
   "Add-in function for <body>"
-  (let ((b (read-string "bgcolor="))
-	(bg (yahtml-read-parameter "background" ""))
-	(x (read-string "text color="))
-	(l (read-string "link color="))
-	(v (read-string "vlink color=")))
-    (concat
-     (yahtml-make-optional-argument "bgcolor" b)
-     (yahtml-make-optional-argument "background" bg)
-     (yahtml-make-optional-argument "text" x)
-     (yahtml-make-optional-argument "link" l)
-     (yahtml-make-optional-argument "vlink" v))))
+  (cond
+   (yahtml-html4-strict nil)
+   (t
+    (let ((b (read-string "bgcolor="))
+	  (bg (yahtml-read-parameter "background" ""))
+	  (x (read-string "text color="))
+	  (l (read-string "link color="))
+	  (v (read-string "vlink color=")))
+      (concat
+       (yahtml-make-optional-argument "bgcolor" b)
+       (yahtml-make-optional-argument "background" bg)
+       (yahtml-make-optional-argument "text" x)
+       (yahtml-make-optional-argument "link" l)
+       (yahtml-make-optional-argument "vlink" v))))))
+
+(defun yahtml-make-style-parameter (proplist)
+  "Make CSS property definitions in style attribute."
+  (mapconcat
+   '(lambda (x) (if (and (cdr x) (string< "" (cdr x)))
+		    (format "%s: %s;" (car x) (cdr x))))
+   (delq nil proplist)
+   " "))
 
 (defun yahtml:img ()
   "Add-in function for <img>"
@@ -1150,11 +1215,23 @@
     (setq width (yahtml-read-parameter "width" width)
 	  height (yahtml-read-parameter "height" height))
     (concat (if l "SRC" "src") "=\"" src "\""
-	    (yahtml-make-optional-argument "align" alg)
 	    (yahtml-make-optional-argument "alt" alt)
 	    (yahtml-make-optional-argument "width" width)
 	    (yahtml-make-optional-argument "height" height)
-	    (yahtml-make-optional-argument "border" brd))))
+	    (if yahtml-html4-strict
+		(yahtml-make-optional-argument
+		 "style"
+		 (if (or brd alg)
+		     (yahtml-make-style-parameter
+		      (list
+		       (if (string< "" alg)
+			   (cons "align" alg))
+		       (if (string< "" brd)
+			   (cons "border"
+				 (format "%dpx" (string-to-int brd))))))))
+	      (concat
+	       (yahtml-make-optional-argument "border" brd)
+	       (yahtml-make-optional-argument "align" alg))))))
 
 (defun yahtml-file-truename (file)
   (cond
@@ -1301,9 +1378,9 @@
   (setq yahtml-last-single-cmd "dd") "")
 
 (defun yahtml:p ()
-  (let ((alg (yahtml-read-parameter "align")))
-    (yahtml-make-optional-argument "align" alg)
-))
+  (if yahtml-html4-strict nil
+    (let ((alg (yahtml-read-parameter "align")))
+      (yahtml-make-optional-argument "align" alg))))
 
 (defvar yahtml-input-types
   '(("text") ("password") ("checkbox") ("radio") ("submit")
@@ -1344,15 +1421,39 @@
 (defun yahtml:table ()
   "Add-in function for `table'"
   (let ((b (read-string "border="))
-	(a (yahtml-read-parameter "align")))
-    (concat
-     (yahtml-make-optional-argument "border" b)
-     (yahtml-make-optional-argument "align" a))))
+	(a (yahtml-read-parameter
+	    "align" nil '(("align" ("right")("center"))))))
+    (if yahtml-html4-strict
+	(yahtml-make-optional-argument
+	 "style"
+	 (if (or (string< "" b) (string< "" a))
+	     (yahtml-make-style-parameter
+	      (append
+	       (if (string< "" b)
+		   (list
+		    (cons "border" (format "%dpx solid" (string-to-int b)))
+		    (cons "border-collapse" "collapse")))
+	       (if (string< "" a)
+		   (cond
+		    ((string-match "right" a)
+		     (list (cons "margin-left" "auto")
+			   (cons "margin-right" "0")))
+		    ((string-match "center" a)
+		     (list (cons "margin-left" "auto")
+			   (cons "margin-right" "auto")))))))))
+      (concat
+       (yahtml-make-optional-argument "border" b)
+       (yahtml-make-optional-argument "align" a)))))
+
 ;(fset 'yahtml:caption 'yahtml:p)
 (defun yahtml:caption ()
   "Add-in function for `caption' in table tag"
-  (let ((yahtml-parameters-completion-alist '(("align" ("top") ("bottom")))))
-    (yahtml-make-optional-argument "align" (yahtml-read-parameter "align"))))
+  (let ((par (yahtml-read-parameter "align")))
+    (if yahtml-html4-strict
+	(yahtml-make-optional-argument
+	 "style" (if par (yahtml-make-style-parameter
+			  (list (cons "caption-side" par)))))
+      (yahtml-make-optional-argument "align" par))))
 
 (defun yahtml:font ()
   "Add-in function for `font'"
@@ -1365,6 +1466,14 @@
   (yahtml-make-optional-argument
    "type" (read-string "type=" "text/css")))
 
+(defun yahtml:script ()
+  "Add-in function for `script'"
+  (concat
+   (yahtml-make-optional-argument
+    "type" (yahtml-read-parameter "type" "text/javascript"))
+   (yahtml-make-optional-argument
+    "src" (yahtml-read-parameter "src" ""))))
+
 (defun yahtml:tr ()
   "Add-in function for `tr'"
   (setq ;yahtml-last-begend "td"		;; which do you prefer?
@@ -1400,8 +1509,14 @@
 			  (yahtml-url-to-path href) yahtml-css-class-alist)))
 	       (message "")
 	       (yahtml-make-optional-argument "href" href))))))
-     (t ;;??
-      ))))
+     (t
+      (concat
+       (yahtml-make-optional-argument "rel" rel)
+       (yahtml-make-optional-argument
+	"type" (yahtml-read-parameter "type" "text/css"))
+       (yahtml-make-optional-argument
+	"href" (read-from-minibuffer "href: " "" yahtml-url-completion-map))
+       )))))
 
 (defvar yahtml:meta-names
   '(("name" ("keywords")("author")("copyright")("date")("GENERATOR"))))
@@ -1468,6 +1583,10 @@
       ""
       ))))
 
+(defun yahtml:abbr ()
+  "Add-in function for abbr."
+  (yahtml-make-optional-argument "title" (yahtml-read-parameter "title")))
+
 ;;; ---------- Simple tag ----------
 (defun yahtml-insert-tag (region-mode &optional tag)
   "Insert <TAG> </TAG> and put cursor inside of them."
@@ -1502,6 +1621,7 @@
   (yahtml-insert-tag t tag))
 
 
+(defvar yahtml-need-single-closer nil)	;for test
 (defun yahtml-insert-single (cmd)
   "Insert <CMD>."
   (interactive
@@ -1518,14 +1638,19 @@
 	(or (cdr (assoc cmd yahtml-single-cmd-table)) cmd))
   (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase)
 		     yahtml-last-single-cmd))
-  (insert (format "<%s>" cmd)))
+  (insert (format "<%s%s%s>"
+		  cmd
+		  (yahtml-addin cmd)
+		  (if (and yahtml-need-single-closer
+			   (assoc cmd '(("br")("hr"))))
+		      " /" "")))
+  (if (assoc cmd yahtml-env-table)
+      (save-excursion (insert (format "</%s>" cmd)))))
 
 (defun yahtml-insert-p (&optional arg)
   "Convenient function to insert <p></p>"
   (interactive "P")
-  (if arg (yahtml-insert-tag arg "p")
-    (save-excursion			;insert "/p" first to memorize "p"
-      (yahtml-insert-single "/p"))	;in the last-completion variable
+  (if (or yahtml-always-/p arg) (yahtml-insert-tag arg "p")
     (yahtml-insert-single "p")))
 
 (defun yahtml-insert-amps (arg)
@@ -1551,6 +1676,13 @@
       (insert ?&))
      (t (insert (format "&#%d;" c))))))
 
+(defun yahtml:!--\#include ()
+  (let ((file (yahtml-read-parameter "file" "")))
+    (format "%s=\"%s\"--" (if (string-match "/" file) "virtual" "file") file)))
+
+(defun yahtml:!--\#exec ()
+  (format "cmd=\"%s\"--" (yahtml-read-parameter "cmd" "" '(("cmd" . file)))))
+
 ;;; ---------- Jump ----------
 (defun yahtml-on-href-p ()
   "Check if point is on href clause."
@@ -1637,7 +1769,7 @@
   (let ((href (yahtml-on-href-p)) file name (parent buffer-file-name))
     (if href
 	(cond
-	 ((string-match "^\\(ht\\|f\\)tp:" href)
+	 ((string-match "^\\(ht\\|f\\)tps?:" href)
 	  (yahtml-browse-html href))
 	 (t (setq file (substring href 0 (string-match "#" href)))
 	    (if (string-match "#" href)
@@ -1716,7 +1848,7 @@
      (t nil))))
 
 (defun yahtml-current-tag ()
-  "Return the current tag name."
+  "Return the current tag name including #exec and #include."
   (save-excursion
     (let ((p (point)) b tag)
       (or (bobp)
@@ -1724,32 +1856,12 @@
 	  (progn (skip-chars-backward "^<") (forward-char -1)))
       (setq b (point))
       (skip-chars-forward "<")
-      (setq tag (buffer-substring
+      (setq tag (YaTeX-buffer-substring
 		 (point) (progn (skip-chars-forward "^ \t\n") (point))))
       (goto-char b)
       (forward-list 1)
       (and (< p (point)) tag))))
       
-
-(defun yahtml-goto-corresponding-img ()
-  "View image on point"
-  (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t))
-    (if (and tag
-	     (string-match "img" tag)
-	     (save-excursion
-	       (re-search-backward "<\\s *img" nil t)
-	       (re-search-forward "src=\"?\\([^\"> ]+\\)\"?")
-	       (match-beginning 1)
-	       (setq image
-		     (buffer-substring (match-beginning 1) (match-end 1)))))
-	(progn
-	  (message "Invoking %s %s..." yahtml-image-viewer image)
-	  (start-process
-	   "Viewer" " * Image Viewer *"
-	   shell-file-name yahtml-shell-command-option ;"-c"
-	   (concat yahtml-image-viewer " " image))
-	  (message "Invoking %s %s...Done" yahtml-image-viewer image)))))
-
 (defun yahtml-get-attrvalue (attr)
   "Extract current tag's attribute value from buffer."
   (let (e (case-fold-search t))
@@ -1763,8 +1875,22 @@
 		  (looking-at "\"?\\([^\"> \t\n]+\\)\"?")))
 	  (YaTeX-match-string 1)))))
 
+(defun yahtml-goto-corresponding-img ()
+  "View image on point"
+  (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t))
+    (if (and tag
+	     (string-match "img" tag)
+	     (setq image (yahtml-get-attrvalue "src")))
+	(progn
+	  (message "Invoking %s %s..." yahtml-image-viewer image)
+	  (start-process
+	   "Viewer" " * Image Viewer *"
+	   shell-file-name yahtml-shell-command-option ;"-c"
+	   (concat yahtml-image-viewer " " image))
+	  (message "Invoking %s %s...Done" yahtml-image-viewer image)))))
+
 (defun yahtml-goto-corresponding-source (&optional other)
-  "Goto applet's source."
+  "Goto applet's or script's source."
   (let ((env (yahtml-current-tag)) s (p (point)))
     (cond
      ((string-match "applet" env)
@@ -1780,6 +1906,13 @@
 	(message "No applet source specified")
 	(sit-for 1)
 	nil))
+     ((string-match "script" env)
+      (if (setq s (yahtml-get-attrvalue "src"))
+	  (progn
+	    (funcall (if other 'YaTeX-switch-to-buffer-other-window
+		       'YaTeX-switch-to-buffer)
+		     (yahtml-url-to-path s))
+	    s)))
      ((string-match "!--#include" env)
       (cond
        ((setq s (yahtml-get-attrvalue "file")) ;<!--#include file="foo"-->
@@ -1807,12 +1940,12 @@
 
 (defun yahtml-goto-corresponding-* (&optional other)
   "Go to corresponding object."
-  (interactive)
+  (interactive "P")
   (cond
    ((yahtml-goto-corresponding-href other))
    ((yahtml-goto-corresponding-img))
+   ((yahtml-goto-corresponding-source other))
    ((yahtml-goto-corresponding-begend))
-   ((yahtml-goto-corresponding-source other))
    (t (message "I don't know where to go."))
    ))
 
@@ -1945,8 +2078,8 @@
        ((setq attr (yahtml-on-assignment-p)) ;if on the assignment to attr
 	(if (and (equal attr "class")	     ;treat "class" attribute specially
 		 (setq css (yahtml-css-get-element-completion-alist tag)))
-	    (setq new (yahtml-read-parameter ;should be made generic?
-		       attr nil (list (cons "class" css))))
+	    
+	    (setq new (yahtml-read-css css))
 	  ;;other than "class", read parameter normally
 	  (setq new (yahtml-read-parameter attr)))
 	(goto-char (car (get 'yahtml-on-assignment-p 'region)))
@@ -2478,7 +2611,7 @@
 (defun yahtml-intelligent-newline-ul ()
   (interactive)
   (yahtml-insert-single "li")
-  (or yahtml-faithful-to-htmllint (insert " "))
+  (or yahtml-always-/li yahtml-faithful-to-htmllint (insert " "))
   (yahtml-indent-line))
 
 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul)
@@ -2492,11 +2625,11 @@
 	(cond
 	 ((match-beginning 2)
 	  (yahtml-insert-single "dd")
-	  (or yahtml-faithful-to-htmllint (insert " "))
+	  (or yahtml-always-/dd yahtml-faithful-to-htmllint (insert " "))
 	  (setq yahtml-last-single-cmd "dt"))
 	 ((match-beginning 3)
 	  (yahtml-insert-single "dt")
-	  (or yahtml-faithful-to-htmllint (insert " "))
+	  (or yahtml-always-/dt yahtml-faithful-to-htmllint (insert " "))
 	  (setq yahtml-last-single-cmd "dd")))
       (insert (if yahtml-prefer-upcases "<DT> " "<dt> "))
       (setq yahtml-last-single-cmd "dd"))
@@ -2526,6 +2659,35 @@
 	(open-line 1)
 	(YaTeX-reindent c))))
 
+(defun yahtml-intelligent-newline-head ()
+  (let ((title (read-string "Document title: "))
+	(b "<title>") (e "</title>") p)
+    (yahtml-indent-line)
+    (insert (format "%s" (if yahtml-prefer-upcases (upcase b) b)))
+    (setq p (point))
+    (insert (format "%s%s" title (if yahtml-prefer-upcases (upcase e) e)))
+    (if (string= "" title) (goto-char p))
+    (setq yahtml-last-begend "body")))
+
+(defun yahtml-intelligent-newline-script ()
+  (let ((p (point)) b)
+    (if (save-excursion
+	  (and
+	   (setq b (re-search-backward "<script\\>" nil t))
+	   (re-search-forward
+	    "\\(javascript\\)\\|\\(tcl\\)\\|\\(vbscript\\)" p t)))
+	(let ((js (match-end 1)) (tcl (match-end 2)) (vb (match-end 3))
+	      c (srcp (re-search-backward "src=" b t)))
+	  (goto-char p)
+	  (yahtml-indent-line)
+	  (setq c (current-column))
+	  (if srcp
+	      nil
+	    (insert "<!--\n" (cond (js "//") (tcl "#") (vb "'")) " -->")
+	    (beginning-of-line)
+	    (open-line 1)
+	    (YaTeX-reindent c))))))
+
 ;;; ---------- Marking ----------
 (defun yahtml-mark-begend ()
   "Mark current tag"
@@ -2591,23 +2753,32 @@
       (goto-char (point-min))
       (let ((alist initial) b e element class a)
 	(setq b (point))
-	(while (search-forward "{" nil t)
-	  (setq e (point))
-	  (goto-char b)
-	  (while (re-search-forward	;ちょといい加減なREGEXP
-		  "\\([a-z][-a-z0-9]*\\)?\\.\\([-a-z0-9][-a-z0-9]*\\)\\>" e t)
-	    (setq element (YaTeX-match-string 1)
-		  class (YaTeX-match-string 2))
-	    ;;if starts with period (match-string 1 is nil),
-	    ;;this is global class
-	    (setq element (downcase (or element "global")))
-	    (if (setq a (assoc element alist))
-		(or (assoc class (cdr a))
-		    (setcdr a (cons (list class) (cdr a))))
-	      (setq alist (cons (list element (list class)) alist))))
-	  (goto-char (1- e))
-	  (search-forward "}" nil t)
-	  (setq b (point)))
+	(while (re-search-forward "\\({\\)\\|\\(@import\\)" nil t)
+	  (if (match-beginning 2)
+	      (let ((f (YaTeX-buffer-substring
+			(progn (skip-chars-forward "^\"")(1+ (point)))
+			(progn (forward-char 1)
+			       (skip-chars-forward "^\"")(point)))))
+		(if (file-exists-p f)
+		    (setq alist
+			  (append alist (yahtml-css-collect-classes-file f)))))
+	    (setq e (point))
+	    (goto-char b)
+	    (while (re-search-forward	;ちょといい加減なREGEXP
+		    "\\([a-z][-a-z0-9]*\\)?\\.\\([-a-z0-9][-a-z0-9]*\\)\\>"
+		    e t)
+	      (setq element (YaTeX-match-string 1)
+		    class (YaTeX-match-string 2))
+	      ;;if starts with period (match-string 1 is nil),
+	      ;;this is global class
+	      (setq element (downcase (or element "global")))
+	      (if (setq a (assoc element alist))
+		  (or (assoc class (cdr a))
+		      (setcdr a (cons (list class) (cdr a))))
+		(setq alist (cons (list element (list class)) alist))))
+	    (goto-char (1- e))
+	    (search-forward "}" nil t)
+	    (setq b (point))))
 	alist))))
 	    
 (defun yahtml-css-collect-classes-buffer (&optional initial)
@@ -2676,10 +2847,10 @@
     ("<!--#\\(include\\|exec\\|config\\|fsize\\|flastmod\\)" "-->" include)
     ;; string
     (hilit-string-find ?\\ string)
-    (yahtml-hilit-region-tag "<\\(em\\|strong\\|b\\)\\>" bold)
+    (yahtml-hilit-region-tag "<\\(strong\\|b\\)\\>" bold)
     ("</?[uod]l>" 0 decl)
     ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label)
-    (yahtml-hilit-region-tag "<\\(i\\>\\)" italic)
+    (yahtml-hilit-region-tag "<\\(em\\|i\\>\\)" italic)
     ;("<a\\s +href" "</a>" crossref) ;good for hilit19, but odd for font-lock..
     (yahtml-hilit-region-tag "<\\(a\\)\\s +href" crossref)
     (yahtml-hilit-region-tag-itself "</?\\sw+\\>" decl)
@@ -2777,5 +2948,5 @@
 ; fill-prefix: ";;; "
 ; paragraph-start: "^$\\|\\|;;;$"
 ; paragraph-separate: "^$\\|\\|;;;$"
-; buffer-file-coding-system: sjis
+; coding: sjis
 ; End:
--- a/yatex.new	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatex.new	Sun Dec 24 06:16:52 2006 +0000
@@ -1,6 +1,49 @@
 	What's new in YaTeX/yahtml
 	野鳥/yahtml - 各バージョンの変更点について
 
+1.73	=== yatex ===
+	C-i (YaTeX-indent-line) のtabular/array環境対応。行頭位置の
+	tabular的カラム位置に応じてインデントの深さを4桁ずつ深くする。
+	深くする桁数を制御する変数 YaTeX-tabular-indentation 新設。
+	\ref補完で出る一覧で数式は\label文字列も出すようにした。
+	\ref補完で自動的に生成するラベル名を短くした。カスタマイズも可。
+	生成するラベル名の書式を変える変数YaTeX-ref-default-label-string新設。
+	ラベル名生成関数そのものは YaTeX-ref-generate-label-function で変更可。
+	AMS-LaTeX独自のカウンタつき数式環境も全てref補完でlabel打ち可能
+	な場所を検出できるようにした。
+	AMS-LaTeX独自の数式環境でのお任せ改行サポート。
+	tabularのお任せ改行で *{N}{REP} もカラム数を取れるようにした。
+	verbatim環境/alltt環境宣言はTABインデントで行頭に来るようにした。
+	インデントなしの環境宣言を決める変数 YaTeX-noindent-env-regexp 新設。
+	[prefix] c, [prefix] g などがセクション型マクロの英字のみの引数
+	で動かないのを修正。
+	先回りusepackageでパッケージのオプションを確認できるようにした。
+	[prefix] k でセクション型マクロの引数の数を考慮して消すようにした。
+	[prefix] k ではマクロの最後の引数の中味のみを残すようにした。
+	[prefix] S ではリジョンをセクション型マクロの最後の引数に括り入
+	れるようにしてそれ以前の引数入力にアドイン関数を呼ぶようにした。
+	数式モード内の _添字 ^上字 を変えるfaceを作成。とりあえず色だけ
+	変えるようにした(Emacs21.4なら上下にスライドできるだろう)。
+	変数 YaTeX-dvi2-command-ext-alist 新設。Previewerコマンドと、そ
+	れでPreviewするファイルのデフォルト拡張子を指定できるようにした。
+	tabular中のカラム内に\begin\endがある場合はfill-paragraph境界を
+	そこまでに絞るようにした。
+	\cite上での[prefix] g で\bibliography{}で指定したBibファイルの対
+	応エントリに飛べるようにした。
+
+	=== yahtml ===
+	cssの @import に対応(たぶん)。
+	class補完でクラス名をSPCで区切った複数指定の補完入力を可能に。
+	Emacs-21.3 以降のため insert-default-directory をnilに。
+	single-cmd-tableから p を削除。
+	変数 yahtml-html4-strict を新設。HTML4Strict準拠をできるだけ補助。
+	script, noscript要素の補完を追加。script要素のアドインも追加。
+	[prefix] m に <!--#include ...--> <!--#exec ...--> 補完を追加。
+	[prefix] m でもアドイン補完を呼ぶようにしたので M-C-m の<li>挿入
+	でクラス名補完が起きる。これを回避するために M-C-j にも intelligent
+	newline を割り当ててクラス名補完を飛ばせるようにした。
+	[prefix] g に universal arg を指定しても隣窓で開かないのを修正。
+
 1.72	=== yatex ===
 	YaTeX-kanji-code が nil なら coding-system に感知しない
 	補完したマクロがLaTeX2eの特定のpackageに依存している場合
--- a/yatex19.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatex19.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,7 +1,7 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX facilities for Emacs 19
-;;; (c)1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Fri Jun 27 12:07:46 2003 on firestorm
+;;; (c)1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Mon Jun 26 11:31:34 2006 on firestorm
 ;;; $Id$
 
 ;(require 'yatex)
@@ -13,21 +13,23 @@
 (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19)
   "*Use highlighting buffer or not.")
 (defvar YaTeX-background-mode
-  (cond
-   ((boundp 'hilit-background-mode) hilit-background-mode)
-   ((boundp 'frame-background-mode) frame-background-mode)
-   ((fboundp 'get-frame-background-mode)
-    (get-frame-background-mode (selected-frame)))
-   ((face-background 'default)
-    (if (> (+ 32768 32768 32768)
-	   (apply '+
-		  (funcall (if (fboundp 'color-rgb-components)
-			       'color-rgb-components
-			     'x-color-values)
-			   (face-background 'default))))
-	'dark
-      'light))
-   (t nil)))
+  (or (if (fboundp 'get-frame-background-mode)
+          (get-frame-background-mode (selected-frame)))
+      (if (fboundp 'frame-parameters)
+          (cdr (assq 'background-mode (frame-parameters))))
+      (if (boundp 'frame-background-mode)
+          frame-background-mode)
+      (if (boundp 'hilit-background-mode)
+          hilit-background-mode)
+      (if (face-background 'default)
+          (if (> (+ 32768 32768 32768)
+                 (apply '+
+                        (funcall (if (fboundp 'color-rgb-components)
+                                     'color-rgb-components
+                                   'x-color-values)
+                                 (face-background 'default))))
+              'dark
+            'light))))
 
 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX"))
 (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process"))
@@ -250,7 +252,7 @@
 ;; 引数を数えて正しい位置までピカピカさせるよ〜ん!
 
 (defun YaTeX-19-region-section-type (pattern)
-  "Return list of starting and end point of section-type commands of PATTERN."
+  "Return cons of starting and end point of section-type commands of PATTERN."
   (if (re-search-forward pattern nil t)
       (let ((m0 (match-beginning 0)) (e0 (match-end 0)) cmd (argc 1))
 	(setq cmd (substring (YaTeX-match-string 0) 1)
@@ -277,7 +279,7 @@
 	    (goto-char e0))))))
 
 (defun YaTeX-19-region-large-type (pattern)
-  "Return list of large-type contents.
+  "Return cons of large-type contents.
 Assumes PATTERN begins with `{'."
   (if (re-search-forward pattern nil t)
       (let ((m0 (match-beginning 0)) (e0 (match-end 0))p)
@@ -292,6 +294,60 @@
 	  ;;move to re-search end not to make font-lock confused
 	  (goto-char e0)))))
 
+(defun YaTeX-19-region-env-type (envptn)
+  "Return cons of environment contents specified by ENVPTN as regexp."
+  (if (and (looking-at envptn) ;;re-search-forward envptn nil t)
+	   (save-excursion
+	     (not(search-backward YaTeX-comment-prefix
+				  (point-beginning-of-line) t))))
+      (let ((m0 (match-beginning 0)) (e0 (match-end 0))
+	    (env (YaTeX-match-string 1))
+	    (nextline (progn (forward-line 1) (point))))
+	(goto-char m0)
+	;(message "max=%d" (point-max))(sit-for 2)
+	(condition-case err
+	    (if (YaTeX-goto-corresponding-environment)
+		(prog1
+		    (cons nextline (match-beginning 0))
+		  (goto-char e0)))
+	  (error nil)))))
+
+(defun YaTeX-19-region-paren-math (ptn)
+  "Return cons of \(...\) or \[...\] type math environment."
+  (if (looking-at "\\\\\\([\[(]\\)")
+      (let*((ptype (cdr (assoc (YaTeX-match-string 1)
+			       '(("(" . ")") ("[" "]")))))
+	    (b (match-beginning 0))
+	    (e (match-end 0)))
+	(condition-case err
+	    (if (re-search-forward
+		 (concat "[^\\]\\\\" (regexp-quote ptype))
+		 nil t)
+		(prog1 (cons b (match-beginning 0))
+		  (goto-char e)))
+	  (error nil)))))
+
+(defun YaTeX-19-region-math-sub (ptn)
+  "Return cons of _{...}"
+  (if (and (looking-at ptn) 
+	   (eq YaTeX-font-lock-formula-face
+	       (get-text-property (point) 'face)))
+      (let ((e (match-end 0)) (p (point)))
+	(goto-char e)
+	(prog1
+	    (condition-case ()
+		(if (looking-at "{")
+		    (cons (1+ (point))
+			  (progn (forward-list 1) (1- (point))))
+		  (cons e
+			(cond
+			 ((looking-at (concat YaTeX-ec-regexp
+					      YaTeX-TeX-token-regexp))
+			  (match-end 0))
+			 ;; other case??
+			 (t (1+ (point)))))))
+	  (goto-char e)))))
+
 ;; 些細なことだが % の前の文字もピカリとさせてしまうようで… >hilit19
 ;; ↓この関数は下の hilit-set-mode-patterns の "[^\\]\\(%\\).*$" に
 ;; 依存している
@@ -300,12 +356,38 @@
   (if (re-search-forward pattern nil t)
       (cons (match-beginning 2) (match-end 0))))
 
+;; 2006/6/23 match only if it's in specified envrironment.
+(defun YaTeX-19-re-search-in-env (ptn_env)
+  (catch 'done
+    ;; For font-lock, this function should find it.
+    (let (md r)
+      (while (YaTeX-re-search-active-forward
+	      (car ptn_env) YaTeX-comment-prefix nil t)
+	(setq md (match-data)
+	      r (string-match (cdr ptn_env)
+			      (or (YaTeX-inner-environment 'quick) "")))
+	(store-match-data md)
+	(if r (setq r (cons (match-beginning 0) (match-end 0))))
+	(if (or YaTeX-use-hilit19 r) (throw 'done r))
+	(goto-char (match-end 0)))
+      (throw 'done r))))
+
 ;;(make-face 'tt)
 ;;(set-face-font 'tt "-schumacher-clean-medium-r-normal--*-*-*-*-*-*-*-*")
 ;;(hilit-translate 'tt "white")
 
+;; font-lockの関数呼びパターンの場合は正規表現が行末までマッチすると
+;; hilit候補対象外にされてしまうので1字手前で正規表現を止める
 (defvar YaTeX-hilit-patterns-alist
   '(
+    ;; formulas
+    (YaTeX-19-region-math-sub "[^\\]^" YaTeX-font-lock-math-sup-face overwrite)
+    (YaTeX-19-region-math-sub "[^\\]_" YaTeX-font-lock-math-sub-face overwrite)
+    (YaTeX-19-region-env-type
+     "\\\\begin{\\(equation\\|eqnarray\\|displaymath\\|\\(x?x?\\|fl\\)align\\|multline\\|gather\\)" formula)
+    ;(YaTeX-19-region-paren-math "\\\\" formula)
+    ;;("[^\\]\\\\("  "\\\\)" formula)                   ; \( \)
+    ;;("[^\\]\\\\\\[" "\\\\\\]" formula)                ; \[ \]
     ;; comments
     (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment)
 
@@ -341,22 +423,19 @@
     ;;this should be customized by YaTeX-item-regexp
     ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label)
     (YaTeX-19-region-section-type
-     "\\\\caption\\(\\[[^]]*\\]\\)?\\>" label)
+     "\\\\\\(caption\\|bibitem\\)\\(\\[[^]]*\\]\\)?\\>" label)
 
     ;; things that do some sort of cross-reference
     (YaTeX-19-region-section-type
-     "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\)\\>"
+     "\\\\\\(\\(no\\|possessive\\)?cite[a-z]*\\|[a-z]*ref\\|label\\|index\\|glossary\\)\\>"
      crossref)
 
     ;; things that bring in external files
-    ("\\\\\\(include\\|input\\|bibliography\\){" "}" include)
+    ("\\\\\\(include\\|input\\|bibliography\\(style\\)?\\){" "}" include)
 
-    ;; formulas
-    ("[^\\]\\\\("  "\\\\)" formula)                   ; \( \)
-    ("[^\\]\\\\\\[" "\\\\\\]" formula)                ; \[ \]
-    ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)"
-     "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}"
-     formula)
+   ;; ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)"
+   ;;  "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}"
+   ;;  formula)
     ("\\([^\\$]\\|^\\)\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 2 formula); '$...$' or '$$...$$'
 
     ;; "wysiwyg" emphasis -- these don't work on nested expressions
@@ -365,7 +444,13 @@
     ;;;(YaTeX-19-region-large-type "{\\\\tt" tt)
     ;;;("\\\\begin{verbatim" "\\\\end{verbatim" tt)
 
-    ("``" "''" string))
+    ("``" "''" string)
+    ("\\\\\\(new\\|clear\\(double\\)?\\)page\\>\\|\\\\\\(\\\\\\|cr\\)\\>"
+     0 delimiter)
+    (YaTeX-19-re-search-in-env
+     ("&\\|\\\\hline" . "tabular\\|equation\\|eqn\\|array\\|align") delimiter)
+    (YaTeX-19-re-search-in-env ("\\\\[+-=><'`]" . "tabbing") delimiter)
+    )
   "*Hiliting pattern alist for LaTeX text.")
 
 ;;(defvar YaTeX-hilit-pattern-adjustment-default nil)
@@ -419,7 +504,15 @@
     sym)
    ((and YaTeX-use-hilit19 (and (fboundp 'hilit-translate)))
     (let ((face (intern (concat fgcolor "/" bgcolor))))
-      (hilit-translate sym face)
+      (if (facep sym)
+	  (hilit-translate sym face)
+	(make-face sym)
+	(or (memq sym hilit-predefined-face-list)
+	    (progn
+	      (set-face-foreground sym fgcolor)
+	      (set-face-background sym bgcolor)
+	      (setq hilit-predefined-face-list
+		    (cons sym hilit-predefined-face-list)))))
       face))))
 
 (cond
@@ -533,6 +626,10 @@
 			      sect
 			      'keyword))
 		    (if single (list single 0 'macro))))))))))
+
+;;2006/6/23 new face, `delimiter' introduced
+(YaTeX-19-create-face 'delimiter "saddlebrown" "ivory")
+
 ;;(YaTeX-19-collect-macros)	;causes an error
 (defun YaTeX-hilit-setup-alist ()
   (cond
@@ -575,13 +672,48 @@
   (setq YaTeX-font-lock-keywords
 	(YaTeX-convert-pattern-hilit2fontlock
 	 (cdr (YaTeX-19-collect-macros)))
-	font-lock-keywords nil)
-  ;(save-excursion
-   ; (font-lock-fontify-region (window-start) (window-end)))
+;;; Keep this section for debugging.
+;;    YaTeX-font-lock-keywords
+;;    (append (YaTeX-convert-pattern-hilit2fontlock
+;; 	    (cdr (YaTeX-19-collect-macros)))
+;; 	   '(((lambda (lim)
+;; 		(YaTeX-19-re-search-in-env '("foo" . "tabular"))
+;; 		;(search-forward "foo" nil t)
+;; 	       )
+;; 	      (0 YaTeX-font-lock-delimiter-face))))
+	;;font-lock-keywords nil
+	font-lock-set-defaults nil)
+  ;;(save-excursion
+  ;; (font-lock-fontify-region (window-start) (window-end))
   (font-lock-mode -1)			;is stupid, but sure.
   (font-lock-mode 1)
   (recenter arg))
 
+(defun YaTeX-font-lock-fontify-region (beg end)
+  (interactive "r")
+  (save-excursion (font-lock-fontify-region beg end)))
+
+(defun YaTeX-font-lock-fontify-environment ()
+  (interactive)
+  (save-excursion
+    (save-match-data			;is safe after emacs-19
+      (YaTeX-mark-environment)
+      (message "")
+      (YaTeX-font-lock-fontify-region (region-beginning) (region-end)))))
+
+(defun YaTeX-font-lock-highlight-menu ()
+  (interactive)
+  (message "Force Highlight: R)egion E)nvironment")
+  (let ((c (read-char)))
+    (cond
+     ((memq c '(?R ?r))
+      (YaTeX-font-lock-fontify-region (region-beginning) (region-end)))
+     ((memq c '(?e ?e))
+      (YaTeX-font-lock-fontify-environment)))))
+
+(if YaTeX-use-font-lock
+    (YaTeX-define-key "u" 'YaTeX-font-lock-highlight-menu))
+
 (defvar YaTeX-font-lock-keywords nil
   "Pattern-face alist of yahtml-mode for font-lock")
 
@@ -678,5 +810,5 @@
 ; fill-prefix: ";;; "
 ; paragraph-start: "^$\\|\\|;;;$"
 ; paragraph-separate: "^$\\|\\|;;;$"
-; buffer-file-coding-system: sjis
+; coding: sjis
 ; End:
--- a/yatexadd.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexadd.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX add-in functions.
-;;; yatexadd.el rev.17
-;;; (c)1991-2003 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Thu Nov 27 11:11:30 2003 on firestorm
+;;; yatexadd.el rev.18
+;;; (c)1991-2006 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:12:30 2006 on firestorm
 ;;; $Id$
 
 ;;;
@@ -56,9 +56,18 @@
     (format "%s%s{%s}" width loc rule)))
 
 (fset 'YaTeX:tabular* 'YaTeX:tabular)
+(fset 'YaTeX:supertabular 'YaTeX:tabular)
+(defun YaTeX:alignat ()
+  (concat "{" (read-string "Number of columns: ") "}"))
 (defun YaTeX:array ()
   (concat (YaTeX:read-position "tb")
 	  "{" (read-string "Column format: ") "}"))
+(defun YaTeX:subequations ()
+  (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ"
+	     "Changing comment string reduces effort at `ref' completion"))
+  (concat " " YaTeX-comment-prefix
+	  (YaTeX::ref-default-label "%H:%M")
+	  (if YaTeX-japan "の式群" "equations")))
 
 (defun YaTeX:read-oneof (oneof &optional quick allow-dup)
   (let ((pos "") loc (guide ""))
@@ -137,6 +146,12 @@
 	  YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat*
 	  YaTeX:xxalignat YaTeX:xxalignat*))
 
+(defun YaTeX:alignat ()
+  (YaTeX:equation)
+  (concat "{" (read-string "Number of cols: ") "}"))
+
+
+
 (defun YaTeX:list ()
   "%\n{} %default label\n{} %formatting parameter")
 
@@ -148,6 +163,9 @@
   (setq YaTeX-section-name "bibitem")
   (concat "{" (read-string "Longest label: ") "}"))
 
+(defun YaTeX:multicols ()
+  (concat "{" (read-string "Number of columns: ") "}"))
+
 ;;;
 ;;Sample functions for section-type command.
 ;;;
@@ -163,23 +181,33 @@
   (cond
    ((YaTeX-in-environment-p "picture")
     (concat (YaTeX:read-coordinates "Dimension")
-	    (YaTeX:read-position "lrtb")))
+	    (YaTeX:read-position "lsrtb")))
    (t
     (let ((width (read-string "Width: ")))
       (if (string< "" width)
 	  (progn
 	    (or (equal (aref width 0) ?\[)
 		(setq width (concat "[" width "]")))
-	    (concat width (YaTeX:read-position "lr"))))))))
+	    (concat width (YaTeX:read-position
+			   (if YaTeX-use-LaTeX2e "lrs" "lr")))))))))
 
-(defun YaTeX:framebox ()
-  (if (YaTeX-quick-in-environment-p "picture")
-      (YaTeX:makebox)))
+;; (defun YaTeX:framebox ()
+;;   (if (YaTeX-quick-in-environment-p "picture")
+;;       (YaTeX:makebox)))
+(fset 'YaTeX:framebox 'YaTeX:makebox)
+
+(defun YaTeX:parbox ()
+  (YaTeX:read-position "tbc"))
 
 (defun YaTeX:dashbox ()
   (concat "{" (read-string "Dash dimension: ") "}"
 	  (YaTeX:read-coordinates "Dimension")))
 
+(defun YaTeX:savebox (argp)
+  (cond
+   ((= argp 1) (read-string "Saved into name: " "\\"))
+   ((= argp 2) (read-string "Text: "))))
+
 (defvar YaTeX-minibuffer-quick-map nil)
 (if YaTeX-minibuffer-quick-map nil
   (setq YaTeX-minibuffer-quick-map
@@ -220,6 +248,10 @@
 
 (fset 'YaTeX:right 'YaTeX:left)
 
+(defun YaTeX:langle ()
+  (setq YaTeX-single-command "rangle")
+  nil)
+
 (defun YaTeX:read-coordinates (&optional mes varX varY)
   (concat
    "("
@@ -471,29 +503,90 @@
 ; 	    (bury-buffer YaTeX-label-buffer)))
 ; 	label)))))
 
-(defun YaTeX::ref-generate-label ()
+(defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y"
+  "*Default \\ref time string format.
+This format is like strftime(3) but allowed conversion char are as follows;
+%y -> Last 2 digit of year,  %b -> Month name,  %m -> Monthe number(1-12),
+%d -> Day,  %H -> Hour,  %M -> Minute,  %S -> Second,
+%qx -> alphabetical-decimal conversion of yymmdd.
+%qX -> alphabetical-decimal conversion of HHMMSS.
+Beware defualt label-string should be always unique.  So this format string
+should have both time part (%H+%M+%S or %qX) and date
+part (%y+(%b|%m)+%d or %qx).")
+
+(defun YaTeX::ref-alphabex (n)
+  (let ((alphabex ""))
+    (while (> n 0)
+      (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex)
+	    n (/ n 26)))
+    alphabex))
+
+(defun YaTeX::ref-default-label (&optional format)
+  "Default auto-genarated label string."
+  ;; We do not use (format-time-string) for emacs-19
+  (let*((ts (substring (current-time-string) 4))
+	(y (substring ts -2))
+	(b (substring ts 0 3))
+	(d (format "%d" (string-to-int (substring ts 4 6))))
+	(H (substring ts 7 9))
+	(M (substring ts 10 12))
+	(S (substring ts 13 15))
+	(HMS (+ (* 10000 (string-to-int H))
+		(* 100 (string-to-int M))
+		(string-to-int S)))
+	(talphabex (YaTeX::ref-alphabex HMS))
+	(mnames "JanFebMarAprMayJunJulAugSepOctNovDec")
+	(m (format "%02d" (/ (string-match b mnames) 3)))
+	(ymd (+ (* 10000 (string-to-int y))
+		(* 100 (string-to-int m))
+		(string-to-int d)))
+	(dalphabex (YaTeX::ref-alphabex ymd)))
+    (YaTeX-replace-formats
+     (or format YaTeX-ref-default-label-string)
+     (list (cons "y" y)
+	   (cons "b" b)
+	   (cons "m" m)
+	   (cons "d" d)
+	   (cons "H" H)
+	   (cons "M" M)
+	   (cons "S" S)
+	   (cons "qX" talphabex)
+	   (cons "qx" dalphabex)))))
+
+(defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label
+  "*Function to generate default label for unnamed \\label{}s.
+The function pointed to this value should take two arguments.
+First argument is LaTeX macro's name, second is macro's argument.")
+
+(defun YaTeX::ref-generate-label (command arg)
   "Generate a label string which is unique in current buffer."
-  (let ((default (substring (current-time-string) 4)))
+  (let ((default (condition-case nil
+		     (YaTeX::ref-default-label)
+		   (error (substring (current-time-string) 4)))))
     (read-string "Give a label for this line: "
 		 (if YaTeX-emacs-19 (cons default 1) default))))
 
-(defun YaTeX::ref-getset-label (buffer point)
+(defun YaTeX::ref-getset-label (buffer point &optional noset)
   "Get label string in the BUFFER near the POINT.
-Make \\label{xx} if no label."
+Make \\label{xx} if no label.
+If optional third argument NOSET is non-nil, do not generate new label."
   ;;Here, we rewrite the LaTeX source.  Therefore we should be careful
   ;;to decide the location suitable for \label.  Do straightforward!
-  (let (boundary inspoint cc newlabel (labelholder "label") mathp env
-       (r-escape (regexp-quote YaTeX-comment-prefix)))
-    ;;(set-buffer buffer)
-    (switch-to-buffer buffer)
+  (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env
+       (r-escape (regexp-quote YaTeX-comment-prefix))
+       command arg alreadysought foundpoint)
+    (set-buffer buffer)
     (save-excursion
       (goto-char point)
       (setq cc (current-column))
       (if (= (char-after (point)) ?\\) (forward-char 1))
       (cond
        ((looking-at YaTeX-sectioning-regexp)
+	(setq command (YaTeX-match-string 0))
 	(skip-chars-forward "^{")
-	(forward-list 1)
+	(setq arg (buffer-substring
+		   (1+ (point))
+		   (progn (forward-list 1) (1- (point)))))
 	(skip-chars-forward " \t\n")
 	;(setq boundary "[^\\]")
 	(setq inspoint (point))
@@ -507,7 +600,8 @@
 		    (match-beginning 0)
 		  (1- (point))))))
        ((looking-at "item\\s ")
-	(setq cc (+ cc 6))
+	(setq command "item"
+	      cc (+ cc 6))
 	;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b"))
 	(setq boundary
 	      (save-excursion
@@ -518,7 +612,8 @@
 		  (1- (point))))
 	      inspoint boundary))
        ((looking-at "bibitem")
-	(setq labelholder "bibitem")	; label holder is bibitem itself
+	(setq labelholder "bibitem"	; label holder is bibitem itself
+	      command "bibitem")
 	(setq boundary
 	      (save-excursion
 		(if (YaTeX-re-search-active-forward
@@ -527,19 +622,50 @@
 		    (match-beginning 0)
 		  (1- (point))))
 	      inspoint boundary))
-       ((string-match YaTeX::ref-mathenv-regexp
+       ((string-match YaTeX::ref-nestable-counter-regexp
 		      (setq env (or (YaTeX-inner-environment t) "document")))
-	(setq mathp t)
+	(let ((curtop (get 'YaTeX-inner-environment 'point))
+	      (end (point-max)) label)
+	  (skip-chars-forward " \t\n")
+	  (setq inspoint (point)	;initial candidate
+		cc (current-column)
+		command env
+		alreadysought t)
+	  (if (condition-case nil
+		  (progn
+		    (goto-char curtop)
+		    (YaTeX-goto-corresponding-environment))
+		(error nil))
+	      (setq end (point)))
+	  (goto-char inspoint)
+	  (while (YaTeX-re-search-active-forward
+		  (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" )
+		  r-escape end t)
+	    (setq label (YaTeX-match-string 1))
+	    (if (and (equal env (YaTeX-inner-environment t))
+		     (= curtop (get 'YaTeX-inner-environment 'point)))
+		;;I found the label
+		(setq alreadysought label
+		      foundpoint (match-end 0))))
+	  ))
+       ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case
+	(setq command env
+	      mathp t
+	      exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env))
 	;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)"))
 	(setq boundary
 	      (save-excursion
 		(if (YaTeX-re-search-active-forward
-		     (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")
+		     (concat
+		      YaTeX-ec-regexp "\\("
+		      (if exp1 "" "\\\\\\|")
+		      "end{" env "}\\)")
 		     r-escape nil 1)
 		    (match-beginning 0)
 		  (1- (point))))
 	      inspoint boundary))
        ((looking-at "footnote\\s *{")
+	(setq command "footnote")
 	(skip-chars-forward "^{")	;move onto `{'
 	(setq boundary
 	      (save-excursion
@@ -550,10 +676,13 @@
 		(1- (point)))
 	      inspoint boundary))
        ((looking-at "caption\\|\\(begin\\)")
+	(setq command (YaTeX-match-string 0))
 	(skip-chars-forward "^{")
 	;;;;;;(if (match-beginning 1) (forward-list 1))
 	;; caption can be treated as mathenv, is it right??
-	(forward-list 1)
+	(setq arg (buffer-substring
+		   (1+ (point))
+		   (progn (forward-list 1) (1- (point)))))
 	;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b"))
 	(setq inspoint (point))
 	(setq boundary
@@ -566,55 +695,81 @@
        (t ))
       (if (save-excursion (skip-chars-forward " \t") (looking-at "%"))
 	  (forward-line 1))
-      (if (and (save-excursion
-		 (YaTeX-re-search-active-forward
-		  ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)")
-		  labelholder
-		  (regexp-quote YaTeX-comment-prefix)
-		  boundary 1))
-	       (match-beginning 0))
+      (cond
+       ((stringp alreadysought)
+	(put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly...
+	alreadysought)
+       ((and (null alreadysought)
+	     (> boundary (point))
+	     (save-excursion
+	       (YaTeX-re-search-active-forward
+		;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)")
+		labelholder
+		(regexp-quote YaTeX-comment-prefix)
+		boundary 1))
+	     (match-beginning 0))
 	  ;; if \label{hoge} found, return it
-	  (buffer-substring
-	   (progn
-	     (goto-char (match-end 0))
-	     (skip-chars-forward "^{") (1+ (point)))
-	   (progn
-	     (forward-sexp 1) (1- (point))))
+	(put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0)))
+	(buffer-substring
+	 (progn
+	   (goto-char (match-end 0))
+	   (skip-chars-forward "^{") (1+ (point)))
+	 (progn
+	   (forward-sexp 1) (1- (point)))))
 	;;else make a label
 	;(goto-char (match-beginning 0))
+       (noset    nil)				;do not set label if noset
+       (t
 	(goto-char inspoint)
 	(skip-chars-backward " \t\n")
-	(save-excursion (setq newlabel (YaTeX::ref-generate-label)))
+	(save-excursion
+	  (setq newlabel
+		(funcall YaTeX-ref-generate-label-function command arg)))
 	(delete-region (point) (progn (skip-chars-backward " \t") (point)))
 	(if mathp nil 
 	  (insert "\n")
 	  (YaTeX-reindent cc))
 	(insert (format "\\label{%s}" newlabel))
-	newlabel))))
+	newlabel)))))
 
+(defvar YaTeX::ref-labeling-regexp-alist-default
+  '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2)
+    ("\\\\label{\\([^}]+\\)}" . 1))
+  "Alist of labeling regexp vs. its group number points to label string.
+This alist is used in \\ref's argument's completion.")
+(defvar YaTeX::ref-labeling-regexp-alist-private nil
+  "*Private extesion to YaTeX::ref-labeling-regexp-alist.
+See the documetation of YaTeX::ref-labeling-regexp-alist.")
 (defvar YaTeX::ref-labeling-regexp-alist
-  '(("\\\\begin{java}{\\([^}]+\\)}" . 1)
-    ("\\\\label{\\([^}]+\\)}" . 1)))
+  (append YaTeX::ref-labeling-regexp-alist-default
+	  YaTeX::ref-labeling-regexp-alist-private))
 (defvar YaTeX::ref-labeling-regexp
   (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|"))
 (defvar YaTeX::ref-mathenv-regexp
-  "equation\\|eqnarray\\|align\\|gather\\|alignat\\|xalignat")
+  ;; See also YaTeX-ams-math-begin-alist in yatex.el
+  ;; Define only envs which has counter.(without *)
+  "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline")
+(defvar YaTeX::ref-mathenv-exp1-regexp
+  "\\(equation\\|multline\\)\\b"
+  "*Regexp of math-envname which has only one math-expression.")
 (defvar YaTeX::ref-enumerateenv-regexp
   "enumerate")
+(defvar YaTeX::ref-nestable-counter-regexp
+  "subequations")
 
 (defvar YaTeX::ref-labeling-section-level 2
   "*ref補完で収集するセクショニングコマンドの下限レベル
 YaTeX-sectioning-levelの数値で指定.")
 
-(defun YaTeX::ref (argp &optional labelcmd refcmd)
+(defun YaTeX::ref (argp &optional labelcmd refcmd predf)
   (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache
   (require 'yatexsec)
   (cond
    ((= argp 1)
-    (let*((lnum 0) e0 x cmd label match-point point-list boundary
+    (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary
 	  (buf (current-buffer))
 	  (llv YaTeX::ref-labeling-section-level)
-	  (mathenvs YaTeX::ref-mathenv-regexp)
+	  (mathenvs YaTeX::ref-mathenv-regexp) envname endrx
 	  (enums YaTeX::ref-enumerateenv-regexp)
 	  (counter
 	   (or labelcmd
@@ -631,7 +786,12 @@
 			YaTeX-sectioning-level))
 		 "\\|")
 		"\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){"
-		"\\|\\(begin{\\(" mathenvs "\\|" enums  "\\)\\)\\)")))
+		"\\|\\(begin{\\(" mathenvs "\\|" enums  "\\)}\\)"
+		(if YaTeX-use-AMS-LaTeX
+		    (concat
+		     "\\|\\(begin{"
+		     YaTeX::ref-nestable-counter-regexp "}\\)"))
+		"\\)")))
 	  (regexp (concat "\\(" counter
 			  "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)"))
 	  (itemsep (concat YaTeX-ec-regexp
@@ -642,9 +802,9 @@
 	  (output
 	   (function
 	    (lambda (label p)
-	      (while (setq x (string-match "\n" label))
+	      (while (setq x (string-match "[\n\t]" label))
 		(aset label x ? ))
-	      (while (setq x (string-match "[ \t\n][ \t\n]+" label))
+	      (while (setq x (string-match "  +" label))
 		(setq label (concat
 			     (substring label 0 (1+ (match-beginning 0)))
 			     (substring label (match-end 0)))))
@@ -652,6 +812,7 @@
 	      (setq point-list (cons p point-list))
 	      (message "Collecting labels... %d" lnum)
 	      (setq lnum (1+ lnum)))))
+	  (me (if (boundp 'me) me 'YaTeX::ref))
 	  )
       (message "Collecting labels...")
       (save-window-excursion
@@ -665,12 +826,16 @@
 	      (set-buffer buf)))
 	(save-excursion
 	  (set-buffer (get-buffer-create YaTeX-label-buffer))
+	  (condition-case ()
+	      (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode))
+		  (font-lock-mode 1))
+	    (error nil))
 	  (setq buffer-read-only nil)
 	  (erase-buffer))
 	(save-excursion
 	  (set-buffer buf)
 	  (goto-char (point-min))
-	  (let ((standard-output (get-buffer YaTeX-label-buffer)))
+	  (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel)
 	    (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf)))
 	    (while (YaTeX-re-search-active-forward
 		    regexp ;;counter
@@ -678,28 +843,118 @@
 	      ;(goto-char (match-beginning 0))
 	      (setq e0 (match-end 0))
 	      (cond
+	       ;; 
+	       ;;2005/10/21 Skip it if predicate function returns nil
+	       ((and predf
+		     (let ((md (match-data)))
+		       (prog1
+			   (condition-case nil
+			       (not (funcall predf))
+			     (error nil))
+			 (store-match-data md)))))
 	       ((YaTeX-literal-p) nil)
 	       ((YaTeX-match-string 1)
 		;;if standard counter commands found 
-		(setq cmd (YaTeX-match-string 2))
+		(setq cmd (YaTeX-match-string 2)
+		      m0 (match-beginning 0))
 		(setq match-point (match-beginning 0))
 		(or initl
 		    (if (< p (point)) (setq initl lnum)))
 		(cond
+		 ;; In any case, variables e0 should be set
+		 ((and YaTeX-use-AMS-LaTeX
+		       (string-match YaTeX::ref-nestable-counter-regexp cmd))
+		  (let (label)
+		    (skip-chars-forward "}")
+		    (setq label (buffer-substring
+				 (point) (min (+ 80 (point)) (point-max))))
+		    ;; to skip (maybe)auto-generated comment
+		    (skip-chars-forward " \t")
+		    (if (looking-at YaTeX-comment-prefix)
+			(forward-line 1))
+		    (setq e0 (point))
+		    (skip-chars-forward " \t\n")
+		    (if (looking-at "\\\\label{\\([^}]+\\)}")
+			(setq label (format "(labe:%s)" (YaTeX-match-string 1))
+			      e0 (match-end 1)))
+		    (funcall output (format "--subequation--%s" label) e0)))
 		 ((string-match mathenvs cmd) ;;if matches mathematical env
 		  ;(skip-chars-forward "} \t\n")
-		  (forward-line 1)
-		  (setq x (point))
-		  (catch 'scan
-		    (while (YaTeX-re-search-active-forward
-			    (concat "\\\\\\\\$\\|\\\\end{\\(" mathenvs "\\)")
-			    percent nil t)
-		      (let ((quit (match-beginning 1)))
-			(funcall output
-				 (buffer-substring x (match-beginning 0))
-				 x)
-			(if quit (throw 'scan t)))
-		      (setq x (point))))
+		  ;(forward-line 1) ;2004/1/25
+		  (skip-chars-forward "}")
+		  (setq x (point)
+			envname (substring
+				 cmd (match-beginning 0) (match-end 0)))
+		  (save-restriction
+		    (narrow-to-region
+		     m0
+		     (save-excursion
+		       (YaTeX-re-search-active-forward
+			(setq endrx (format "%send{%s}" YaTeX-ec-regexp
+					    (regexp-quote envname)))
+			percent nil t)))
+		    (catch 'scan
+		      (while (YaTeX-re-search-active-forward
+			      (concat
+			       "\\\\end{\\(" (regexp-quote envname) "\\)";;(1)
+			       (if YaTeX-use-AMS-LaTeX
+				   "\\|\\\\\\(notag\\)") ;;2
+			       (if (string-match
+				    YaTeX::ref-mathenv-exp1-regexp  cmd)
+				   "" "\\|\\\\\\\\$")
+			       )
+			      percent nil t)
+			(let*((quit (match-beginning 1))
+			      (notag (match-beginning 2))
+			      (label ".......................") l2
+			      (e (point)) (m0 (match-beginning 0))
+			      (ln (YaTeX-string-width label)))
+			  (cond
+			   (notag
+			    (YaTeX-re-search-active-forward
+			     "\\\\\\\\" percent nil 1)
+			    (setq x (point)))
+			   (t
+			    (if (YaTeX-re-search-active-backward
+				 YaTeX::ref-labeling-regexp
+				 percent x t)
+				;; if \label{x} in math-expression, display it
+				;; because formula source is hard to recognize
+				(progn
+				  (goto-char (match-end 0))
+				  (setq l2 (format "\"label:%s\""
+						   (buffer-substring
+						    (1- (point))
+						    (progn (forward-sexp -1)
+							   (1+ (point))))))
+				  (setq label
+					(if (< (YaTeX-string-width l2) ln)
+					    (concat
+					     l2
+					     (substring
+					      label
+					      0 (- ln (YaTeX-string-width l2))))
+					  l2))
+				  (goto-char e)))
+			    (funcall output
+				     (concat
+				      label " "
+				      (buffer-substring x m0))
+				     x)
+			    (cond
+			     ((YaTeX-quick-in-environment-p
+			       YaTeX-math-gathering-list)
+			      ;; if here is inner split/cases/gathered env.,
+			      ;; counter for here is only one.
+			      ;; Go out this environment and,
+			      (YaTeX-end-of-environment)
+			      ;; search next expression unit boundary.
+			      (YaTeX-re-search-active-forward
+			       (concat endrx "\\|\\\\begin{")
+			       percent nil 1)
+			      (end-of-line)))
+			    (if quit (throw 'scan t)))))
+			(setq x (point)))))
 		  (setq e0 (point)))
 		 ((string-match enums cmd)
 		  ;(skip-chars-forward "} \t\n")
@@ -715,15 +970,51 @@
 		      (setq x (match-beginning 0))
 		      (funcall
 		       output
-		       (buffer-substring
-			(match-beginning 0)
-			(if (re-search-forward itemsep nil t)
-			    (progn (goto-char (match-beginning 0))
-				   (skip-chars-backward " \t")
-				   (1- (point)))
-			  (point-end-of-line)))
+		       (concat
+			existlabel
+			(buffer-substring
+			 (match-beginning 0)
+			 (if (re-search-forward itemsep nil t)
+			     (progn (goto-char (match-beginning 0))
+				    (skip-chars-backward " \t")
+				    (1- (point)))
+			   (point-end-of-line))))
 		       x))
 		    (setq e0 (point-max))))
+		 ((string-match "bibitem" cmd) ;maybe generated by myself
+		  (setq label "")
+		  (skip-chars-forward " \t")
+		  (if (looking-at "{")	;sure to be true!!
+		      (forward-list 1))
+		  (let ((list '(30 10 65))
+			(delim ";") q lim len l str)
+		    (save-excursion
+		      (setq lim (if (re-search-forward itemsep nil 1)
+				    (match-beginning 0) (point))))
+		    (while list
+		      (skip-chars-forward " \t\n\\")
+		      (setq q (looking-at "[\"'{]")
+			    len (car list)
+			    str
+			    (buffer-substring
+			     (point)
+			     (progn
+			       (if q (forward-sexp 1)
+				 (search-forward delim lim 1)
+				 (forward-char -1))
+			       (point))))
+		      (if (> (setq l (YaTeX-string-width str)) len)
+			  (setq str (concat
+				     (YaTeX-truncate-string-width
+				      str (- len (if q 5 4)))
+				     "... "
+				     (if q (substring str -1)))))
+		      (if (< (setq l (YaTeX-string-width str)) len)
+			  (setq str (concat str (make-string (- len l) ? ))))
+		      (if (looking-at delim) (goto-char (match-end 0)))
+		      (setq label (concat label " " str)
+			    list (cdr list)))
+		    (funcall output label match-point)))
 		 ;;else, simple section-type counter
 		 ((= (char-after (1- (point))) ?{)
 		  (setq label (buffer-substring
@@ -733,6 +1024,8 @@
 				      (point))))
 		  (funcall output label match-point)
 		  ;; Skip preceding label if exists
+		  (if (YaTeX::ref-getset-label (current-buffer) match-point t)
+		      (goto-char (get 'YaTeX::ref-getset-label 'foundpoint)))
 		  (if (save-excursion
 			(skip-chars-forward "\t \n")
 			(looking-at YaTeX::ref-labeling-regexp))
@@ -819,14 +1112,45 @@
 	label)))))
 
 (fset 'YaTeX::pageref 'YaTeX::ref)
+(defun YaTeX::tabref (argp)	    ; For the style file of IPSJ journal
+  (YaTeX::ref
+   argp nil nil
+   (function
+    (lambda ()
+      (YaTeX-quick-in-environment-p "table")))))
+(defun YaTeX::figref (argp)	    ; For the style file of IPSJ journal
+  (YaTeX::ref
+   argp nil nil
+   (function
+    (lambda ()
+      (YaTeX-quick-in-environment-p "figure")))))
 
-(defun YaTeX::cite-collect-bibs-external (&rest files)
-  "Collect bibentry from FILES(variable length argument);
+(defun YaTeX::cite-collect-bibs-external (bibptn &rest files)
+  "Collect bibentry from FILES(variable length argument) ;
 and print them to standard output."
   ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html
-  (let ((tb (get-buffer-create " *bibtmp*")))
+  (let*((tb (get-buffer-create " *bibtmp*"))
+	(bibitemsep "^\\s *@[A-Za-z]")
+	(target (if (string< "" bibptn) bibptn bibitemsep))
+	(checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep))
+	beg
+	(searchnext
+	 (if (string< "" bibptn)
+	     (function
+	      (lambda()
+		(setq beg (point))
+		(and
+		 (prog1
+		     (re-search-forward target nil t)
+		   (end-of-line))
+		 (re-search-backward bibitemsep beg t))))
+	   (function
+	    (lambda()
+	      (re-search-forward target nil t)))))
+	)
     (save-excursion
       (set-buffer tb)
+      (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))
       (while files
 	(erase-buffer)
 	(cond
@@ -836,8 +1160,9 @@
 	  (insert-file-contents (concat (car files) ".bib"))))
 	(save-excursion
 	  (goto-char (point-min))
-	  (while (re-search-forward "^\\s *@[A-Za-z]" nil t)
+	  (while (funcall searchnext)
 	    (skip-chars-forward "^{,")
+	    (setq beg (point))
 	    (if (= (char-after (point)) ?{)
 		(princ (format "%sbibitem{%s}%s\n"
 			       YaTeX-ec
@@ -845,39 +1170,64 @@
 				(1+ (point))
 				(progn (skip-chars-forward "^,\n")
 				       (point)))
-			       (if (re-search-forward "title\\s *=" nil t)
-				   (buffer-substring
-				    (progn
-				      (goto-char (match-end 0))
-				      (skip-chars-forward " \t\n")
-				      (point))
-				    (progn
-				      (if (looking-at "[{\"]")
-					  (forward-sexp 1)
-					(forward-char 1)
-					(skip-chars-forward "^,"))
-				      (point)))))))))
-	(setq files (cdr files))))))
+			       (mapconcat
+				(function
+				 (lambda (kwd)
+				   (goto-char beg)
+				   (if (re-search-forward
+					(concat kwd "\\s *=") nil t)
+				       (buffer-substring
+					(progn
+					  (goto-char (match-end 0))
+					  (skip-chars-forward " \t\n")
+					  (point))
+					(progn
+					  (if (looking-at "[{\"]")
+					      (forward-sexp 1)
+					    (forward-char 1)
+					    (skip-chars-forward "^,}"))
+					  (point))))))
+				'("author" "year" "title" )
+				";"))))
+	    (and (re-search-forward bibitemsep nil t)
+		 (forward-line -1))))
+	(setq files (cdr files)))
+      (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)))))
 
 (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem"
   "*Regexp of macro name of bibitem definition")
 
-(defun YaTeX::cite-collect-bibs-internal ()
+(defun YaTeX::cite-collect-bibs-internal (bibptn)
   "Collect bibentry in the current buffer and print them to standard output."
   (let ((ptn (concat YaTeX-ec-regexp
 		     "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b"))
+	(lim (concat YaTeX-ec-regexp
+		     "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)"
+		     "\\|\\(end{\\)"))
 	(pcnt (regexp-quote YaTeX-comment-prefix)))
+    ;; Using bibptn not yet implemented.
+    ;; Do you need it?? 2005/11/22
     (save-excursion
       (while (YaTeX-re-search-active-forward ptn pcnt nil t)
 	(skip-chars-forward "^{\n")
 	(or (eolp)
-	    (princ (format "%sbibitem{%s}\n"
+	    (princ (format "%sbibitem%s %s\n"
 			   YaTeX-ec
 			   (buffer-substring
-			    (1+ (point))
-			    (progn (forward-sexp 1) (point))))))))))
+			    (point)
+			    (progn (forward-sexp 1) (point)))
+			   (buffer-substring
+			    (progn (skip-chars-forward "\n \t") (point))
+			    (save-excursion
+			      (if (YaTeX-re-search-active-forward
+				   lim pcnt nil t)
+				  (progn
+				    (goto-char (match-beginning 0))
+				    (skip-chars-backward "\n \t")
+				    (point))
+				(point-end-of-line)))))))))))
 
-(defun YaTeX::cite (argp)
+(defun YaTeX::cite (argp &rest dummy)
   (cond
    ((eq argp 1)
     (let* ((cb (current-buffer))
@@ -886,8 +1236,10 @@
 	   (hilit-auto-highlight nil)
 	   (pcnt (regexp-quote YaTeX-comment-prefix))
 	   (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}"))
+	   (bibptn (read-string "Pattern: "))
 	   (bbuf (get-buffer-create " *bibitems*"))
 	   (standard-output bbuf)
+	   (me 'YaTeX::cite)		;shuld set this for using YaTeX::ref
 	   bibs files)
       (set-buffer bbuf)(erase-buffer)(set-buffer cb)
       (save-excursion
@@ -895,10 +1247,11 @@
 	;;(1)search external bibdata
 	(while (YaTeX-re-search-active-forward bibrx pcnt nil t)
 	  (apply 'YaTeX::cite-collect-bibs-external
+		 bibptn
 		 (YaTeX-split-string
 		  (YaTeX-match-string 1) ",")))
 	;;(2)search direct \bibitem usage
-	(YaTeX::cite-collect-bibs-internal)
+	(YaTeX::cite-collect-bibs-internal bibptn)
 	(if (progn
 	      (YaTeX-visit-main t)
 	      (not (eq (current-buffer) cb)))
@@ -907,12 +1260,15 @@
 	      ;;(1)search external bibdata
 	      (while (YaTeX-re-search-active-forward bibrx pcnt nil t)
 		(apply 'YaTeX::cite-collect-bibs-external
+		       bibptn
 		       (YaTeX-split-string
 			(YaTeX-match-string 1) ",")))
 	      ;;(2)search internal
-	      (YaTeX::cite-collect-bibs-internal)))
+	      (YaTeX::cite-collect-bibs-internal bibptn)))
 	;;Now bbuf holds the list of bibitem
 	(set-buffer bbuf)
+	;;;(switch-to-buffer bbuf)
+	(if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer))
 	(YaTeX::ref
 	 argp 
 	 (concat "\\\\\\("
@@ -929,6 +1285,8 @@
 (fset 'YaTeX::possessivecite 'YaTeX::cite)
 (fset 'YaTeX::citeyear 'YaTeX::cite)
 (fset 'YaTeX::citename 'YaTeX::cite)
+(fset 'YaTeX::citep 'YaTeX::cite)
+(fset 'YaTeX::citet 'YaTeX::cite)
 
 (defun YaTeX-yatex-buffer-list ()
   (save-excursion
@@ -982,7 +1340,7 @@
      ((null rv) "")
      (t
       (set-buffer rv)
-      (YaTeX::ref argp labelcmd refcmd)))))
+      (funcall me argp labelcmd refcmd)))))
 
 ;;
 ; completion for the arguments of \newcommand
@@ -1020,6 +1378,12 @@
       ))
    (t "")))
 
+(defun YaTeX::newcounter (&optional argp)
+  (cond
+   ((= argp 1)
+    (read-string "New counter name: "))
+   (t "")))
+
 ;;
 ; completion for the arguments of \pagestyle
 ;;
@@ -1159,16 +1523,6 @@
 (defvar YaTeX:documentstyle-options-local nil
   "List of LaTeX local documentstyle options.")
 
-(defvar YaTeX-minibuffer-completion-map nil
-  "Minibuffer completion key map that allows comma completion.")
-(if YaTeX-minibuffer-completion-map nil
-  (setq YaTeX-minibuffer-completion-map
-	(copy-keymap minibuffer-local-completion-map))
-  (define-key YaTeX-minibuffer-completion-map " "
-    'YaTeX-minibuffer-complete)
-  (define-key YaTeX-minibuffer-completion-map "\t"
-    'YaTeX-minibuffer-complete))
-
 (defun YaTeX:documentstyle ()
   (let*((delim ",")
 	(dt (append YaTeX:documentstyle-options-local
@@ -1210,6 +1564,16 @@
       (if (string= "" sname) (setq sname YaTeX-default-document-style))
       (setq YaTeX-default-document-style sname)))))
 
+(defun YaTeX::include (argp &optional prompt)
+  (cond
+   ((= argp 1)
+    (let*((insert-default-directory)
+	  (file (read-file-name (or prompt "Input file: ") "")))
+      (setq file (substring file 0 (string-match "\\.tex$" file)))))))
+
+(fset 'YaTeX::input 'YaTeX::include)
+
+
 ;;; -------------------- LaTeX2e stuff --------------------
 (defvar YaTeX:documentclass-options-default
   '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt")
@@ -1325,6 +1689,8 @@
 (fset 'YaTeX:colorbox 'YaTeX:textcolor)
 (fset 'YaTeX::colorbox 'YaTeX::textcolor)
 (fset 'YaTeX:fcolorbox 'YaTeX:textcolor)
+(fset 'YaTeX:pagecolor 'YaTeX:textcolor)
+(fset 'YaTeX::pagecolor 'YaTeX::textcolor)
 
 (defun YaTeX::fcolorbox (argp)
   (cond
@@ -1333,14 +1699,46 @@
    ((= argp 3) (read-string "Colored string: "))))
 
 (defun YaTeX:scalebox ()
-  "Add-in for \\rotatebox"
-  (let ((vmag (read-string (if YaTeX-japan "倍率: " "Magnification: ")))
-	(hmag (read-string (if YaTeX-japan "横倍率(省略可): "
-			     "Horizontal magnification(Optional): "))))
+  "Add-in for \\scalebox"
+  (let ((vmag (read-string
+	       (if YaTeX-japan "倍率(負で反転): "
+		 "Magnification(Negative for flipped): ")))
+	(hmag (read-string (if YaTeX-japan "縦倍率(省略可): "
+			     "Vertical magnification(Optional): "))))
     (if (and hmag (string< "" hmag))
 	(format "{%s}[%s]" vmag hmag)
       (format "{%s}" vmag))))
 
+(defun YaTeX:rotatebox ()
+  "Optional argument add-in for \\rotatebox"
+  (message "Rotate origin? (N)one (O)rigin (X)-Y: ")
+  (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something)
+    (cond
+     ((memq c '(?O ?o))
+      (if (string< "" (setq r (YaTeX:read-oneof "htbpB")))
+	  (concat "[origin=" r "]")))
+     ((memq c '(?X ?x ?Y ?y))
+      (setq r (read-string "" (if YaTeX-emacs-19 (cons defx 3) defx))
+	    x (if (string< "x=" r) r)
+	    r (read-string "" (if YaTeX-emacs-19 (cons defy 3) defy))
+	    y (if (string< "y=" r) r)
+	    something (or x y))
+      (format "%s%s%s%s%s"
+	      (if something "[" "")
+	      (if x x "")
+	      (if (and x y) "," "")
+	      (if y y "")
+	      (if something "]" ""))))))
+
+(defun YaTeX::rotatebox (argp)
+  "Argument add-in for \\rotatebox"
+  (cond
+   ((= argp 1)
+    (read-string (if YaTeX-japan "回転角(度; 左回り): "
+		   "Angle in degree(unclockwise): ")))
+   ((= argp 2)
+	(read-string (if YaTeX-japan "テキスト: " "Text: ")))))
+
 (defun YaTeX:includegraphics ()
   "Add-in for \\includegraphics's option"
   (let (width height (scale "") angle str)
@@ -1364,21 +1762,21 @@
 
 (defun YaTeX::includegraphics (argp)
   "Add-in for \\includegraphics"
-  (cond
-   ((= argp 1)
-    (read-file-name "EPS File: " ""))))
+  (YaTeX::include argp "Image File: "))
  
 (defun YaTeX:caption ()
   (setq YaTeX-section-name "label")
   nil)
 
+
 (defvar YaTeX::usepackage-alist-default
   '(("version") ("plext") ("url") ("fancybox") ("pifont") ("longtable")
     ("ascmac") ("bm") ("graphics") ("graphicx") ("alltt") ("misc") ("eclbkbox")
     ("amsmath") ("amssymb") ("xymtex") ("chemist")
     ("a4j") ("array") ("epsf") ("color") ("epsfig") ("floatfig")
-    ("landscape") ("path") ("supertabular") ("twocolumn"))
-  "Default completion table for arguments of \usepackage")
+    ("landscape") ("path") ("supertabular") ("twocolumn")
+    ("latexsym") ("times") ("makeidx"))
+  "Default completion table for arguments of \\usepackage")
 
 (defvar YaTeX::usepackage-alist-private nil
   "*Private completion list of the argument for usepackage")
@@ -1390,11 +1788,14 @@
   (cond
    ((equal argp 1)
     (setq YaTeX-env-name "document")
-    (YaTeX-cplread-with-learning
-     "Use package: "
-     'YaTeX::usepackage-alist-default
-     'YaTeX::usepackage-alist-private
-     'YaTeX::usepackage-alist-local))))
+    (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map)
+	  (delim ","))
+      (YaTeX-cplread-with-learning
+       (if YaTeX-japan "Use package(カンマで区切ってOK): "
+	 "Use package(delimitable by comma): ")
+       'YaTeX::usepackage-alist-default
+       'YaTeX::usepackage-alist-private
+       'YaTeX::usepackage-alist-local)))))
 
 (defun YaTeX::mask (argp)
   (cond
@@ -1422,8 +1823,20 @@
    ((equal argp 4)
     (YaTeX:read-oneof "lcr" 'quick))
    ((equal argp 5)
-    (read-string "String: "))
-))
+    (read-string "String: "))))
+
+(defun YaTeX::textcircled (argp)
+  (cond
+   ((equal argp 1)
+    (let ((char (read-string "Circled char: "))
+	  (left "") (right "") c)
+      (setq c (read-char
+	       "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:"))
+      (cond
+       ((memq c '(?s ?S)) (setq left "{\\small " right "}"))
+       ((memq c '(?t ?T)) (setq left "{\\tiny " right "}"))
+       ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}")))
+      (format "%s%s%s" left char right)))))
 
 ;;; -------------------- math-mode stuff --------------------
 (defun YaTeX::tilde (&optional pos)
@@ -1509,6 +1922,11 @@
 		(YaTeX-kill-paren nil))))))
   (message ""))
 
+(defun YaTeX::DeclareMathOperator (argp)
+  (cond
+   ((equal argp 1)
+    (read-string "Operator: " "\\"))))
+
 ;;;
 ;; Add-in functions for large-type command.
 ;;;
@@ -1524,5 +1942,5 @@
 ; fill-prefix: ";;; "
 ; paragraph-start: "^$\\|\\|;;;$"
 ; paragraph-separate: "^$\\|\\|;;;$"
-; buffer-file-coding-system: sjis
+; coding: sjis
 ; End:
--- a/yatexenv.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexenv.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX environment-specific functions.
 ;;; yatexenv.el
-;;; (c) 1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Fri Jun 27 12:09:30 2003 on firestorm
+;;; (c) 1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Sat Jun 24 08:14:11 2006 on firestorm
 ;;; $Id$
 
 ;;;
@@ -10,8 +10,8 @@
 ;;;
 
 ;; Showing the matching column of tabular environment.
-(defun YaTeX-array-what-column ()
-  "Show matching columne title of array environment.
+(defun YaTeX-array-what-column-internal ()
+  "Return the cons of matching column and its title of array environment.
 When calling from a program, make sure to be in array/tabular environment."
   (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&")
 	(n 0) j
@@ -54,18 +54,23 @@
 	    (error "This column exceeds the limit."))
 	(setq j (1- j)))
       (skip-chars-forward "\\s ")
-      (message
-       "This is the column(#%d) of: %s" n
-       (buffer-substring
-	(point)
-	(progn
-	  (re-search-forward (concat andptn "\\|" nlptn) eot)
-	  (goto-char (match-beginning 0))
-	  (if (looking-at andptn)
-	      (forward-char 1))
-	  (skip-chars-backward "\\s ")
-	  (point))))))
-)
+      (list n
+	    (buffer-substring
+	     (point)
+	     (progn
+	       (re-search-forward (concat andptn "\\|" nlptn) eot)
+	       (goto-char (match-beginning 0))
+	       (if (looking-at andptn)
+		   (forward-char 1))
+	       (skip-chars-backward "\\s ")
+	       (point)))))))
+
+(defun YaTeX-array-what-column ()
+  "Show matching column title of array environment.
+When calling from a program, make sure to be in array/tabular environment."
+  (apply 'message
+	 "This is the column(#%d) of: %s"
+	 (YaTeX-array-what-column-internal)))
 
 ;;;###autoload
 (defun YaTeX-what-column ()
@@ -74,28 +79,12 @@
   (cond
    ((YaTeX-quick-in-environment-p '("tabular" "tabular*" "array" "array*"))
     (YaTeX-array-what-column))
-   (t (message "Not in array/tabular environment.")))
-)
+   (t (message "Not in array/tabular environment."))))
 
-(defun YaTeX-tabular-parse-format (&optional tabular*)
-  "Parse `tabular' format.
-Return the list of (No.ofCols PointEndofFormat)"
-  (let ((p (point)) elt boform eoform (cols 0))
-    (save-excursion
-      (if (null (YaTeX-beginning-of-environment t))
-	  (error "Beginning of tabular not found."))
-      (skip-chars-forward "^{")
-      (forward-list 1)
-      (if tabular*
-	  (progn (skip-chars-forward "^{")
-		 (forward-list 1)))
-      (skip-chars-forward "^{" p)
-      (if (/= (following-char) ?\{) (error "Tabular format not found."))
-      (setq boform (1+ (point))
-	    eoform (progn (forward-list 1) (1- (point))))
-      (if (> eoform p) (error "Non-terminated tabular format."))
-      (goto-char boform)
-      (while (< (point) eoform)
+(defun YaTeX-tabular-parse-format-count-cols (beg end)
+  (goto-char beg)
+  (let (elt (cols 0))
+    (while (< (point) end)
 	(setq elt (following-char))
 	(cond
 	 ((string-match (char-to-string elt) "clr") ;normal indicators.
@@ -105,16 +94,60 @@
 	  (forward-char 1))
 	 ((string-match (char-to-string elt) "p@") ;p or @ expression
 	  (setq cols (+ (if (eq elt ?p) 1 0) cols))
-	  (skip-chars-forward "^{" p)
+	  ;;(skip-chars-forward "^{" p)
+	  (skip-chars-forward "^{" end)
 	  (forward-list 1))
+	 ((equal elt ?*)		;*{N}{EXP} -> Repeat EXP N times
+	  (skip-chars-forward "^{" end)
+	  (setq cols (* (string-to-int
+			 (buffer-substring
+			  (1+ (point))
+			  (progn (forward-list 1) (1- (point)))))
+			(YaTeX-tabular-parse-format-count-cols
+			 (progn (skip-chars-forward "^{" end) (1+ (point)))
+			 (progn (forward-list 1) (1- (point)))))))
 	 (t (forward-char 1))		;unknown char
 	 ))
-      (list cols (1+ eoform))))
-)
+    cols))
+
+(defun YaTeX-tabular-parse-format (&optional type)
+  "Parse `tabular' format.
+Return the list of (No.ofCols PointEndofFormat)"
+  (let ((p (point)) boform eoform (cols 0))
+    (save-excursion
+      (if (null (YaTeX-beginning-of-environment t))
+	  (error "Beginning of tabular not found."))
+      (skip-chars-forward "^{")
+      (forward-list 1)
+      (cond
+       ((eq type 'tabular*)
+	(skip-chars-forward "^{")
+	(forward-list 1)))
+      (skip-chars-forward "^{" p)
+      (if (/= (following-char) ?\{) (error "Tabular format not found."))
+      (setq boform (1+ (point))
+	    eoform (progn (forward-list 1) (1- (point))))
+      (if (> eoform p) (error "Non-terminated tabular format."))
+      (goto-char boform)
+      (setq cols
+	    (cond
+	     ((eq type 'alignat)
+	      (max
+	       1
+	       (1-
+		(* 2
+		   (string-to-int
+		    (buffer-substring
+		     (point)
+		     (progn (up-list -1) (forward-list 1) (1- (point)))))))))
+	     (t
+	      (YaTeX-tabular-parse-format-count-cols (point) eoform))))
+      (list cols (1+ eoform)))))
+
 ;; Insert &
-(defun YaTeX-intelligent-newline-tabular (&optional tabular*)
+(defun YaTeX-intelligent-newline-tabular (&optional type)
   "Parse current tabular format and insert that many `&'s."
-  (let*((p (point)) (format (YaTeX-tabular-parse-format tabular*))
+  (let*((p (point)) (format (YaTeX-tabular-parse-format type))
 	(cols (car format)) (beg (car (cdr format)))
 	space hline)
     (cond
@@ -132,16 +165,43 @@
     (insert "\\\\")
     (if hline (insert " \\hline"))
     (goto-char p)
-    (YaTeX-indent-line)
-)
-)
+    (YaTeX-indent-line)))
 
 (defun YaTeX-intelligent-newline-tabular* ()
   "Parse current tabular* format and insert that many `&'s."
-  (YaTeX-intelligent-newline-tabular t)
-)
+  (YaTeX-intelligent-newline-tabular 'tabular*))
 
 (fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular)
+(fset 'YaTeX-intelligent-newline-supertabular 'YaTeX-intelligent-newline-tabular)
+
+(defun YaTeX-intelligent-newline-alignat ()
+  (YaTeX-intelligent-newline-tabular 'alignat))
+(fset 'YaTeX-intelligent-newline-alignat* 'YaTeX-intelligent-newline-alignat)
+
+(defun YaTeX-intelligent-newline-align ()
+  "Intelligent newline function for align.
+Count the number of & in the first align line and insert that many &s."
+  (let*((p (point)) (cols 0))
+    (save-excursion
+      (YaTeX-beginning-of-environment)
+      (catch 'done
+	(while (YaTeX-re-search-active-forward
+		"\\(&\\)\\|\\(\\\\\\\\\\)" YaTeX-comment-prefix p t)
+	  (if (match-beginning 1) (setq cols (1+ cols)) (throw 'done t)))))
+    (save-excursion
+      (if (= cols 0)
+	  (insert "&")
+	(while (>= (setq cols (1- cols)) 0)
+	  (insert "& "))))
+    (YaTeX-indent-line)))
+
+(mapcar
+ '(lambda (s)
+    (fset (intern (concat  "YaTeX-intelligent-newline-"
+			   (symbol-name s)))
+	  'YaTeX-intelligent-newline-align))
+ '(align* flalign  flalign* matrix pmatrix bmatrix Bmatrix vmatrix Vmatrix
+   cases))
 
 ;;;
 ;; Functions for tabbing environment
@@ -214,8 +274,7 @@
     (newline)
     (undo-boundary)
     (if (and env func (fboundp func))
-	(funcall func)))
-)
+	(funcall func))))
 
 ;;;
 ;; Environment-specific line indenting functions
--- a/yatexhks.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexhks.el	Sun Dec 24 06:16:52 2006 +0000
@@ -41,6 +41,13 @@
   '(lambda () (interactive) (YaTeX-make-section nil nil nil "setlength")))
 (define-key YaTeX-user-extensional-map "b"
   '(lambda () (interactive) (YaTeX-make-fontsize nil "bf")))
+(define-key YaTeX-user-extensional-map "I" 'YaTeX-browse-info)
+
+(defun YaTeX-browse-info ()
+  "Browse YaTeX's info"
+  (interactive)
+  (require 'info)
+  (Info-goto-node (if YaTeX-japan "(yatexj)Top" "(yatexe)Top")))
 
 
 ;
--- a/yatexhlp.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexhlp.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX helper with LaTeX commands and macros.
 ;;; yatexhlp.el
-;;; (c)1994,1998 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Fri Jun 27 12:09:58 2003 on firestorm
+;;; (c)1994,1998,2004 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Tue Oct 19 01:13:21 2004 on firestorm
 ;;; $Id$
 
 (let ((help-file (concat "YATEXHLP."
@@ -11,6 +11,8 @@
       (help-dir
        (cond
 	((and (boundp 'site-directory) site-directory) site-directory)
+	((string-match "\\.app/" doc-directory)	;For Emacs.app(Darwin)
+	 (expand-file-name "../site-lisp" doc-directory))
 	(YaTeX-emacs-19 (expand-file-name "../../site-lisp" doc-directory))
 	(t exec-directory))))
   (defvar YaTeX-help-file
@@ -38,6 +40,29 @@
 	(t "[[ Description ]]"))
   "Section header of description.")
 
+(defvar YaTeX-help-mode-map nil "Keymap used in YaTeX-help buffer")
+(if YaTeX-help-mode-map nil
+  (setq YaTeX-help-mode-map (make-sparse-keymap))
+  (let ((map YaTeX-help-mode-map))
+    (suppress-keymap map)
+    (define-key map "j" '(lambda () (interactive) (scroll-up 1)))
+    (define-key map "k" '(lambda () (interactive) (scroll-up -1)))
+    (define-key map "n" 'next-line)
+    (define-key map "p" 'previous-line)
+    (define-key map " " 'scroll-up)
+    (define-key map "\C-?" 'scroll-down)
+    (define-key map "o" 'other-window)
+    (define-key map "h" 'describe-bindings)
+    (define-key map "q" 'YaTeX-help-quit)
+    (define-key map "<" 'beginning-of-buffer)
+    (define-key map ">" 'end-of-buffer)))
+
+(defun YaTeX-help-quit ()
+  "Close help and return to privious buffer"
+  (interactive)
+  (bury-buffer (current-buffer))
+  (set-window-configuration YaTeX-help-saved-config))
+
 (defvar YaTeX-help-reference-regexp "<refer\\s +\\([^>]+\\)>"
   "Regexp of reference format of YaTeX-help file.")
 (defvar YaTeX-help-buffer "** YaTeX HELP **" "Help buffer name for yatexhlp")
@@ -62,10 +87,11 @@
 		    (or (assoc entry entries)
 			(setq entries (cons (list entry) entries)))))))))
        (list YaTeX-help-file YaTeX-help-file-private)))
-    entries)
-)
+    entries))
 
-(defvar YaTeX-help-entries (YaTeX-help-entries))
+(defvar YaTeX-help-entries nil
+  "Helo entries alist.")
+(setq YaTeX-help-entries (YaTeX-help-entries))
 
 (defun YaTeX-help-resolve-reference (buffer1 buffer2 &optional done-list)
   "Replace reference format in buffer1 with refered contents in buffer2."
@@ -100,9 +126,7 @@
 		  (insert-buffer-substring buffer2 beg end))))
 	  (switch-to-buffer buffer1)))
       (if beg (YaTeX-help-resolve-reference
-	       buffer1 buffer2 (append done-list ref-list))))
-    )
-)
+	       buffer1 buffer2 (append done-list ref-list))))))
 
 (defun YaTeX-refer-help (command help-file &optional append)
   "Refer the COMMAND's help into HELP-FILE.
@@ -137,6 +161,7 @@
       (YaTeX-showup-buffer
        hbuf (function (lambda (x) (nth 3 (window-edges x)))) t)
       (set-buffer hbuf)
+      (setq buffer-read-only nil)
       (if append (goto-char (point-max)) (erase-buffer))
       (insert YaTeX-help-synopsis "\n")
       (insert-buffer-substring hfbuf sb se)
@@ -144,9 +169,18 @@
       (insert-buffer-substring hfbuf db de)
       (YaTeX-help-resolve-reference hbuf hfbuf (list (list command)))
       (goto-char (point-min))
+      (setq buffer-read-only t)
+      (set-buffer-modified-p nil)
+      (YaTeX-help-mode)
       (select-window curwin)
-      t))
-)
+      t)))
+
+(defun YaTeX-help-mode ()
+  (interactive)
+  (use-local-map YaTeX-help-mode-map)
+  (setq major-mode 'yatex-help-mode
+	mode-name "YaTeX-HELP"))
+
 (defun YaTeX-help-newline (&optional arg)
   (interactive "P")
   (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp))
@@ -158,8 +192,8 @@
 	   YaTeX-help-command-current YaTeX-help-file-current))
 	(set-window-configuration YaTeX-help-saved-config)
 	(bury-buffer cbuf))
-    (newline arg))
-)
+    (newline arg)))
+
 (defun YaTeX-help-add-entry (command help-file)
   (let ((hfbuf (find-file-noselect help-file))
 	(dbuf (current-buffer)) beg end)
@@ -185,8 +219,8 @@
     (let ((make-backup-files t))
       (basic-save-buffer))
     (bury-buffer hfbuf)
-    (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries)))
-)
+    (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries))))
+
 (defun YaTeX-help-prepare-entry (command help-file)
   "Read help description on COMMAND and add it to HELP-FILE."
   (let ((buf (get-buffer-create "**Description**"))
@@ -207,16 +241,15 @@
     (use-local-map YaTeX-help-entry-map)
     (message
      (cond (YaTeX-japan "入力を終えたら . のみ入力してRET")
-	   (t "Type only `.' and RET to exit."))))
-)
+	   (t "Type only `.' and RET to exit.")))))
+
 (defun YaTeX-enrich-help (command)
   "Add the COMMAND's help to help file."
   (if (y-or-n-p (format "No help on `%s'. Create help?" command))
       (YaTeX-help-prepare-entry
        command
        (if (y-or-n-p "Add help to global documentation?")
-	   YaTeX-help-file YaTeX-help-file-private)))
-)
+	   YaTeX-help-file YaTeX-help-file-private))))
 
 (defun YaTeX-help-sort (&optional help-file)
   "Sort help file HELP-FILE.
@@ -225,8 +258,7 @@
   (interactive)
   (if help-file (set-buffer (find-file-noselect help-file)))
   (sort-regexp-fields
-   nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max))
-)
+   nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max)))
 
 (defun YaTeX-apropos-file (keyword help-file &optional append)
   (let ((hb (find-file-noselect help-file))
@@ -238,6 +270,7 @@
      ab (function (lambda (x) (nth 3 (window-edges x)))))
     (select-window (get-buffer-window ab))
     (set-buffer ab)			;assertion
+    (setq buffer-read-only nil)
     (or append (erase-buffer))
     (set-buffer hb)
     (goto-char (point-min))
@@ -250,22 +283,23 @@
       (insert-char ?- (1- (window-width)))
       (insert (format "\n<<%s>>\n" command))
       (YaTeX-refer-help command help-file t) ;append mode
+      (setq buffer-read-only nil)
       (set-buffer hb)
       (goto-char pt)
       (if (re-search-forward head nil 1)
 	  (goto-char (1- (match-beginning 0)))))
+    (setq buffer-read-only t)
     (select-window sw)
-    pt)
-)
+    pt))
 
 ;;;###autoload
 (defun YaTeX-apropos (key)
   (interactive "sLaTeX apropos (regexp): ")
   (if (string= "" key) (error "Nothing to show"))
+  (setq YaTeX-help-saved-config (current-window-configuration))
   (or (YaTeX-apropos-file key YaTeX-help-file)
       (YaTeX-apropos-file key YaTeX-help-file-private t)
-      (message "No matches found."))
-)
+      (message "No matches found.")))
 
 ;;;###autoload
 (defun YaTeX-help ()
@@ -301,7 +335,7 @@
 	     "Describe (La)TeX command: "
 	     YaTeX-help-entries nil nil command))
       );end excursion
+    (setq YaTeX-help-saved-config (current-window-configuration))
     (or (YaTeX-refer-help command YaTeX-help-file)
 	(YaTeX-refer-help command YaTeX-help-file-private)
-	(YaTeX-enrich-help command)))
-)
+	(YaTeX-enrich-help command))))
--- a/yatexlib.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexlib.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX and yahtml common libraries, general functions and definitions
 ;;; yatexlib.el
-;;; (c)1994-2002 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Tue Aug 19 22:20:40 2003 on firestorm
+;;; (c)1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:12:20 2006 on firestorm
 ;;; $Id$
 
 ;; General variables
@@ -32,6 +32,10 @@
 ;; autoload from yahtml.el
 (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t)
 
+(defvar latex-message-kanji-code 2
+  "*Kanji coding system latex command types out.
+1 = Shift JIS, 2 = JIS, 3 = EUC. 4 = UTF-8")
+
 (defvar YaTeX-kanji-code-alist
   (cond
    ((boundp '*junet*)
@@ -43,7 +47,7 @@
 	    (YaTeX-macos (if (boundp '*sjis-mac*) *sjis-mac* *sjis*mac))
 	    (t *sjis*)))
 	  '(2 . *junet*) '(3 . *euc-japan*)))
-   (YaTeX-emacs-20
+   ((and YaTeX-emacs-20 (featurep 'mule))
     ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
     (list '(0 . no-conversion)
 	  (cons
@@ -52,7 +56,8 @@
 		   ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
 		   (t 'sjis)))
 	  '(2 . iso-2022-jp-unix)
-	  '(3 . euc-jp-unix))))
+	  '(3 . euc-jp-unix)
+	  '(4 . utf-8))))
   "Kanji-code expression translation table.")
 (defvar YaTeX-inhibit-prefix-letter nil
   "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.")
@@ -79,6 +84,16 @@
 \it, \bf 内部での日本語が□になってしまう場合はこれをnilにして下さい。")
 
 ;----------- work variables ----------------------------------------
+(defvar YaTeX-minibuffer-completion-map nil
+  "Minibuffer completion key map that allows comma completion.")
+(if YaTeX-minibuffer-completion-map nil
+  (setq YaTeX-minibuffer-completion-map
+	(copy-keymap minibuffer-local-completion-map))
+  (define-key YaTeX-minibuffer-completion-map " "
+    'YaTeX-minibuffer-complete)
+  (define-key YaTeX-minibuffer-completion-map "\t"
+    'YaTeX-minibuffer-complete))
+
 (defvar YaTeX-typesetting-mode-map nil
   "Keymap used in YaTeX typesetting buffer")
 
@@ -127,6 +142,7 @@
 ;;;###autoload
 (defun YaTeX-read-user-completion-table (&optional forcetoread)
   "Append user completion table of LaTeX macros"
+  (interactive)
   (let*((user-table (expand-file-name YaTeX-user-completion-table))
 	(local-table (expand-file-name (file-name-nondirectory user-table)))
 	var localvar localbuf (curbuf (current-buffer)) sexp)
@@ -140,7 +156,7 @@
       (set-buffer (setq localbuf (find-file-noselect local-table)))
       (widen)
       (goto-char (point-min))
-      (while (re-search-forward "(setq \\([^ ]+\\)" nil t)
+      (while (re-search-forward "(setq \\([^ \t\n]+\\)" nil t)
 	(setq var (intern (buffer-substring
 			   (match-beginning 1) (match-end 1)))
 	      localvar (YaTeX-local-table-symbol var))
@@ -340,6 +356,13 @@
   (YaTeX-search-active-forward
    regexp cmntrx bound err cnt 're-search-backward))
 
+(defun YaTeX-relative-path-p (path)
+  "Return non-nil if PATH is not absolute one."
+  (let ((md (match-data)))
+    (unwind-protect
+	(not (string-match "^\\(/\\|[a-z]:\\|\\\\\\).*/" file))
+      (store-match-data md))))
+
 ;;;###autoload
 (defun YaTeX-switch-to-buffer (file &optional setbuf)
   "Switch to buffer if buffer exists, find file if not.
@@ -347,7 +370,7 @@
   (interactive "Fswitch to file: ")
   (if (bufferp file)
       (setq file (buffer-file-name file))
-    (and (string-match "^[^/].*/" file)
+    (and (YaTeX-relative-path-p file)
 	 (eq major-mode 'yatex-mode)
 	 YaTeX-search-file-from-top-directory
 	 (save-excursion
@@ -373,7 +396,7 @@
   (interactive "Fswitch to file: ")
   (and (eq major-mode 'yatex-mode)
        (stringp file)
-       (string-match "^[^/].*/" file)
+       (YaTeX-relative-path-p file)
        YaTeX-search-file-from-top-directory
        (save-excursion
 	 (YaTeX-visit-main t)
@@ -412,7 +435,7 @@
 (defun YaTeX-replace-format (string format repl)
   "In STRING, replace first appearance of FORMAT to REPL as if
 function `format' does.  FORMAT does not contain `%'"
-  (let ((ans string))
+  (let ((ans string) (case-fold-search nil))
     (while (not (string=
 		 ans (setq string (YaTeX-replace-format-sub ans format repl))))
       (setq ans string))
@@ -569,7 +592,7 @@
 (defun YaTeX-match-string (n &optional m)
   "Return (buffer-substring (match-beginning n) (match-beginning m))."
   (if (match-beginning n)
-      (buffer-substring (match-beginning n)
+      (YaTeX-buffer-substring (match-beginning n)
 			(match-end (or m n)))))
 
 ;;;###autoload
@@ -979,7 +1002,7 @@
 	  (goto-char (get 'YaTeX-inner-environment 'point))
 	  (and end (YaTeX-goto-corresponding-environment))
 	  (if (interactive-p) (push-mark op))
-	  t))))
+	  (point)))))
 
 (defun YaTeX-end-of-environment (&optional limit-search-bound)
   "Goto the end of the current environment.
@@ -993,8 +1016,10 @@
   (interactive)
   (let ((curp (point)))
     (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin
-	(forward-line 1)
-      (beginning-of-line))
+	(progn (goto-char (match-end 0)))
+      (if (= (char-after (point)) ?\\) nil	;if on \\end
+	(skip-chars-backward "^\n\\\\")
+	(or (bolp) (forward-char -1))))
     (if (not (YaTeX-end-of-environment))   ;arg1 turns to match-beginning 1
 	(progn
 	  (goto-char curp)
@@ -1033,6 +1058,17 @@
     (insert (YaTeX-replace-format-args YaTeX-struct-end env)))
    (t nil)))
 
+(defun YaTeX-string-width (str)
+  "Return the display width of string."
+  (if (fboundp 'string-width)
+      (string-width str)
+    (length str)))
+(defun YaTeX-truncate-string-width (str width)
+  (cond
+   ((fboundp 'truncate-string-to-width) (truncate-string-to-width str width))
+   ((fboundp 'truncate-string) (truncate-string str width))
+   (t (substring str 0 width))))
+
 ;;; Function for menu support
 (defun YaTeX-define-menu (keymap bindlist)
   "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST.
@@ -1093,9 +1129,17 @@
   (if (eq (selected-window) (minibuffer-window))
       (if (fboundp 'delete-field) (delete-field) (erase-buffer))))
 
+(fset 'YaTeX-buffer-substring
+      (if (fboundp 'buffer-substring-no-properties)
+	  'buffer-substring-no-properties
+	'buffer-substring))
+
 ;;;
 ;; hilit19 vs. font-lock
 ;;;
+(defvar YaTeX-19-functions-font-lock-direct
+  '(YaTeX-19-re-search-in-env))
+
 (defun YaTeX-convert-pattern-hilit2fontlock (h19pa)
   "Convert hilit19's H19PA patterns alist to font-lock's one.
 This function is a makeshift for YaTeX and yahtml."
@@ -1113,6 +1157,7 @@
 	   (crossref . YaTeX-font-lock-crossref-face)
 	   (include . YaTeX-font-lock-include-face)
 	   (formula . YaTeX-font-lock-formula-face)
+	   (delimiter . YaTeX-font-lock-delimiter-face)
 	   (string . ignore) (comment . ignore)
 	   )))
     (while (setq i (car palist))
@@ -1138,33 +1183,45 @@
 		  0 (list 'quote newface) nil)) ;;'keep))
 	       flpa)))
        ((and (symbolp (car i)) (fboundp (car i)))
-	(setq flpa
-	      (cons
-	       (list (car (cdr i))	;regexp
-		     (list
-		      (list
-		       'lambda (list 'dummy)
-		       '(goto-char (match-beginning 0))
-		       '(remove-text-properties
-			 (point) (min (point-max) (1+ (point)))
-			 '(face nil font-lock-multiline nil))
+	(if (memq (car i) YaTeX-19-functions-font-lock-direct)
+	    ;; Put direct function call for it.
+	    ;; When calling this function, fontify entire matched string.
+	    (setq flpa
+		  (cons
+		   (list
+		    (list 'lambda (list 'dummy) ;dummy should be boundary
+			  (list (car i) (list 'quote (car (cdr i)))))
+		    (list 0 newface))
+		   flpa))
+	  (setq flpa
+		(cons
+		 (list (car (cdr i))	;regexp
 		       (list
-			'let (list '(e (match-end 0))
-				   (list 'm (list (car i) (car (cdr i)))))
 			(list
-			 'if 'm
+			 'lambda (list 'dummy)
+			 '(goto-char (match-beginning 0))
+			 (if (eq (nth 3 i) 'overwrite)
+			     nil
+			   '(remove-text-properties
+			     (point) (min (point-max) (1+ (point)))
+			     '(face nil font-lock-multiline nil)))
 			 (list
-			  'YaTeX-font-lock-fillin
-			  (list 'car 'm)
-			  (list 'cdr 'm)
-			  (list 'quote 'face)
-			  (list 'quote 'font-lock)
-			  (list 'quote newface))
-			 '(goto-char e)
-			 ))
-		       nil)		;retun nil to cheat font-lock
-		      nil nil))		;pre-match, post-match both nil
-	       flpa))))
+			  'let (list '(e (match-end 0))
+				     (list 'm (list (car i) (car (cdr i)))))
+			  (list
+			   'if 'm
+			   (list
+			    'YaTeX-font-lock-fillin
+			    (list 'car 'm)
+			    (list 'cdr 'm)
+			    (list 'quote 'face)
+			    (list 'quote 'font-lock)
+			    (list 'quote newface))
+			   '(goto-char e)
+			   ))
+			 nil)		;retun nil to cheat font-lock
+			nil nil))	;pre-match, post-match both nil
+		 flpa)))))
       (setq palist (cdr palist)));while
     (if (featurep 'xemacsp)
 	(nreverse flpa)
@@ -1214,11 +1271,46 @@
     :group 'font-lock-faces)
   (defvar YaTeX-font-lock-formula-face 'YaTeX-font-lock-formula-face)
 
+  (defface YaTeX-font-lock-delimiter-face
+    '((((class static-color)) (:bold t))
+      (((type tty)) (:bold t))
+      (((class color) (background dark))
+       (:foreground "saddlebrown" :background "ivory" :bold t))
+      (((class color) (background light)) (:foreground "red"))
+      (t (:bold t :underline t)))
+    "Font Lock mode face used to highlight delimiters."
+    :group 'font-lock-faces)
+  (defvar YaTeX-font-lock-delimiter-face 'YaTeX-font-lock-delimiter-face)
+
+  (defface YaTeX-font-lock-math-sub-face
+    '((((class static-color)) (:bold t))
+      (((type tty)) (:bold t))
+      (((class color) (background dark))
+       (:foreground "khaki" :bold t :underline t))
+      (((class color) (background light))
+       (:foreground "Goldenrod" :underline t))
+      (t (:bold t :underline t)))
+    "Font Lock mode face used to highlight subscripts in formula."
+    :group 'font-lock-faces)
+  (defvar YaTeX-font-lock-math-sub-face 'YaTeX-font-lock-math-sub-face)
+
+  (defface YaTeX-font-lock-math-sup-face
+    '((((class static-color)) (:bold t))
+      (((type tty)) (:bold t))
+      (((class color) (background dark))
+       (:bold nil :foreground "ivory" :background "lightyellow4"))
+      (((class color) (background light))
+       (:underline t :foreground "gold"))
+      (t (:bold t :underline t)))
+    "Font Lock mode face used to highlight superscripts in formula."
+    :group 'font-lock-faces)
+  (defvar YaTeX-font-lock-math-sup-face 'YaTeX-font-lock-math-sup-face)
+
   (defface YaTeX-font-lock-crossref-face
     '((((class color) (background dark)) (:foreground "lightgoldenrod"))
       (((class color) (background light)) (:foreground "DarkGoldenrod"))
       (t (:bold t :underline t)))
-    "Font Lock mode face used to highlight cress references."
+    "Font Lock mode face used to highlight cross references."
     :group 'font-lock-faces)
   (defvar YaTeX-font-lock-crossref-face 'YaTeX-font-lock-crossref-face)
 
@@ -1300,6 +1392,17 @@
       (select-window sw)))
   ))
 
+(defun YaTeX-assoc-regexp (elt alist)
+  "Like assoc, return a list of whose car match with ELT.  Search from ALIST.
+Note that each car of cons-cell is regexp.  ELT is a plain text to be
+compared by regexp."
+  (let (x)
+    (catch 'found
+      (while alist
+	(setq x (car (car alist)))
+	(if (string-match x elt)
+	    (throw 'found (car alist)))
+	(setq alist (cdr alist))))))
 
 ;;;
 ;; Functions for the Installation time
@@ -1315,10 +1418,25 @@
 	(mapcar 'byte-compile-file command-line-args-left)
 	(kill-emacs))))
 
+(defun tfb-and-exit ()
+  "Texinfo-format-buffer and kill-emacs."
+  (if command-line-args-left
+      (let ((load-path (cons ".." load-path)))
+	(and (fboundp 'set-language-environment)
+	     (featurep 'mule)
+	     (set-language-environment "Japanese"))
+	(mapcar (function
+		 (lambda (arg)
+		   (find-file arg)
+		   (texinfo-format-buffer)
+		   (basic-save-buffer)))
+		command-line-args-left)
+	(kill-emacs))))
+
 (provide 'yatexlib)
 ; Local variables:
 ; fill-prefix: ";;; "
 ; paragraph-start: "^$\\|\\|;;;$"
 ; paragraph-separate: "^$\\|\\|;;;$"
-; buffer-file-coding-system: sjis
+; coding: sjis
 ; End:
--- a/yatexmth.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexmth.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX math-mode-specific functions.
 ;;; yatexmth.el
-;;; (c)1993-2003 by HIROSE Yuuji [yuuji@yatex.org]
-;;; Last modified Sun Mar 30 19:56:00 2003 on firestorm
+;;; (c)1993-2006 by HIROSE Yuuji [yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:13:15 2006 on firestorm
 ;;; $Id$
 
 ;;; [Customization guide]
@@ -107,6 +107,11 @@
 (YaTeX-setq-math-sym YaTeX-image-neg		"イ"		"¬")
 (YaTeX-setq-math-sym YaTeX-image-flat		"b"		"♭")
 (YaTeX-setq-math-sym YaTeX-image-sqrt		""		"√")
+(defvar YaTeX-image-nearrow '("__\n /|\n/" "  _\n  /|\n/" ))
+(defvar YaTeX-image-nwarrow '(" __\n|\\\n  \\" " _\n|\\n   \"))
+(defvar YaTeX-image-searrow '("\\\n \\|\n--`" "\\n  \|\n   ̄"))
+(defvar YaTeX-image-swarrow '("  /\n|/\n'~~" "   /\n|/\n  ̄"))
+
 
 (defvar
  YaTeX-math-sign-alist-default
@@ -202,6 +207,7 @@
    ("-<"	"prec"		("-<"		"く"))
    ("-<="	"preceq"	("-<\n-"	"く\n="))
    ("<<"	"ll"		("<<"		"《"))
+   (">>"	"gg"		(">>"		"》"))
    ;	:
    ;;arrows
    ("<-"	"leftarrow"	("<-"		"←"))
@@ -224,6 +230,18 @@
    ("\C-n"	"downarrow"	("|\nv" "↓"))
    ("v|"	"downarrow"	("|\nv" "↓"))
    ("v||"	"Downarrow"	"||\n\\/")
+   ("\C-p\C-f"	"nearrow"	YaTeX-image-nearrow)
+   ("\C-f\C-p"	"nearrow"	YaTeX-image-nearrow)
+   ("ne"	"nearrow"	YaTeX-image-nearrow)
+   ("\C-p\C-b"	"nwarrow"	YaTeX-image-nwarrow)
+   ("\C-b\C-p"	"nwarrow"	YaTeX-image-nwarrow)
+   ("nw"	"nwarrow"	YaTeX-image-nwarrow)
+   ("\C-n\C-f"	"searrow"	YaTeX-image-searrow)
+   ("\C-f\C-n"	"searrow"	YaTeX-image-searrow)
+   ("se"	"searrow"	YaTeX-image-searrow)
+   ("\C-n\C-b"	"swarrow"       YaTeX-image-swarrow)
+   ("\C-b\C-n"	"swarrow"	YaTeX-image-swarrow)
+   ("sw"	"swarrow"	YaTeX-image-swarrow)
    ("|->"	"mapsto"	("|->"		"|→"))
    ("<-)"	"hookleftarrow"	("   ,\n<--+"	"   ヽ\n<--/"))
    ("(->"	"hookrightarrow" ("`\n+-->"	"/\n\-->"))
@@ -259,6 +277,8 @@
    ("O+"	"bigoplus"	"/~~~\\\n| + |\n\\___/")
    ("Ox"	"bigotimes"	"/~~~\\\n| X |\n\\___/")
    ;;other marks
+   ("angle"	"angle"		("/\n~" "∠"))
+   ("/_"	"angle"		("/\n~" "∠"))
    ("Z"		"aleph"		"|\\|")
    ("|\\|"	"aleph"		"|\\|")
    ("h-"	"hbar"		"_\nh")
@@ -282,6 +302,8 @@
    ("partial"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
    ("round"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
    ("[]"	"Box"		"[]")
+   ("no"	"notag"		"\\notag")
+   (":"		"colon"		":")
    ("Diamond"	"Diamond"	"/\\\n\\/")
    ("3"		"triangle"	"/\\\n~~")
    ("C"		"clubsuit"	" o\no+o\n |")
@@ -380,8 +402,8 @@
 (defvar YaTeX-math-display-width
   (* 8 (1+ (/ YaTeX-math-sign-width 8))))
 (defvar YaTeX-math-menu-map nil
-  "Keymap used in YaTeX mathematical sign menu mode."
-)
+  "Keymap used in YaTeX mathematical sign menu mode.")
+
 (if YaTeX-math-menu-map nil
   (setq YaTeX-math-menu-map (make-sparse-keymap))
   (define-key YaTeX-math-menu-map "n"	'next-line)
@@ -400,8 +422,7 @@
   (define-key YaTeX-math-menu-map "q"	'abort-recursive-edit))
 
 (defvar YaTeX-math-exit-key "\e"
-  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode."
-)
+  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.")
 
 (defmacro YaTeX-math-japanese-sign (list)
   (list 'nth 1 list))
@@ -438,8 +459,7 @@
 		   " $'")))
       (setq YaTeX-math-mode nil)
       (message "Exit from math mode."))
-    (set-buffer-modified-p (buffer-modified-p)))
-)
+    (set-buffer-modified-p (buffer-modified-p))))
 
 (defun YaTeX-math-forward (arg)
   (interactive "p")
@@ -460,77 +480,81 @@
     (YaTeX-math-gets sign))
    ((symbolp sign)
     (YaTeX-math-gets (symbol-value sign)))
-   (t sign))
-)
+   (t sign)))
 
 (defun YaTeX-math-get-sign (list)
-  (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
-)
+  (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))))
+
 (defvar YaTeX-math-section-type-regexp
   "eqn\\\\\\sw+\\b"
   "*Regexp of section-type math-mode macro")
 
 (defun YaTeX-in-math-mode-p ()
-  "If current position is supposed to be in LaTeX-math-mode, return t."
-  (or (YaTeX-quick-in-environment-p
-       (append
-	'("math" "eqnarray" "equation" "eqnarray*" "displaymath");LaTeX
-	(if YaTeX-use-AMS-LaTeX
-	    ;; And math modes of AMS-LaTeX
-	    '("align" "align*" "split" "multline" "multline*" "gather"
-	      "gather*" "aligned*" "gathered" "gathered*" "alignat"
-	      "equation*" "cases" 
-	      "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"))))
-      (let*((p (point)) (nest 0) me0 r
-	    (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
-	    (boundary
-	     (save-excursion
-	       (if (looking-at delim)
-		   (goto-char (max (point-min) (1- (point)))))
-	       (re-search-backward delim nil 1)
-	       (point))))
-	(save-excursion
-	  (cond
-	   ((catch 'open
-	      (save-excursion
-		(while (and (>= nest 0)
-			    (re-search-backward
-			     (concat YaTeX-ec-regexp	;\
-				     "\\([()]\\|[][]\\)") boundary t))
-		  (setq me0 (match-end 0))
-		  (if (or (YaTeX-on-comment-p)
-			  (YaTeX-literal-p)) nil
-		    (if (or (= (char-after (1- me0)) ?\))
-			    (= (char-after (1- me0)) ?\]))
-			(setq nest (1+ nest))
-		      (if (= (preceding-char) ?\\ ) nil;;\\[5pt]
-			(setq nest (1- nest))))))
-		(if (< nest 0) (throw 'open t))))
-	    t)
-	   ((and (setq r (YaTeX-on-section-command-p
-			  YaTeX-math-section-type-regexp))
-		 (numberp r)
-		 (> r 0))
-	    t)
-	   (t (catch 'dollar
-		(while ;(search-backward "$" boundary t);little bit fast.
-		    (YaTeX-re-search-active-backward ;;;;;; Too slow???
-		     "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
-		  (cond
-		   ((equal (char-after (1- (point))) ?$) ; $$ equation $$
-		    (backward-char 1)
-		    (setq nest (1+ nest)))
-		   ((let ((YaTeX-verbatim-environments
-			   (append YaTeX-math-verbatim-environments
-				   YaTeX-verbatim-environments)))
-		      (YaTeX-literal-p))
-		    nil)
-		   ((and (equal (char-after (1- (point))) ?\\ )
-			 (not (equal (char-after (- (point) 3)) ?\\ )))
-		    nil)		;\$
-		   (t (setq nest (1+ nest)))))
-		(if (= (% nest 2) 1) (throw 'dollar t))))))))
-)
+  "If current position is supposed to be in LaTeX-math-mode, return t.
+This function refers a local variable `source-window' in YaTeX-make-section."
+  (save-excursion
+    (and (boundp 'source-window) source-window
+	 (set-buffer (window-buffer source-window)))
+    (or (YaTeX-quick-in-environment-p
+	 (append
+	  '("math" "eqnarray" "equation" "eqnarray*" "displaymath") ;LaTeX
+	  (if YaTeX-use-AMS-LaTeX
+	      ;; And math modes of AMS-LaTeX
+	      ;;'("align" "align*" "split" "multline" "multline*" "gather"
+	      ;;  "gather*" "aligned*" "gathered" "gathered*" "alignat"
+	      ;;  "equation*" "cases" "flalign" "flalign*"
+	      ;;  "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"
+	      YaTeX-math-begin-list
+	    )))
+	(let*((p (point)) (nest 0) me0 r
+	      (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
+	      (boundary
+	       (save-excursion
+		 (if (looking-at delim)
+		     (goto-char (max (point-min) (1- (point)))))
+		 (re-search-backward delim nil 1)
+		 (point))))
+	  (save-excursion
+	    (cond
+	     ((catch 'open
+		(save-excursion
+		  (while (and (>= nest 0)
+			      (re-search-backward
+			       (concat YaTeX-ec-regexp ;\
+				       "\\([()]\\|[][]\\)") boundary t))
+		    (setq me0 (match-end 0))
+		    (if (or (YaTeX-on-comment-p)
+			    (YaTeX-literal-p)) nil
+		      (if (or (= (char-after (1- me0)) ?\))
+			      (= (char-after (1- me0)) ?\]))
+			  (setq nest (1+ nest))
+			(if (= (preceding-char) ?\\ ) nil ;;\\[5pt]
+			  (setq nest (1- nest))))))
+		  (if (< nest 0) (throw 'open t))))
+	      t)
+	     ((and (setq r (YaTeX-on-section-command-p
+			    YaTeX-math-section-type-regexp))
+		   (numberp r)
+		   (> r 0))
+	      t)
+	     (t (catch 'dollar
+		  (while ;(search-backward "$" boundary t);little bit fast.
+		      (YaTeX-re-search-active-backward ;;;;;; Too slow???
+		       "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
+		    (cond
+		     ((equal (char-after (1- (point))) ?$) ; $$ equation $$
+		      (backward-char 1)
+		      (setq nest (1+ nest)))
+		     ((let ((YaTeX-verbatim-environments
+			     (append YaTeX-math-verbatim-environments
+				     YaTeX-verbatim-environments)))
+			(YaTeX-literal-p))
+		      nil)
+		     ((and (equal (char-after (1- (point))) ?\\ )
+			   (not (equal (char-after (- (point) 3)) ?\\ )))
+		      nil)		;\$
+		     (t (setq nest (1+ nest)))))
+		  (if (= (% nest 2) 1) (throw 'dollar t))))))))))
 
 (defun YaTeX-math-display-list (list cols)
   (goto-char (point-max))
@@ -589,8 +613,7 @@
 		   (prog2 (skip-chars-forward "^ \t\n") (point)))
 		nil))
 	(kill-buffer YaTeX-math-menu-buffer))
-      command))
-)
+      command)))
 
 ;
 (defun YaTeX-math-show-image (image &optional exit-char)
@@ -702,8 +725,8 @@
 
 	      (if match
 		  (progn (delete-region beg (point))
-			 (setq single-command (car (cdr match)))
-			 (insert YaTeX-ec single-command)
+			 (setq YaTeX-single-command (car (cdr match)))
+			 (insert YaTeX-ec YaTeX-single-command)
 			 (if (and YaTeX-math-need-image
 				  (setq sign (YaTeX-math-get-sign match)))
 			     (YaTeX-math-show-image (concat sign "\n")))
@@ -716,14 +739,14 @@
       (if (eq result t)
 	  (setq unread-command-char last-char)
 	(message "Done."))
-      (if (assoc single-command section-table)
-	  (YaTeX-make-section nil nil nil single-command)
+      (if (assoc YaTeX-single-command section-table)
+	  (YaTeX-make-section nil nil nil YaTeX-single-command)
 	(setq YaTeX-current-completion-type 'maketitle)
-	(YaTeX-make-singlecmd single-command)))
+	(YaTeX-make-singlecmd YaTeX-single-command)))
      ((eq result 'abort)
       (message "Abort."))
      ((eq result 'escape)
-      (call-interactively (global-key-binding this-key)))
+      (call-interactively (lookup-key global-map this-key)))
      ((eq result 'exit)
       (YaTeX-toggle-math-mode))
      ((eq result 'menu)
@@ -782,7 +805,7 @@
 				       (+ (point) 3 longest) t))
 	  (progn
 	    (setq move (- (point) point))
-	    (setq paren (match-string 0))
+	    (setq paren (YaTeX-match-string 0))
 	    (setq list YaTeX-ams-paren-modifier)
 	    ;; criterion for whether on [] () \{\} or not.
 	    (if (string-match YaTeX-left-paren paren)
@@ -830,8 +853,8 @@
 						 paren-regexp "\\)")))
 			(setq flag nil)))
 		  (setq list (cdr list)))))
-	    (if (<= move (length (match-string 0)))
-		(match-string 0)))))))
+	    (if (<= move (length (YaTeX-match-string 0)))
+		(YaTeX-match-string 0)))))))
 
 (defun YaTeX-goto-open-paren (&optional jumpto-co)
   "Jump to the exact position of open parenthesis.
@@ -872,8 +895,8 @@
   (interactive)
   (if (not (and YaTeX-use-AMS-LaTeX (YaTeX-on-parenthesis-p)))
       nil
-    (let* ((mod (match-string 1)) ;; modifier
-	   (paren (if mod (match-string 2) (match-string 0))) ;; paren
+    (let* ((mod (YaTeX-match-string 1)) ;; modifier
+	   (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren
 	   (mod-length (if (or (string= mod "\\left") (string= mod "\\right"))
 			   5            ;; 5 in case left or right
 			 (length mod))) ;; length of modifier
--- a/yatexpkg.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexpkg.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,10 +1,13 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX package manager
 ;;; yatexpkg.el
-;;; (c)2003 by HIROSE, Yuuji [yuuji@yatex.org]
-;;; Last modified Thu Aug 28 18:24:33 2003 on firestorm
+;;; (c)2003-2006 by HIROSE, Yuuji [yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:13:29 2006 on firestorm
 ;;; $Id$
 
+(defvar YaTeX-package-ams-envs
+  (mapcar 'car YaTeX-ams-env-table))
+
 (defvar YaTeX-package-alist-default
   '(("version"	(env "comment")		;by tsuchiya@pine.kuee.kyoto-u.ac.jp
      		(section "includeversion" "excludeversion"))
@@ -14,6 +17,7 @@
     ("url"	(section "url"))	;by fujieda@jaist.ac.jp
 
     ("fancybox"	(section "shadowbox" "doublebox" "ovalbox" "Ovalbox"))
+    ("slashbox"	(section "slashbox" "backslashbox"))
     ("pifont"	(section "ding"))
     ("longtable" (env "longtable"))
     ("ascmac"	(env "screen" "boxnote" "shadebox" "itembox")
@@ -21,10 +25,20 @@
      		(section "keytop") ("mask") ("maskbox"))
     ("bm"	(section "bm"))		;by aoyama@le.chiba-u.ac.jp
 
-    ("graphicx"	(section "includegraphics"))
     ("alltt"	(env "alltt"))
     ("misc"	(section "verbfile" "listing"))
-    ("eclbkbox"	(env "breakbox")))
+    ("eclbkbox"	(env "breakbox"))
+    ("supertabular" (env "supertabular"))
+    ("amsmath"	(env . YaTeX-package-ams-envs)
+     		(section "tag" "tag*"))
+    ("graphicx" (section "includegraphics"
+			 "rotatebox" "scalebox" "resizebox" "reflectbox")
+     		(option . YaTeX-package-graphics-driver-alist))
+    ("color"	(section "textcolor" "colorbox" "pagecolor" "color")
+     		(option . YaTeX-package-graphics-driver-alist))
+    ("ulem"	(section "uline" "uuline" "uwave")
+		(option ("normalem")))
+    ("multicol"	(env "multicols")))
   "Default package vs. macro list.
 Alists contains '(PACKAGENAME . MACROLIST)
 PACKAGENAME     Basename of package(String).
@@ -32,8 +46,21 @@
 TYPE	One of 'env, 'section or 'maketitle according to completion-type
 MACROS	List of macros
 
+If TYPE is 'option, its cdr is alist of completion candidates for that
+package.  Its cdr can be a symbol whose value is alist.
+
 An good example is the value of YaTeX-package-alist-default.")
 
+(defvar YaTeX-package-graphics-driver-alist
+  '(("dvips") ("xdvi") ("dvipdf") ("pdftex") ("dvipsone") ("dviwindo")
+    ("emtex") ("dviwin") ("oztex") ("textures") ("pctexps") ("pctexwin")
+    ("pctexhp") ("pctex32") ("truetex") ("tcidvi") ("vtex"))
+  "Drivers alist of graphics/color stylefile's supporting deveces.
+This list is taken from
+%% graphics.dtx Copyright (C) 1994      David Carlisle Sebastian Rahtz
+%%              Copyright (C) 1995 1996 1997 1998 David Carlisle
+as of 2004/1/19.  Thanks.")
+
 (defvar YaTeX-package-alist-private nil
   "*User defined package vs. macro list. See also YaTeX-package-alist-default")
 
@@ -42,23 +69,33 @@
 Optional second argument TYPE limits the macro type.
 TYPE is a symbol, one of 'env, 'section, 'maketitle."
   (let ((list (append YaTeX-package-alist-private YaTeX-package-alist-default))
-	element x pkg pkglist r)
+	element x val pkg pkglist r)
     (while list
       (setq element (car list)
 	    pkg (car element)
 	    element (cdr element))
       (if (setq r (catch 'found
 		    (while element
-		      (setq x (car element))
-		      (and (YaTeX-member macro (cdr x))
-			   (or (null type)
+		      (setq x (car element)
+			    val (cdr x))
+		      (if (symbolp val) (setq val (symbol-value val)))
+		      (and (or (null type)
 			       (eq type (car x)))
+			   (YaTeX-member macro val)
 			   (throw 'found (car x)))	;car x is type
 		      (setq element (cdr element)))))
 	  (setq pkglist (cons (cons pkg r) pkglist)))
       (setq list (cdr list)))
     pkglist))
 
+(defun YaTeX-package-option-lookup (pkg)
+  "Look up options for specified pkg and returne them in alist form.
+Just only accocing against the alist of YaTeX-package-alist-*"
+  (let ((l (cdr (assq 'option
+		      (assoc pkg (append YaTeX-package-alist-private
+					 YaTeX-package-alist-default))))))
+    (if (symbolp l) (symbol-value l) l)))
+
 (defvar YaTeX-package-resolved-list nil
   "List of macros whose package is confirmed to be loaded.")
 
@@ -68,7 +105,7 @@
   (let ((cb (current-buffer))
 	(wc (current-window-configuration))
 	(usepackage (concat YaTeX-ec "usepackage"))
-	(pkglist (YaTeX-package-lookup macro))
+	(pkglist (YaTeX-package-lookup macro type))
 	(usepkgrx (concat
 		   YaTeX-ec-regexp
 		   "\\(usepackage\\|include\\)\\b"))
@@ -76,7 +113,7 @@
 		     (set (make-local-variable 'YaTeX-package-resolved-list)
 			  (cons macro YaTeX-package-resolved-list))))
 	(begdoc (concat YaTeX-ec "begin{document}"))
-	pb pkg mb0)
+	pb pkg optlist (option "") mb0 uspkgargs)
     (if (or (YaTeX-member macro YaTeX-package-resolved-list)
 	    (null pkglist))
 	nil				;nothing to do
@@ -89,14 +126,25 @@
 		(goto-char (point-min))
 		(YaTeX-search-active-forward	;if search fails, goto eob
 		 begdoc YaTeX-comment-prefix nil 1)
-		(while (YaTeX-re-search-active-backward
-			usepkgrx YaTeX-comment-prefix nil t)
+		(while ;(YaTeX-re-search-active-backward
+			;usepkgrx YaTeX-comment-prefix nil t)
+		    ;;allow commented out \usepackages 2004/3/16
+		    (re-search-backward usepkgrx nil t)
 		  (setq mb0 (match-beginning 0))
 		  (skip-chars-forward "^{")
-		  (forward-char 1)
+		  (setq uspkgargs (YaTeX-buffer-substring
+				   (point)
+				   (progn
+				     ;;(forward-list 1) is more precise,
+				     ;; but higher risk.
+				     (skip-chars-forward "^}\n")(point))))
 		  (let ((pl pkglist))
 		    (while pl		;(car pl)'s car is package, cdr is type
-		      (if (looking-at (regexp-quote (car (car pl))))
+		      (if (string-match
+			   (concat "[{,]\\s *"
+				   (regexp-quote (car (car pl)))
+				   "\\>")
+			   uspkgargs)
 			  (throw 'found t))
 		      (setq pl (cdr pl)))
 		    (goto-char mb0))))
@@ -106,6 +154,7 @@
 	    (if (y-or-n-p
 		 (format "`%s' requires package. Put \\usepackage now?" macro))
 		(progn
+		  (require 'yatexadd)
 		  (setq pkg
 			(completing-read
 			 "Load which package?(TAB for list): "
@@ -113,7 +162,21 @@
 			 ;;initial input
 			 (if (= (length pkglist) 1)
 			     (let ((w (car (car pkglist))))
-			       (if YaTeX-emacs-19 (cons w 0) w)))))
+			       (if YaTeX-emacs-19 (cons w 0) w))))
+			optlist
+			(YaTeX-package-option-lookup pkg))
+		  (if optlist
+		      (let ((minibuffer-completion-table optlist)
+			    (delim ",") (w (car (car optlist))))
+			(setq option
+			      (read-from-minibuffer
+			       (format "Any option for {%s}?: " pkg)
+			       (if (= (length optlist) 1)
+				   (if YaTeX-emacs-19 (cons w 0) w))
+			       YaTeX-minibuffer-completion-map)
+			      option (if (string< "" option)
+					 (concat "[" option "]")
+				       ""))))
 		  (set-buffer pb)
 		  (goto-char (point-min))
 		  (if (YaTeX-re-search-active-forward
@@ -126,8 +189,8 @@
 		      (goto-char (match-beginning 0)))
 		  (insert
 		   usepackage
-		   (format "{%s}\t%% required for `\\%s' (yatex added)\n"
-			   pkg macro))
+		   (format "%s{%s}\t%% required for `\\%s' (yatex added)\n"
+			   option pkg macro))
 		  (funcall register))
 	      (message "Don't forget to put \\usepackage{%s} yourself later"
 		       (car (car pkglist)))) ;doing car car is negligence...
--- a/yatexprc.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexprc.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX process handler.
 ;;; yatexprc.el
-;;; (c)1993-2003 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Sun Nov  2 08:09:44 2003 on firestorm
+;;; (c)1993-2006 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:12:50 2006 on firestorm
 ;;; $Id$
 
 ;(require 'yatex)
@@ -37,6 +37,7 @@
 ;;    ((boundp 'NEMACS)
 ;;     (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist))))
   (cond
+   (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist)))
    (YaTeX-emacs-20
     (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist)))
    ((boundp 'MULE)
@@ -317,7 +318,11 @@
   (YaTeX-typeset
    (read-string-with-history
     "Call command: "
-    (concat base-cmd " " (YaTeX-get-preview-file-name))
+    (concat base-cmd " "
+	    (let ((me (file-name-nondirectory buffer-file-name)))
+	      (if (string-match "\\.tex" me)
+		  (substring me 0 (match-beginning 0))
+		me)))
     'YaTeX-call-command-history)
    buffer))
 
@@ -429,12 +434,13 @@
 		  (YaTeX-get-paper-type)))
      'YaTeX-preview-command-history)
     (read-string-with-history
-     "Preview file[.dvi]: "
+     "Preview file: "
      (if (get 'dvi2-command 'region)
 	 (substring YaTeX-texput-file
 		    0 (rindex YaTeX-texput-file ?.))
        (YaTeX-get-preview-file-name))
      'YaTeX-preview-file-history)))
+  (if YaTeX-dos (setq preview-file (expand-file-name preview-file)))
   (setq dvi2-command preview-command)	;`dvi2command' is buffer local
   (save-excursion
     (YaTeX-visit-main t)
@@ -511,7 +517,7 @@
 error or warning lines in reverse order."
   (interactive)
   (let ((cur-buf (buffer-name)) (cur-win (selected-window))
-	error-line typeset-win error-buffer error-win)
+	b0 errorp error-line typeset-win error-buffer error-win)
     (if (null (get-buffer YaTeX-typeset-buffer))
 	(error "There is no typesetting buffer."))
     (YaTeX-showup-buffer YaTeX-typeset-buffer nil t)
@@ -520,10 +526,10 @@
 	 (concat "\\(" latex-error-regexp "\\)\\|\\("
 		 latex-warning-regexp "\\)")
 	 nil t)
-	nil
+	(setq errorp (match-beginning 1))
       (select-window cur-win)
       (error "No more errors on %s" cur-buf))
-    (goto-char (match-beginning 0))
+    (goto-char (setq b0 (match-beginning 0)))
     (skip-chars-forward "^0-9" (match-end 0))
     (setq error-line
 	  (string-to-int
@@ -545,13 +551,13 @@
     (setq error-win (selected-window))
     (goto-line error-line)
     (message "LaTeX %s in `%s' on line: %d."
-	     (if (match-beginning 1) "error" "warning")
+	     (if errorp "error" "warning")
 	     error-buffer error-line)
     (select-window typeset-win)
     (skip-chars-backward "0-9")
     (recenter (/ (window-height) 2))
     (sit-for 1)
-    (goto-char (match-beginning 0))
+    (goto-char b0)
     (select-window error-win)))
 
 (defun YaTeX-jump-error-line ()
@@ -653,18 +659,27 @@
 	(delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$")
 	(widen))))
 
+(defvar YaTeX-dvi2-command-ext-alist
+ '(("[agx]dvi\\|dviout" . ".dvi")
+   ("ghostview\\|gv" . ".ps")
+   ("acroread\\|pdf\\|Preview\\|TeXShop" . ".pdf")))
+
 (defun YaTeX-get-preview-file-name ()
   "Get file name to preview by inquiring YaTeX-get-latex-command"
   (let* ((latex-cmd (YaTeX-get-latex-command t))
 	 (rin (rindex latex-cmd ? ))
 	 (fname (if (> rin -1) (substring latex-cmd (1+ rin)) ""))
+	 (r (YaTeX-assoc-regexp dvi2-command YaTeX-dvi2-command-ext-alist))
+	 (ext (if r (cdr r) ""))
 	 (period))
-    (if (string= fname "")
+    (concat
+     (if (string= fname "")
 	(setq fname (substring (file-name-nondirectory
 				(buffer-file-name))
 			       0 -4))
       (setq period (rindex fname ?.))
-      (setq fname (substring fname 0 (if (eq -1 period) nil period))))))
+      (setq fname (substring fname 0 (if (eq -1 period) nil period))))
+     ext)))
 
 (defun YaTeX-get-latex-command (&optional switch)
   "Specify the latex-command name and its argument.
@@ -680,21 +695,27 @@
 	\"jlatex main.tex\"
 
 will be given to the shell."
-  (let (magic command target)
+  (let (parent tparent magic)
     (setq parent
 	  (cond
-	   (YaTeX-parent-file YaTeX-parent-file)
+	   (YaTeX-parent-file
+	    (if YaTeX-dos (expand-file-name YaTeX-parent-file)
+	      YaTeX-parent-file))
 	   (t (save-excursion
 		(YaTeX-visit-main t)
 		(file-name-nondirectory (buffer-file-name)))))
-	  magic (YaTeX-get-builtin "!"))
-    (cond
-     (magic
-      (cond
-       (switch (if (string-match "\\s " magic) magic
-		 (concat magic " " parent)))
-       (t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
-     (t (concat tex-command " " (if switch parent))))))
+	  magic (YaTeX-get-builtin "!")
+	  tparent (file-name-nondirectory parent))
+    (YaTeX-replace-formats
+     (cond
+      (magic
+       (cond
+	(switch (if (string-match "\\s " magic) magic
+		  (concat magic " " parent)))
+	(t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
+      (t (concat tex-command " " (if switch parent))))
+     (list (cons "f" tparent)
+	   (cons "r" (substring tparent 0 (rindex tparent ?.)))))))
 
 (defvar YaTeX-lpr-command-history nil
   "Holds command line history of YaTeX-lpr.")
@@ -813,8 +834,9 @@
        ;;((and main-file (YaTeX-switch-to-buffer main-file setbuf)))
        ((and main-file
 	     (file-exists-p (setq main-file (concat "../" main-file)))
-	     (y-or-n-p (concat (expand-file-name main-file)
-			       " is main file?:")))
+	     (or b-in
+		 (y-or-n-p (concat (expand-file-name main-file)
+				   " is main file?:"))))
 	(setq YaTeX-parent-file main-file)
 	;(YaTeX-switch-to-buffer main-file setbuf)
 	(funcall ff main-file)
@@ -851,7 +873,7 @@
     (if (and (re-search-forward
 	      (concat "^" (regexp-quote (concat "%#" key))) nil t)
 	     (not (eolp)))
-	(buffer-substring
+	(YaTeX-buffer-substring
 	 (progn (skip-chars-forward " 	" (point-end-of-line))(point))
 	 (point-end-of-line))
       nil)))

yatex.org