Kodama's home / tips.
emacs では, LaTeX 文書の編集モードと Outline モードを組み合わせることで, section, subsection などの見出を表示して, 文書全体の構成を見やすくすることができます.
LaTeX 文書の編集をする場合, emacs に LaTeX の構文を認識させて作業を支援するように設定することができます. この LaTeX の編集モードで良く使われるものに YaTeXモード と AUC-TeXモード があります.
emacs の Outline モードでは文書の構成に応じて, テキストの詳細を見せたり, 一時的に隠したりできます. そのため, 文書全体の構成を把握しながら作業をすすめることが容易になります. 各節の表題を表示して全体の構成を把握しながら, 必要な節の詳細を表示して編集することができます.
児玉は AUC-TeXモード を使用していますが, 日本では YaTeXモード の利用者の方が多いかもしれません.
(defun latex-outline-level () (interactive) (let ((str nil)) (looking-at outline-regexp) (setq str (buffer-substring-no-properties (match-beginning 0) (match-end 0))) (cond ;; キーワード に 階層 を返す ((string-match "documentclass" str) 1) ((string-match "documentstyle" str) 1) ((string-match "part" str) 2) ((string-match "chapter" str) 3) ((string-match "appendix" str) 3) ((string-match "subsubsection" str) 6) ((string-match "subsection" str) 5) ((string-match "section" str) 4) (t (+ 6 (length str))) ))) (add-hook 'yatex-mode-hook '(lambda () (setq outline-level 'latex-outline-level) (make-local-variable 'outline-regexp) (setq outline-regexp (concat "[ \t]*\\\\\\(documentstyle\\|documentclass\\|" "part\\|chapter\\|appendix\\|section\\|subsection\\|subsubsection\\)" "\\*?[ \t]*[[{]")) (outline-minor-mode t)))
(add-hook 'LaTeX-mode-hook '(lambda () (outline-minor-mode t)))
Kodama's home / tips.