YaTeX マニュアル

[1] YaTeXとは

Yet Another LaTeX mode for Emacs. を参照のこと。

RefTeX は YaTeX とは別のメジャーモードですが、一緒に使うことができます。 RefTeXについては RefTeX User Manual を参照のこと。

[2] 初期設定

以下は VineLinux 3.* での使用が前提。

RefTeX や AMS-LaTeX を使いたい場合は、 ~/.emacs.my.el に以下の記述を加えます。


; Setting for RefTeX
(add-hook 'yatex-mode-hook '(lambda () (reftex-mode t)))

; Setting for YaTeX
(setq YaTeX-use-AMS-LaTeX t)

source specials を使いたい場合は、 ~/.emacs.el のYaTeXに関する設定個所を下のように書き換えておきます。 (setq tex-command "platex -src-specials") のところがポイントです。


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; YaTeX 1.72
;;   [La]TeX 入力モード
;;   M-x yatex とするか、.tex で終わるファイルを読み込むと起動します
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

;; YaTeX-mode
(setq auto-mode-alist
      (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(setq dvi2-command "xdvi"
      tex-command "platex -src-specials"
      dviprint-command-format "dvips %s | lpr"
      YaTeX-kanji-code 3)

;; YaHtml-mode
(setq auto-mode-alist
      (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist))
(autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t)
(setq yahtml-www-browser "mozilla")

;; TeX source special のための設定
(if (load "xdvi-search" t) ; 必須
    (progn
      (custom-set-variables
       '(server-switch-hook (quote (raise-frame)))) ; 窓を上に
      (custom-set-faces)
      (add-hook 'yatex-mode-hook
                '(lambda ()
                   (define-key YaTeX-mode-map "\C-c\C-j" 'xdvi-jump-to-line)))
    ))

[3] source special

emacs から xdviの該当個所へのジャンプは C-c C-j で、 xdvi から emacs の該当個所へのジャンプは C-[MouseClick] で行います。

[4] \include

\include を使用する場合、include するファイルを main.tex とでも名づけておき、 include される個々のファイル sub.tex の冒頭と末尾に以下を付け加えておきます。

%#!platex -src-specials main.tex

(sub.tex の内容)

%%% Local Variables: ***
%%% mode:yatex ***
%%% TeX-master: "main.tex" ***
%%% End: ***

%%% Local Variables: *** 以下は reftex のための設定です(yatex とは直接、関係がない)。

main.tex は以下のようになります。

# main.tex

\documentclass{jsarticle}
\begin{document}

\include{sub}

\end{document}

\include{sub} にカーソルを当てて C-c g を押すと、 sub.tex にジャンプする仕組みになっています。

main.tex に戻るには sub.tex のバッファ上で C-c ^ とします。

[5] RefTeX について少し

RefTeX は YaTeX とは別のメジャーモードですが、一緒に使うと便利です。

C-c ( を押すと、ラベルを自動で割り振ってくれます。例:\label{foo}。

C-c ) で参照したい既存のラベル一覧を表示してくれるので、矢印キーとマウスで選択すれば、\ref{foo} が自動で入力されます。

[6] 補完入力一覧

各補完型について、キー操作と例を以下に示す。

begin型補完
C-c b
e.g. \begin{document}...\end{document}
e.g. \begin{equation}...\end{equation}
section型補完
C-c s
e.g. \section{...}
e.g. \tilde{...}
section型補完 (n 引数)
C-u n C-c s
e.g. \frac{...}{...}
large型補完
C-c l
e.g. {\large ...}
maketitle型補完
C-c m
e.g. \subset
e.g. \dots
e.g. \item
随時補完
C-c [SPC]
コマンド入力中に補完
end型補完
C-c e
\begin{...} に対応する \end{...} を補完
アクセント記号補完
C-c a
\^{...}
数式記号イメージ補完
;
C-u ;
次節参照
ギリシア文字補完
:
C-u :

[7] 数式記号イメージ補完

数式環境で

;
 または
C-u ;

と入力すると、数式記号イメージ補完モードに入ります。このとき、下表の「Key」をミニバッファに入力していけば、対応する 「LaTeX コマンド」がバッファに自動で入力されます。

なお、下の表で \C- は「コントロールキーを押しながら、それに続く文字を入力する」を意味します。

frequently used
KeyLaTeX Command
||\|
sum\sum
sigma\sum
integral\int
ointegral\oint
sqrt\sqrt
root\sqrt
A\forall
E\exists
!\neg
oo\infty
\\backslash
...\cdots
binary operators
KeyLaTeX Command
+-\pm
-+\mp
x\times
/\div
f\frac
*\ast
#\star
o\circ
o*\bullet
.\cdot
cap\cap
cup\cup
u+\uplus
|~|\sqcap
|_|\sqcup
v\vee
^\wedge
\\\setminus
)(\wr
<>\diamond
/\-\bigtriangleup
-\/\bigtriangledown
<|\triangleleft
|>\triangleright
<||\lhd
||>\rhd
<|-\unlhd
|>-\unrhd
o+\oplus
o-\ominus
ox\otimes
o/\oslash
o.\odot
O\bigcirc
t\dagger
tt\ddagger
II\amalg
relational operators
KeyLaTeX Command
<\leq
>\geq
-=\equiv
=-\equiv
---\equiv
(\subset
(-\subseteq
)\supset
)-\supseteq
[\sqsubset
[-\sqsubseteq
]\sqsupset
]-\sqsupseteq
{\in
}\ni
|-\vdash
-|\dashv
~\sim
~-\simeq
asymp\asymp
~~\approx
~=\cong
=/\neq
.=\doteq
o<\propto
|=\models
_|_\perp
|\mid
||\parallel
bowtie\bowtie
|><|\join
\_/\smile
/~\\frown
-<\prec
-<=\preceq
<<\ll
arrows
KeyLaTeX Command
<-\leftarrow
\C-b\leftarrow
<--\longleftarrow
<=\Leftarrow
<==\Longleftarrow
->\rightarrow
\C-f\rightarrow
-->\longrightarrow
=>\Rightarrow
==>\Longrightarrow
<->\leftrightarrow
<-->\longleftrightarrow
<=>\Leftrightarrow
<==>\Longleftrightarrow
^|\uparrow
\C-p\uparrow
^||\Uparrow
\C-n\downarrow
v|\downarrow
v||\Downarrow
|->\mapsto
<-)\hookleftarrow
(->\hookrightarrow
/-\leftharpoonup
\-\leftharpoondown
-/\rightharpoondown
-\\rightharpoonup
left and right
KeyLaTeX Command
left\left
right\right
accent marks
KeyLaTeX Command
tilde\tilde
T\tilde
wtilde\widetilde
hat\hat
what\widehat
w^\widehat
check\check
bar\bar
overline\overline
wbar\overline
dot\dot
ddot\ddot
vec\vec
~>\overrightarrow
VEC\overrightarrow
rage-aware stuffs
KeyLaTeX Command
prod\prod
CUP\bigcup
union\bigcup
CAP\bigcap
isc\bigcap
O+\bigoplus
Ox\bigotimes
other marks
KeyLaTeX Command
Z\aleph
|\|\aleph
h-\hbar
l\ell
wp\wp
R\Re
Im\Im
mho\mho
'\prime
0\emptyset
nabla\nabla
\/\surd
surd\surd
top\top
bot\bot
b\flat
LT\natural
6\partial
partial\partial
round\partial
[]\Box
Diamond\Diamond
3\triangle
C\clubsuit
D\diamondsuit
H\heartsuit
S\spadesuit

付記:上の表は yatex/yatexmth.el をもとに筆者がプログラムで作成した。すべてをチェックしたわけではないので、間違いがあるかもしれません。間違いありの場合、御容赦ください。

[8] yatex/yatexmth.el について注意すべきところ

[9] ユーザ辞書

例えばBegin型補完で C-c b のあとに foo というユーザ定義の環境名を入れたとすると、その環境名を保存するかどうか、保存するとすればどこに保存するのかを訊いてきます。このとき訊かれるオプションの意味と選び方はだいたい下記のごとし。

U) ユーザ辞書
ユーザ辞書 (~/.yatexrc) に保存します。
汎用環境に最適。
L) ローカル辞書
ローカル辞書 (./.yatexrc) に保存します。 . はカレントディレクトリ。
特定の文書のための環境はこれがいい。
N) メモリ
メモリに保存します。セッション中有効です。 セッションが終了すると消えます。
試しに用いる環境名にはこれがいい。
D) しない
保存しません。 同じ環境を使うたびに保存するかどうか訊いてきて煩いです。
環境名を入れ間違えたときにはいい。

以下はユーザ辞書の例です。自動的に作成されます(手で編集する場合は、構文に注意すること)。

[~/.yatexrc]

(setq user-env-table '(
("equation*")
("cases")
("align*")
("split")
("proof")
("eg")
("pmatrix")
("thm")
("defn")
))

(setq user-section-table '(
("newword")
))