[ホーム]-> [emacs]-> [活用法]-> [yatex]

野鳥 について

野鳥ロゴ

1. 野鳥とは

野鳥 (やてふ, YaTeX) とは、広瀬氏が作られた Emacs の上で動作する LaTeX の入力支援環境です。

Emacs から TeX, bibtex やプレビューワ等を起動したり、LaTeX の原稿を書く際の入力支援の機能を持ったTeX の統合環境です。 同様の機能を持つものとしては AUC-TeX がありますが、YaTeX は作者が日本人の方なので、ドキュメント等が日本語で書かれているという利点があります。 日本語で質問できるメーリングリストがあるのも非常に嬉しいです。

もっと詳しく知りたい方は、 野鳥 (やてふ, YaTeX) のページや YaTeX World (Yet Another LaTeX mode for Emacs) などが参考になるでしょう。

最近、作者の広瀬さんの書かれた Emacs Lisp の本も出版されました。 皆さん買いましょう。

2. インストール

本体は 野鳥 (やてふ, YaTeX) のページからダウンロードできます。 インストールの手順は日本語で書かれているので、簡単に導入できると思います。 (RedHat系 Linux 用の Emacs21 の SRPM:yatex のページも参照。)

3. 設定

詳しいことは Info に書かれていますが、ここでも少し説明してみます。 まずは、基本的な設定から。 tex-commanddvi2-command, dviprint-command-format などは各々の環境に合わせて変更して下さい。

;; YaTeX configuration option
(setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
;; LaTeX コマンド、プレビューワ、プリンタなどの設定
(setq tex-command "platex"
      dvi2-command (if (eq window-system 'x)
		       "xdvi -expert -p 300 -s 3 -geo 750x575+0+0"
		     "dviout") X では xdvi を、コンソールでは dviout を。
      dviprint-command-format "dvips %s | lpr"
      YaTeX-kanji-code 3 ; (1 JIS, 2 SJIS, 3 EUC)
      YaTeX-use-AMS-LaTeX t ; AMS-LaTeX を使う。
      section-name "documentclass"
      makeindex-command "mendex"
      )

以上が基本的な設定ですが、私は次のような設定も加えています。 まずはメッセージの漢字コード、補完の方法、フェイスの設定などです。 フェイスに関しては、一応少しは汎用的なフェイスを定義していますが、 単に色を変えるだけならもっと簡単にできます。

(setq YaTeX-latex-message-code 'euc-jp ; メッセージは euc で。
      YaTeX-no-begend-shortcut t ; begin-end では shortcut ではなく補完を利用。
      )

;; hilit19 は使わない。更にフェイスを追加して、色をカスタマイズ。
(setq YaTeX-use-hilit19 nil)
(setq YaTeX-use-font-lock nil)
(if window-system
    (progn
      (require 'font-latex)
      (add-hook 'yatex-mode-hook 'font-latex-setup)
      (add-hook 'yatex-mode-hook 'turn-on-font-lock 'append)))

(cond
 ((featurep 'font-lock)
  (defface font-latex-math-face
    '((((class grayscale) (background light)) 
       (:foreground "DimGray" :underline t))
      (((class grayscale) (background dark)) 
       (:foreground "LightGray" :underline t))
      (((class color) (background light)) (:foreground "SaddleBrown"))
      (((class color) (background dark))  (:foreground "burlywood"))
      (t (:underline t)))
    "Font Lock mode face used to highlight math in LaTeX."
    :group 'font-latex-highlighting-faces)
  
  (defface font-latex-label-face
    '((((class static-color)) (:foreground "yellow" :underline t))
      (((type tty)) (:foreground "yellow" :underline t))
      (((class color) (background dark)) (:foreground "pink"))
      (((class color) (background light)) (:foreground "ForestGreen"))
      (t (:bold t :underline t)))
    "Font Lock mode face used to highlight labels."
    :group 'font-lock-faces)))

(setq YaTeX-font-lock-formula-face 'font-latex-math-face
      YaTeX-font-lock-label-face 'font-latex-label-face)

次は SKK 対策です。LaTeX では \$ を多用するので、SKK を使っている時でもこれらのキーは通常の YaTeX の動作になるようにしています。

;; skk 対策
(add-hook 'skk-mode-hook
	  (lambda ()
	    (if (eq major-mode 'yatex-mode)
		(progn
		  (define-key skk-j-mode-map "\\" 'self-insert-command)
		  (define-key skk-j-mode-map "$" 'YaTeX-insert-dollar)
		  ))
	    ))

下は math-sign の追加です。

;; math-sign の追加
(setq
 YaTeX-math-sign-alist-private
 '(
   ("q"         "Q"          	"(Q)")
   ("z"         "Z"          	"ZZ")
   ("t"		"text"		"text")
   ("qu"        "quad"         	"__")
   ("qq"        "qquad"         "____")
   ("ls"        "varlimsup"     "___\nlim")
   ("li"        "varliminf"     "lim\n---")
   ("il"        "varinjlim"     "lim\n-->")
   ("pl"        "varprojlim"    "lim\n<--")
   ("st"        "text{ s.t. }" "s.t.")
   ("bigop"     "bigoplus"      "_\n(+)~")
   ("bigot"     "bigotimes"     "_\n(x)\n ~")
   ))

最後に outline-minor-mode に関するカスタマイズです。 LaTeX ファイルでの outline-minor-mode の見出しについての設定を行っています。

;; yatex outline-minor-mode 
(setq-default outline-level 'outline-level)
(add-hook
 'yatex-mode-hook
 (function
  (lambda ()
    (progn
      (modify-syntax-entry ?% "<" (syntax-table))
      (modify-syntax-entry 10 ">" (syntax-table))
      (make-variable-buffer-local 'outline-level)
      (setq outline-level 'latex-outline-level)
      (make-variable-buffer-local 'outline-regexp)
      (setq outline-regexp
	    (concat "[ \t]*\\\\\\(documentstyle\\|documentclass\\|chapter\\|"
		    "section\\|subsection\\|subsubsection\\|paragraph\\)"
		    "\\*?[ \t]*[[{]")
		    )))))

(defun latex-outline-level ()
  (save-excursion
    (looking-at outline-regexp)
    (let ((title (buffer-substring (match-beginning 1) (match-end 1))))
      (cond ((equal (substring title 0 4) "docu") 20)
	    ((equal (substring title 0 4) "para") 15)
	    ((equal (substring title 0 4) "chap") 0)
	    ((equal (substring title 0 4) "appe") 0)
	    (t (length title))))))

4. 使い方

上のように設定した場合、拡張子が tex のファイルを読み込んだ場合に自動的に YaTeX mode になります。もちろん直接 M-x yatex-mode としても YaTeX mode になります。

5. 個人的なパッチ(yatex 1.69 用)

yatex-fontsview.patch mathfntable.tex mathfntable.dvi
なお、上のパッチでは、

(setq yatex-fontsview-command "xdvi -expert -p 300 -s 3 -geo 780x680-60-0")
(setq yatex-fonts-dvifile "~/tex/document/mathfntable.dvi")

などとして、フォント表示用のファイルの位置やそれを表示するソフトウェアを指定できます。 フォント表示用のファイルは上のものを使うか、自分で適当に作ったものを御指定下さい。


[ホーム]-> [emacs]-> [活用法]-> [yatex]