[[Emacs]] > YaTeX

*[[YaTeX:https://www.yatex.org/]] → Windows の Emacs で C-c ' を入力してもエラー行にジャンプしないなどの問題が発生する場合は [[Org mode>Emacs/Org mode]] または [[TeX mode>Emacs/TeX mode]] または [[AUCTeX]] を使用する [#o2c95a66]
*[[YaTeX:https://www.yatex.org/]] [#o2c95a66]

#ref(https://www.yatex.org/yalogo.gif,right,around,nolink,YaTeX)
YaTeX(野鳥)は Emacs の TeX 用メジャーモードです.
[[TeX mode>Emacs/TeX mode]] に比べ機能が大幅に拡張されています.
もう一つ,有名な拡張として [[AUCTeX]] があり,海外ではこちらがよく使われているようです.
国内では YaTeX の方が人気があり,そのため日本語の情報が Web 上でたくさん見つかります.

&color(White,#5F2F2F){  ''◆CONTENTS◆''  };&br;

----
#contents
----

#img(,clear)

*YaTeX とは [#q88fd71b]

YaTeX(野鳥)は Emacs の TeX モードです.

-[[YaTeX (Yet Another TeX mode for Emacs):https://www.yatex.org/]] (公式ページ)
-[[YaTeX (Yet Another LaTeX mode for Emacs.):https://www.yatex.org/]] (公式ページ)
--[[『野鳥』クイックリファレンス:https://www.yatex.org/yatexref.txt]]
--[[Yet Another tex-mode for Emacs - Table of Contents:https://www.yatex.org/info/yatexj_toc.html]]

**リリース情報 [#w889e1b2]

[[yatex: tags:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/tags]] を参照.~

Emacs 24.3 以降を使用している場合は YaTeX 1.77 以降を使用してください.~

**[[ChangeLog:https://www.yatex.org/yatex-new.txt]] [#n0cf386c]

-[[YaTeX Mercurial Repositories:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/]]
--[[コミットログ:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/shortlog/]]
--[[変更点:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/file/tip/yatex.new]]
--[[What's new in Japanese:https://www.yatex.org/yatex-new.txt]]
-https://github.com/emacsmirror/yatex
--[[コミットログ:https://github.com/emacsmirror/yatex/commits/]]
-http://twilog.org/hiroseyuuji/search?word=YaTeX
-http://twilog.org/ryseto/search?word=YaTeX

**スクリーンショット [#c84d00bd]
//#ref(http://oku.edu.mie-u.ac.jp/tex/file.php/2/moddata/forum/2/1712/LaTeXMathPreviewScreenshot.png,nolink,latex-math-preview.el)
//#ref(https://okumuralab.org/tex/file.php/2/moddata/forum/2/1712/LaTeXMathPreviewScreenshot.png,nolink,latex-math-preview.el)
#ref(http://www.emacswiki.org/pics/static/LaTeXMathPreviewScreenshot.png,nolink,latex-math-preview.el)

*注意点 [#x8b18a1c]

**" を入力しようとすると `` が入力される → C-q " [#ibf10abb]
**" を入力しようとすると `` が入力される [#ibf10abb]

-[[Emacs + YaTeX でダブルクォーテーションを入力:http://tetu1984.hateblo.jp/entry/20090123/1232651566]]

YaTeX, TeX mode, AUCTeX では " を入力しようとすると `` が入力されます.~
`` ではなく " を入力したい場合は C-q " (Ctrl-Q を入力した後で " を入力) とします.~
YaTeX, TeX mode, AUCTeX では " を入力しようとすると `` が入力されます.
`` ではなく " を入力したい場合は C-q " (Ctrl-Q を入力した後で " を入力) とします.

*不具合 [#m12f4e1b]

**YaTeX 1.77.5 で C-c C-g を入力して SumatraPDF で forward search ができない → yatexprc.el を修正する [#vf49c2d2]
**YaTeX 1.80 で (setq dvi2-command "okular --unique") を設定して C-c C-g を入力すると forward search ができない [#l5f1c74e]

YaTeX 1.77.5 で C-c C-g を入力して SumatraPDF で forward search ができません.~
yatexprc.el を修正します.~
yatexprc.el の
 ((string-match "sumatra" previewer)
の次の行の
 		   (format "%s %s.pdf %d %s"
 			   previewer bnr line cf))
をコメントアウトして
 ;		   (format "%s %s.pdf %d %s"
 ;			   previewer bnr line cf))
次の行に以下を追加します.~
 		   (format "%s \"%s.pdf\" -forward-search \"%s\" %d"
 			   previewer bnr cf line))
Okular は TeX ファイルをフルパスで指定しないと forward search ができないので,cf がフルパスでない場合は (expand-file-name cf) に修正する必要があります.
ただし,[[2016-01-08:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/rev/e78a87bc2c9e]] 以降では (cf (buffer-file-name)) に変更されて cf はフルパスになったため,この修正は必要ありません.

**YaTeX 1.77, 1.76 で Windows の Emacs で C-c ' を入力してもエラー行にジャンプしない → [[AUCTeX]] を使用する [#w3a7f06f]
Okular の format "%s '%s.pdf#src:%d' '%s'" の設定は間違いで,format "%s '%s.pdf#src:%d %s'" に修正する必要があります.

YaTeX 1.77, 1.76 で Windows の Emacs で C-c ' を入力してもエラー行にジャンプしません.~
Linux の Emacs や YaTeX 1.75, 1.74 では C-c ' を入力するとエラー行にジャンプします.~
エラー行にジャンプしたい場合は [[AUCTeX]] を使用してください.~
どうしても YaTeX でエラー行にジャンプしたい場合は
~/.emacs.d/init.el に
~/.emacs.d/init.el に yatexprc.el の YaTeX-preview-jump-line を修正したものを再設定します.

 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
   (setq tex-command "ptex2pdf -u -l -ot \"-synctex=1\""))
// (expand-file-name cf) はフルパスには関係なくて,フルパスになったの2016-01-08 に修正された
// (cf (buffer-file-name)) ではないのかと思います.

を設定して texmf.cnf に
// ↑
// ご指摘ありがとうございます.
// たしかに cf がフルパスに変更されていますね.
// Okular 以外のビューアはフルパスでなくても実行できると思うのですが
// すべてフルパスになっていても問題ないと思います.

 TEXEDIT = emacsclientw --no-wait +%d "%s"
 (with-eval-after-load 'yatexprc
   (defun YaTeX-preview-jump-line ()
     "Call jump-line function of various previewer on current main file"
     (interactive)
     (save-excursion
       (save-restriction
         (widen)
         (let*((pf (or YaTeX-parent-file
                       (save-excursion (YaTeX-visit-main t) (buffer-file-name))))
               (pdir (file-name-directory pf))
               (bnr (substring pf 0 (string-match "\\....$" pf)))
               ;(cf (file-relative-name (buffer-file-name) pdir))
               (cf (buffer-file-name)) ;2016-01-08
               (buffer (get-buffer-create " *preview-jump-line*"))
               (line (count-lines (point-min) (point-end-of-line)))
               (previewer (YaTeX-preview-default-previewer))
               (cmd (cond
                     ((string-match "Skim" previewer)
                      (format "%s %d '%s.pdf' '%s'"
                              YaTeX-cmd-displayline line bnr cf))
                     ((string-match "evince" previewer)
                      (format "%s '%s.pdf' %d '%s'"
                              "fwdevince" bnr line cf))
                     ((string-match "sumatra" previewer)
                      (format "%s \"%s.pdf\" -forward-search \"%s\" %d"
                              previewer bnr cf line))
                     ((string-match "zathura" previewer)
                      (format "%s --synctex-forward '%d:0:%s' '%s.pdf'"
                              previewer line cf bnr))
                     ((string-match "qpdfview" previewer)
                      (format "%s '%s.pdf#src:%s:%d:0'"
                              previewer bnr cf line))
                     ((string-match "okular" previewer)
                      (format "%s '%s.pdf#src:%d %s'"
                              previewer bnr line (expand-file-name cf)))
                     )))
           (YaTeX-system cmd "jump-line" 'noask pdir))))))

を設定 (emacsclientw.exe の存在するディレクトリに PATH を設定していない場合はフルパスで指定) して Emacs を起動して
**C-c C-t j でのコンパイル時に \includeonly の引数の置き換えがうまくできない [#ga957746]

 M-x server-start
Emacs 26.1 から switch-to-buffer の仕様が変更されたため想定通りの動作をしない.YaTeX 1.80.3 で修正されたので YaTeX を更新する.

を実行します.~

タイプセットしてエラーが発生したときに e を入力して Enter を押すとエラー行にジャンプできます.~

*ダウンロード [#g0fb682c]
-[[YaTeX リリース版:https://www.yatex.org/]]
-[[YaTeX リリース版:https://www.yatex.org/]], [[Releases - yuuji/yatex:https://www.yatex.org/gitbucket/yuuji/yatex/releases]]
-[[YaTeX テスト版:http://www.gentei.org/~yuuji/bin/yatexcurrent.cgi]]

*インストール [#b2ec65b9]

**Windows [#n699538a]
**MELPA からインストール [#x0d7daaa]

64-bit Windows の場合は~
[[NTEmacs64:https://github.com/chuntaro/NTEmacs64]] または [[emacs-w64:http://emacsbinw64.sourceforge.net/]]~
32-bit Windows の場合は~
[[NTEmacs:http://cha.la.coocan.jp/doc/NTEmacs.html]] または [[emacs-24.4-bin-i686-pc-mingw32.zip:http://ftp.gnu.org/gnu/emacs/windows/]]~
をインストールします.~
[[YaTeX リリース版:https://www.yatex.org/]] または [[YaTeX テスト版:http://www.gentei.org/~yuuji/bin/yatexcurrent.cgi]] をダウンロードして展開します.~
展開したフォルダー名を yatex に変更します.~
[[MELPA:https://melpa.org/]] から YaTeX がインストールできます.

-https://melpa.org/#/yatex
-https://github.com/melpa/melpa/blob/master/recipes/yatex
-https://github.com/melpa/melpa/commits/master/recipes/yatex

**公式サイトのパッケージを使用する場合 [#jde46c87]

[[YaTeX リリース版:https://www.yatex.org/]] または [[YaTeX テスト版:http://www.gentei.org/~yuuji/bin/yatexcurrent.cgi]] をダウンロードして展開します.
展開したフォルダー名を yatex に変更します.

Emacs を起動して
 C-x C-f ~/
で,ホームディレクトリ (~/) の場所を確認します.~
で,ホームディレクトリ (~/) の場所を確認します.

yatex フォルダーをコピーして ~/.emacs.d/site-lisp/ にペーストします.(~/.emacs.d/site-lisp/ が無ければ新規に作成します.)

----
 ~
 └─.emacs.d
     └─site-lisp
         └─yatex
----

***設定 [#edc51324]
~/.emacs.d/init.el に以下の設定を記述します.

~/.emacs.d/init.el に設定を記述します.~
プレビューと forward search は [[SumatraPDF]] を使用します.~
SumatraPDF を前面に表示したくない場合は [[SumatraPDF/fwdsumatrapdf]] の fwdsumatrapdf.exe を使用します.~
SumatraPDF の inverse search については [[Emacs#SumatraPDF との連携#inverse search>Emacs#a06810d6]] を参照してください.~
 (add-to-list 'load-path "~/.emacs.d/site-lisp/yatex")

*設定 [#p24cdf4a]

**Windows での設定例 [#n699538a]

~/.emacs.d/init.el に設定を記述します.

プレビューと forward search は [[SumatraPDF]] を使用します.
SumatraPDF を前面に表示したくない場合は [[SumatraPDF/fwdsumatrapdf]] の fwdsumatrapdf.exe を使用します.
SumatraPDF の inverse search については [[Emacs#SumatraPDF との連携#inverse search>Emacs#a06810d6]] を参照してください.

----
 ;;
 ;; YaTeX
 ;;
 (add-to-list 'load-path "~/.emacs.d/site-lisp/yatex")
 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
 (setq auto-mode-alist
       (append '(("\\.tex$" . yatex-mode)
                 ("\\.ltx$" . yatex-mode)
                 ("\\.cls$" . yatex-mode)
                 ("\\.sty$" . yatex-mode)
                 ("\\.clo$" . yatex-mode)
                 ("\\.bbl$" . yatex-mode)) auto-mode-alist))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-kanji-code nil)
 (setq YaTeX-latex-message-code 'utf-8)
 (setq YaTeX-use-LaTeX2e t)
 (setq YaTeX-use-AMS-LaTeX t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c pdflatex -synctex=1")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c lualatex -synctex=1")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c luajitlatex -synctex=1")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c xelatex -synctex=1")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/upbibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/mendex %O -U -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/upbibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/mendex %O -U -o %D %S/\" -e \"$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/\" -e \"$ps2pdf=q/ps2pdf.exe %O %S %D/\" -norc -gg -pdfps")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/pdflatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/lualatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/luajitlatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
 ;(setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/xelatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
 (setq bibtex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/upbibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/mendex %O -U -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
 (setq makeindex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/upbibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/mendex %O -U -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq tex-command "ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
 ;(setq tex-command "lualatex -synctex=1")
 ;(setq tex-command "latexmk")
 ;(setq tex-command "latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/upmendex %O -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
 ;(setq tex-command "latexmk -e \"$lualatex=q/lualatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/upmendex %O -o %D %S/\" -norc -gg -pdflua")
 (setq bibtex-command "latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/upmendex %O -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
 (setq makeindex-command "latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/upmendex %O -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
 (setq dvi2-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")
 ;(setq dvi2-command "texworks")
 ;(setq dvi2-command "texstudio --pdf-viewer-only")
 (setq tex-pdfview-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")
 ;(setq tex-pdfview-command "texworks")
 ;(setq tex-pdfview-command "texstudio --pdf-viewer-only")
 (setq dviprint-command-format "powershell -Command \"& {$r = Write-Output %s;$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFileNameWithoutExtension($r),'.pdf','\"\"\"');Start-Process pdfopen -ArgumentList ('--rxi','--file',$p)}\"")
 
 (defun sumatrapdf-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "sumatrapdf"
       nil
       "rundll32"
       "shell32,ShellExec_RunDLL"
       "SumatraPDF"
       "-reuse-instance"
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       "-forward-search"
       (buffer-name)
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c s") 'sumatrapdf-forward-search)))
 
 (setq dviprint-command-format "powershell -Command \"& {$r = Write-Output %s;$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFileNameWithoutExtension($r),'.pdf','\"\"\"');Start-Process Acrobat -ArgumentList ($p)}\"")

 (defun fwdsumatrapdf-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
     (process-query-on-exit-flag
      (start-process
       "fwdsumatrapdf"
       nil
       "fwdsumatrapdf"
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       (buffer-name)
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))))))
 

 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c f") 'fwdsumatrapdf-forward-search)))
 

 (add-hook 'yatex-mode-hook
           '(lambda ()
              (auto-fill-mode -1)))
 

 ;;
 ;; RefTeX with YaTeX
 ;;
 ;(add-hook 'yatex-mode-hook 'turn-on-reftex)
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (reftex-mode 1)
              (define-key reftex-mode-map (concat YaTeX-prefix ">") 'YaTeX-comment-region)
              (define-key reftex-mode-map (concat YaTeX-prefix "<") 'YaTeX-uncomment-region)))
----

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力 (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~キーバインド (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|Process -> LaTeX|C-c C-t j または C-c C-t C-j|upLaTeX (ptex2pdf)|
|Process -> BibTeX|C-c C-t b RET|upbibtex, biber (Latexmk-pdfupLaTeX)|
|Process -> makeindex|C-c C-t i RET|mendex (Latexmk-pdfupLaTeX)|
|Process -> BibTeX|C-c C-t b RET|bibtexu, biber (upLaTeXmk)|
|Process -> makeindex|C-c C-t i RET|upmendex (upLaTeXmk)|
|Process -> Preview|C-c C-t p RET RET|PDF プレビュー|
|Process -> lpr|C-c C-t l RET|Adobe Reader で PDF プレビューまたは印刷|
||C-c C-g または C-c s または M-x sumatrapdf-forward-search RET|SumatraPDF で forward search|
|Process -> lpr|C-c C-t l RET|Adobe Acrobat Reader で PDF プレビューまたは印刷|
||C-c C-g|SumatraPDF で forward search|
||C-c f または M-x fwdsumatrapdf-forward-search RET|fwdsumatrapdf で forward search|
<

**OS X [#p7238e02]
**macOS での設定例 [#p7238e02]

-[[Mac miniをセットアップする その3 ~emacs,yatex,skim編~:http://t44or2.hatenablog.com/entry/2016/10/29/152327]]
-[[emacsでyatexを使う簡単な方法(Mac):http://ganmacs.hatenablog.com/entry/2013/09/07/225350]]
-[[TeXLive2013 +Emacs + YaTex の設定をした:http://d.hatena.ne.jp/tnil/20130823/1377230350]]
-[[EmacsとSkim.appでTeX・PDFシンクロ:http://d.hatena.ne.jp/setoryohei/20110102/1294003836]]
-[[emacs_and_tex:https://github.com/ryseto/emacs_and_tex]]
-[[Retina を活かす Emacs へ移行2:http://milanista224.blogspot.jp/2013/07/retina-emacs243.html]]

を参照.

[[Emacs.app:http://www.muskmelon.jp/?page_id=79]] をインストールします.~
[[YaTeX リリース版:https://www.yatex.org/]] または [[YaTeX テスト版:http://www.gentei.org/~yuuji/bin/yatexcurrent.cgi]] をダウンロードして展開します.~
展開したフォルダー名を yatex に変更します.~
&#x7e;/.emacs.d/init.el に設定を記述します.

Emacs を起動して
 C-x C-f ~/
で,ホームディレクトリ (&#x7e;/) の場所を確認します.
プレビューと forward search は [[Skim]] を使用します.
Skim の inverse search については [[Emacs#Skim との連携#inverse search>Emacs#e9c08b3d]] を参照してください.

yatex フォルダーをコピーして &#x7e;/.emacs.d/site-lisp/ にペーストします.(&#x7e;/.emacs.d/site-lisp/ が無ければ新規に作成します.)

動作未確認です.
----
 ~
 └─.emacs.d
     └─site-lisp
         └─yatex
----

***設定 [#qe563613]
&#x7e;/.emacs.d/init.el に設定を記述します.~
プレビューと forward search は [[Skim]] を使用します.~
Skim の inverse search については [[Emacs#Skim との連携#inverse search>Emacs#e9c08b3d]] を参照してください.~

----
 ;;
 ;; PATH
 ;;
 (setenv "PATH" "/usr/local/bin:/Library/TeX/texbin/:/Applications/Skim.app/Contents/SharedSupport:$PATH" t)
 (setq exec-path (append '("/usr/local/bin" "/Library/TeX/texbin" "/Applications/Skim.app/Contents/SharedSupport") exec-path))
 
 ;;
 ;; YaTeX
 ;;
 (add-to-list 'load-path "~/.emacs.d/site-lisp/yatex")
 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
 (setq auto-mode-alist
       (append '(("\\.tex$" . yatex-mode)
                 ("\\.ltx$" . yatex-mode)
                 ("\\.cls$" . yatex-mode)
                 ("\\.sty$" . yatex-mode)
                 ("\\.clo$" . yatex-mode)
                 ("\\.bbl$" . yatex-mode)) auto-mode-alist))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-kanji-code nil)
 (setq YaTeX-latex-message-code 'utf-8)
 (setq YaTeX-use-LaTeX2e t)
 (setq YaTeX-use-AMS-LaTeX t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq tex-command "/usr/texbin/ptex2pdf -u -l -ot '-synctex=1'")
 ;(setq tex-command "/usr/texbin/pdflatex -synctex=1")
 ;(setq tex-command "/usr/texbin/lualatex -synctex=1")
 ;(setq tex-command "/usr/texbin/luajitlatex -synctex=1")
 ;(setq tex-command "/usr/texbin/xelatex -synctex=1")
 ;(setq tex-command "/usr/texbin/latexmk")
 ;(setq tex-command "/usr/texbin/latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 ;(setq tex-command "/usr/texbin/latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/' -e '$ps2pdf=q/ps2pdf %O %S %D/' -norc -gg -pdfps")
 ;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/pdflatex %O -synctex=1 %S/' -e '$bibtex=q/bibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 ;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/lualatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 ;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/luajitlatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 ;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/xelatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 (setq bibtex-command "/usr/texbin/latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq makeindex-command "/usr/texbin/latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq dvi2-command "/usr/bin/open -a Skim")
 ;(setq dvi2-command "/usr/bin/open -a Preview")
 ;(setq dvi2-command "/usr/bin/open -a TeXShop")
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq tex-command "ptex2pdf -u -l -ot '-synctex=1'")
 ;(setq tex-command "lualatex -synctex=1")
 ;(setq tex-command "latexmk")
 ;(setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 ;(setq tex-command "latexmk -e '$lualatex=q/lualatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -norc -gg -pdflua")
 (setq bibtex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq makeindex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq dvi2-command "open -a Skim")
 ;(setq dvi2-command "open -a Preview")
 ;(setq dvi2-command "open -a TeXShop")
 ;(setq dvi2-command "/Applications/TeXworks.app/Contents/MacOS/TeXworks")
 ;(setq dvi2-command "/Applications/texstudio.app/Contents/MacOS/texstudio --pdf-viewer-only")
 (setq tex-pdfview-command "/usr/bin/open -a Skim")
 ;(setq tex-pdfview-command "/usr/bin/open -a Preview")
 ;(setq tex-pdfview-command "/usr/bin/open -a TeXShop")
 (setq tex-pdfview-command "open -a Skim")
 ;(setq tex-pdfview-command "open -a Preview")
 ;(setq tex-pdfview-command "open -a TeXShop")
 ;(setq tex-pdfview-command "/Applications/TeXworks.app/Contents/MacOS/TeXworks")
 ;(setq tex-pdfview-command "/Applications/texstudio.app/Contents/MacOS/texstudio --pdf-viewer-only")
 (setq dviprint-command-format "/usr/bin/open -a \"Adobe Reader\" `echo %s | gsed -e \"s/\\.[^.]*$/\\.pdf/\"`")
 (setq dviprint-command-format "open -a \"Adobe Acrobat Reader DC\" `echo %s | gsed -e \"s/\\.[^.]*$/\\.pdf/\"`")
 
 (defun skim-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process  
       "displayline"
       nil
       "/Applications/Skim.app/Contents/SharedSupport/displayline"
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       buffer-file-name))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c s") 'skim-forward-search)))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (auto-fill-mode -1)))
 
 ;;
 ;; RefTeX with YaTeX
 ;;
 ;(add-hook 'yatex-mode-hook 'turn-on-reftex)
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (reftex-mode 1)
              (define-key reftex-mode-map (concat YaTeX-prefix ">") 'YaTeX-comment-region)
              (define-key reftex-mode-map (concat YaTeX-prefix "<") 'YaTeX-uncomment-region)))
----

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力 (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~キーバインド (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|Process -> LaTeX|C-c C-t j または C-c C-t C-j|upLaTeX (ptex2pdf)|
|Process -> BibTeX|C-c C-t b RET|upbibtex, biber (Latexmk-pdfupLaTeX)|
|Process -> makeindex|C-c C-t i RET|mendex (Latexmk-pdfupLaTeX)|
|Process -> BibTeX|C-c C-t b RET|bibtexu, biber (upLaTeXmk)|
|Process -> makeindex|C-c C-t i RET|upmendex (upLaTeXmk)|
|Process -> Preview|C-c C-t p RET RET|PDF プレビュー|
|Process -> lpr|C-c C-t l RET|Adobe Reader で PDF プレビューまたは印刷|
||C-c C-g または C-c s または M-x skim-forward-search RET|Skim で forward search|
|Process -> lpr|C-c C-t l RET|Adobe Acrobat Reader で PDF プレビューまたは印刷|
||C-c C-g|Skim で forward search|
<

**Linux [#e2cbcccd]
**Linux での設定例 [#e2cbcccd]

[[YaTeX リリース版:https://www.yatex.org/]] または [[YaTeX テスト版:http://www.gentei.org/~yuuji/bin/yatexcurrent.cgi]] をダウンロードして展開します.~
展開したフォルダー名を yatex に変更します.~
&#x7e;/.emacs.d/init.el に設定を記述します.

Emacs を起動して
 C-x C-f ~/
で,ホームディレクトリ (&#x7e;/) の場所を確認します.
fwdevince は [[Evince/fwdevince]] にあるものを使用します.
Evince の inverse search については [[Emacs#Evince との連携#inverse search>Emacs#vecb4fd9]] を参照してください.

yatex フォルダーをコピーして &#x7e;/.emacs.d/site-lisp/ にペーストします.(&#x7e;/.emacs.d/site-lisp/ が無ければ新規に作成します.)

----
 ~
 └─.emacs.d
     └─site-lisp
         └─yatex
----

***設定 [#nec42ee2]

&#x7e;/.emacs.d/init.el に設定を記述します.~
fwdevince は [[Evince/fwdevince]] の fwdevince を使用します.~
Evince の inverse search については [[Emacs#Evince との連携#inverse search>Emacs#vecb4fd9]] を参照してください.~

----
 ;;
 ;; YaTeX
 ;;
 (add-to-list 'load-path "~/.emacs.d/site-lisp/yatex")
 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
 (setq auto-mode-alist
       (append '(("\\.tex$" . yatex-mode)
                 ("\\.ltx$" . yatex-mode)
                 ("\\.cls$" . yatex-mode)
                 ("\\.sty$" . yatex-mode)
                 ("\\.clo$" . yatex-mode)
                 ("\\.bbl$" . yatex-mode)) auto-mode-alist))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-kanji-code nil)
 (setq YaTeX-latex-message-code 'utf-8)
 (setq YaTeX-use-LaTeX2e t)
 (setq YaTeX-use-AMS-LaTeX t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq tex-command "ptex2pdf -u -l -ot '-synctex=1'")
 ;(setq tex-command "pdflatex -synctex=1")
 ;(setq tex-command "lualatex -synctex=1")
 ;(setq tex-command "luajitlatex -synctex=1")
 ;(setq tex-command "xelatex -synctex=1")
 ;(setq tex-command "latexmk")
 ;(setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 ;(setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/' -e '$ps2pdf=q/ps2pdf %O %S %D/' -norc -gg -pdfps")
 ;(setq tex-command "latexmk -e '$pdflatex=q/pdflatex %O -synctex=1 %S/' -e '$bibtex=q/bibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 ;(setq tex-command "latexmk -e '$pdflatex=q/lualatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 ;(setq tex-command "latexmk -e '$pdflatex=q/luajitlatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 ;(setq tex-command "latexmk -e '$pdflatex=q/xelatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf")
 (setq bibtex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq makeindex-command  "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq dvi2-command "xdg-open")
 ;(setq dvi2-command "evince")
 ;(setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 ;(setq tex-command "latexmk -e '$lualatex=q/lualatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -norc -gg -pdflua")
 (setq bibtex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 (setq makeindex-command  "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
 ;(setq dvi2-command "xdg-open")
 (setq dvi2-command "evince")
 ;(setq dvi2-command "atril")
 ;(setq dvi2-command "okular --unique")
 ;(setq dvi2-command "zathura -s -x \"emacsclient --no-wait +%{line} %{input}\"")
 ;(setq dvi2-command "zathura -x \"emacsclient --no-wait +%{line} %{input}\"")
 ;(setq dvi2-command "qpdfview --unique")
 ;(setq dvi2-command "texworks")
 ;(setq dvi2-command "texstudio --pdf-viewer-only")
 (setq tex-pdfview-command "xdg-open")
 ;(setq tex-pdfview-command "evince")
 ;(setq tex-pdfview-command "xdg-open")
 (setq tex-pdfview-command "evince")
 ;(setq tex-pdfview-command "atril")
 ;(setq tex-pdfview-command "okular --unique")
 ;(setq tex-pdfview-command "zathura -s -x \"emacsclient --no-wait +%{line} %{input}\"")
 ;(setq tex-pdfview-command "zathura -x \"emacsclient --no-wait +%{line} %{input}\"")
 ;(setq tex-pdfview-command "qpdfview --unique")
 ;(setq tex-pdfview-command "texworks")
 ;(setq tex-pdfview-command "texstudio --pdf-viewer-only")
 (setq dviprint-command-format "xdg-open `echo %s | sed -e \"s/\\.[^.]*$/\\.pdf/\"`")
 
 (defun evince-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "fwdevince"
       nil
       "fwdevince"
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))
       (buffer-name)))))
 
 (setq dviprint-command-format "wine64 cmd /c start Acrobat.exe `echo %s | sed -e \"s/\\.[^.]*$/\\.pdf/\"`")

 (with-eval-after-load 'yatexprc
   (defun YaTeX-preview-jump-line ()
     "Call jump-line function of various previewer on current main file"
     (interactive)
     (save-excursion
       (save-restriction
         (widen)
         (let*((pf (or YaTeX-parent-file
                       (save-excursion (YaTeX-visit-main t) (buffer-file-name))))
               (pdir (file-name-directory pf))
               (bnr (substring pf 0 (string-match "\\....$" pf)))
               ;(cf (file-relative-name (buffer-file-name) pdir))
               (cf (buffer-file-name)) ;2016-01-08
               (buffer (get-buffer-create " *preview-jump-line*"))
               (line (count-lines (point-min) (point-end-of-line)))
               (previewer (YaTeX-preview-default-previewer))
               (cmd (cond
                     ((string-match "Skim" previewer)
                      (format "%s %d '%s.pdf' '%s'"
                              YaTeX-cmd-displayline line bnr cf))
                     ((string-match "evince" previewer)
                      (format "%s '%s.pdf' %d '%s'"
                              "fwdevince" bnr line cf))
                     ((string-match "sumatra" previewer)
                      (format "%s \"%s.pdf\" -forward-search \"%s\" %d"
                              previewer bnr cf line))
                     ((string-match "zathura" previewer)
                      (format "%s --synctex-forward '%d:0:%s' '%s.pdf'"
                              previewer line cf bnr))
                     ((string-match "qpdfview" previewer)
                      (format "%s '%s.pdf#src:%s:%d:0'"
                              previewer bnr cf line))
                     ((string-match "okular" previewer)
                      (format "%s '%s.pdf#src:%d %s'"
                              previewer bnr line (expand-file-name cf)))
                     )))
           (YaTeX-system cmd "jump-line" 'noask pdir))))))

 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c e") 'evince-forward-search)))
 
 (require 'dbus)
 
 (defun un-urlify (fname-or-url)
   "A trivial function that replaces a prefix of file:/// with just /."
   (if (string= (substring fname-or-url 0 8) "file:///")
       (substring fname-or-url 7)
     fname-or-url))
 
 (defun evince-inverse-search (file linecol &rest ignored)
   (let* ((fname (un-urlify file))
          (buf (find-file fname))
          (line (car linecol))
          (col (cadr linecol)))
     (if (null buf)
         (message "[Synctex]: %s is not opened..." fname)
       (switch-to-buffer buf)
       (goto-line (car linecol))
       (unless (= col -1)
         (move-to-column col)))))
 
 (dbus-register-signal
  :session nil "/org/gnome/evince/Window/0"
  "org.gnome.evince.Window" "SyncSource"
  'evince-inverse-search)
 
 (defun okular-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "okular"
       nil
       "okular"
       "--unique"
       (concat (expand-file-name
                (concat (file-name-sans-extension (or YaTeX-parent-file
                                                      (save-excursion
                                                        (YaTeX-visit-main t)
                                                        buffer-file-name)))
                        ".pdf"))
               "#src:"
               (number-to-string (save-restriction
                                   (widen)
                                   (count-lines (point-min) (point))))
               (buffer-file-name))))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c o") 'okular-forward-search)))
 
 (defun zathura-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "zathura"
       nil
       "zathura"
       "--synctex-forward"
       (concat (number-to-string (save-restriction
                                   (widen)
                                   (count-lines (point-min) (point))))
               ":0:"
               (buffer-name))
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c z") 'zathura-forward-search)))
 
 (defun qpdfview-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "qpdfview"
       nil
       "qpdfview"
       "--unique"
       (concat (expand-file-name
                (concat (file-name-sans-extension (or YaTeX-parent-file
                                                      (save-excursion
                                                        (YaTeX-visit-main t)
                                                        buffer-file-name)))
                        ".pdf"))
               "#src:"
               (buffer-name)
               ":"
               (number-to-string (save-restriction
                                   (widen)
                                   (count-lines (point-min) (point))))
               ":0")))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c q") 'qpdfview-forward-search)))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (auto-fill-mode -1)))
 

 ;;
 ;; RefTeX with YaTeX
 ;;
 ;(add-hook 'yatex-mode-hook 'turn-on-reftex)
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (reftex-mode 1)
              (define-key reftex-mode-map (concat YaTeX-prefix ">") 'YaTeX-comment-region)
              (define-key reftex-mode-map (concat YaTeX-prefix "<") 'YaTeX-uncomment-region)))
----

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力 (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~キーバインド (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|Process -> LaTeX|C-c C-t j または C-c C-t C-j|upLaTeX (ptex2pdf)|
|Process -> BibTeX|C-c C-t b RET|upbibtex, biber (Latexmk-pdfupLaTeX)|
|Process -> makeindex|C-c C-t i RET|mendex (Latexmk-pdfupLaTeX)|
|Process -> BibTeX|C-c C-t b RET|bibtexu, biber (upLaTeXmk)|
|Process -> makeindex|C-c C-t i RET|upmendex (upLaTeXmk)|
|Process -> Preview|C-c C-t p RET RET|PDF プレビュー|
|Process -> lpr|C-c C-t l RET|xdg-open で PDF プレビューまたは印刷|
||C-c C-g または C-c e または M-x evince-forward-search RET|Evince で forward search|
||C-c o または M-x okular-forward-search RET|Okular で forward search|
||C-c z または M-x zathura-forward-search RET|zathura で forward search|
||C-c q または M-x qpdfview-forward-search RET|qpdfview で forward search|
|Process -> lpr|C-c C-t l RET|Adobe Acrobat Reader で PDF プレビューまたは印刷|
||C-c C-g|Evince で forward search&br;Okular で forward search&br;zathura で forward search&br;qpdfview で forward search|
<

*使い方 [#v90b1615]
さまざまな機能がありますので、まずは少しだけ。

**タイプセット・プレビュー [#r68a2a97]
**キーバインドについての注意(昔からの利用者向け) [#je823773]
(setq YaTeX-inhibit-prefix-letter t) を使用してください.
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.
t と nil ではキーバインドが異なります(前者だと C-c C-t letter,後者だと C-c t letter になる).

(setq YaTeX-inhibit-prefix-letter t) を使用してください.~
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.~
YaTeX-inhibit-prefix-letter は t と nil でキーバインドが異なります.~
Linux Mint, Debian GNU/Linux, Vine Linux に収録されている YaTeX の最新版はデフォルトで t となっており,YaTeX の作者も t を推奨しています (YaTeX ML [yatex:04567] を参照).~
変更の理由は YaTeX が使用していたキーバインドがユーザー向けに予約されていた C-c letter に設定されていたためと思われます.~
 (setq YaTeX-inhibit-prefix-letter t)

----
[[Emacs Lispのコーディングの慣習:http://www.bookshelf.jp/texi/elisp-manual/21-2-8/jp/elisp_42.html#IDX3219]] より
----
-読者のメジャーモードでは、 C-c letter をキーとして定義しないこと。 これらのキー列はユーザー向けに予約済みである。 それら''だけ''がユーザー向けに予約されたキー列であり、 それらを禁止しないこと。
Linux Mint, Debian GNU/Linux, Vine Linux に収録されている YaTeX の最新版はデフォルトで t となっており,YaTeX の作者も t を推奨しています (YaTeX ML [yatex:04567] を参照).
変更の理由は YaTeX が使用していたキーバインドがユーザー向けに予約されていた C-c letter に設定されていたためと思われます.

https://github.com/emacs-jp/elisp-manual-ja/blob/master/tips.texi#L172-L198 より

>
-読者のメジャーモードでは、 C-c letter をキーとして定義しないこと。 これらのキー列はユーザー向けに予約済みである。 それら''だけ''がユーザー向けに予約されたキー列であり、 それらを禁止しないこと。
>>
かわりに、C-c のあとにコントロール文字か数字文字か特定の句読点文字が続く キー列を定義する。 これらのキー列は、メジャーモード用に予約してある。
<
>
<<
>>
Emacs のすべてのモードをこの慣習に従うように変換するのは たいへんな作業量であった。 この慣習を捨てさるとその作業をむだにしてしまい、ユーザーにも不便である。
<<
<
----

**タイプセット・プレビュー [#r68a2a97]

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力 (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~キーバインド (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~機能|
|Process -> LaTeX|C-c C-t j または C-c C-t C-j|タイプセット|
|Process -> LaTeX+PDF|C-c C-t d|latex + dvipdfmx|
|Process -> Kill LaTeX|C-c C-t k|タイプセットを中断|
|Process -> Preview|C-c C-t p RET RET|プレビュー|
|Process -> BibTeX|C-c C-t b RET|BibTeX|
|Process -> makeindex|C-c C-t i RET|MakeIndex|
|Process -> lpr|C-c C-t l RET|LPR (印刷)|
||C-c C-g|forward search|
||C-c '|エラー行にジャンプ|
||M-x yatex|親ファイルの再設定|
<

----
&color(#2E20DE,#2E20DE){%%% %%%};[[&ref(http://upload.wikimedia.org/wikipedia/commons/thumb/0/08/EmacsIcon.svg/200px-EmacsIcon.svg.png,around,28x28,GNU Emacs - GNU Project - Free Software Foundation (FSF));>http://www.gnu.org/software/emacs/]]&color(#2E20DE,#2E20DE){%%%                    &color(Black){''emacs@YaTeX''};             &color(#2E20DE,#2E20DE){%%%[ &color(Black){''◛''}; ]%%%};&color(#2E20DE,#2E20DE){%%%[ &color(Black){''▭''}; ]%%%};&color(#DD4444,#DD4444){%%%[ &color(White){''×''}; ]%%%};%%%};&br;
&color(Black,#DAE0FE){%%%  ファイル  編集  オプション  バッファ  ツール  YaTeX  Ref  ヘルプ           %%%};&br;
...&br;
&#x2d;U\---  ''yatex.tex''     Top L1   (やてふ Ref)--------------------------------&br;
J)latex R)egion E)nv B)ibtex mk(I)dx latex+p(D)f K)ill P)review S)earch V)iewErr L)pr&br;
----

**補完 [#g3780d28]

(setq YaTeX-inhibit-prefix-letter t) を使用してください.~
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.~

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力 (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~補完|
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~メニュー [YaTeX]|COLOR(#FFF):BGCOLOR(#22D):CENTER:~キーバインド (setq YaTeX-inhibit-prefix-letter t)|COLOR(#FFF):BGCOLOR(#22D):CENTER:~補完|
|Environment -> リストから選択|C-c C-b SPC|begin 型補完|
|Environment region -> リストから選択|C-c B SPC|指定領域に対して begin 型補完|
|Section type -> リストから選択|C-c C-s|section 型補完|
|Section type region (long name) -> リストから選択|C-c S|指定領域に対して section 型補完|
||C-c C-e|end 補完|
<

補完を使わないと
 \begin{itemize}
 \item AUCTeX
 \item YaTeX
 \end{今度からはちゃんと ^C b を使いましょう}
と言われます.

begin 型補完を使うのを忘れた場合は
 \begin{itemize}
 \item AUCTeX
 \item YaTeX
の時に end 補完を使うと
 \end{itemize}
を補完してくれます.

**タイプセット方式の変更 [#m8567380]

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力|COLOR(#FFF):BGCOLOR(#22D):CENTER:~タイプセット方式|
|M-x set-variable RET tex-command RET "latexmk" RET|latexmk|
|M-x set-variable RET tex-command RET "pdflatex -synctex=1" RET|pdflatex|
|M-x set-variable RET tex-command RET "lualatex -synctex=1" RET|lualatex|
|M-x set-variable RET tex-command RET "luajitlatex -synctex=1" RET|luajitlatex|
|M-x set-variable RET tex-command RET "xelatex -synctex=1" RET|xelatex|
<

**タイプセット方式の確認 [#k374ed95]

>
|COLOR(#FFF):BGCOLOR(#22D):CENTER:~入力|
|M-x describe-variable RET tex-command RET|
<
 M-x describe-variable RET tex-command RET

**その他 [#za795743]
[[『野鳥』クイックリファレンス:https://www.yatex.org/yatexref.txt]] もご覧下さい.~
詳細は [[Yet Another tex-mode for Emacs - Table of Contents:https://www.yatex.org/info/yatexj_toc.html]] をご覧下さい.~
[[瀬戸 亮平:http://d.hatena.ne.jp/setoryohei/]] さんの [[YaTeX demo:http://d.hatena.ne.jp/setoryohei/20120106]] で YaTeX の機能が紹介されています.~
詳細は [[Yet Another tex-mode for Emacs - Table of Contents:https://www.yatex.org/info/yatexj_toc.html]] をご覧下さい.

-[[『野鳥』クイックリファレンス:https://www.yatex.org/yatexref.txt]] もご覧下さい.
-[[瀬戸 亮平:http://d.hatena.ne.jp/setoryohei/]] さんの [[YaTeX demo:http://d.hatena.ne.jp/setoryohei/20120106]] で YaTeX の機能が紹介されています.

*ソースのサンプル [#q88c5ad1]
ヘッダー部分に用途別に追加してみました.テンプレートとしても使えるかもしれません.
 %% -*- coding: utf-8-unix -*-
 %#!ptex2pdf -u -l -ot "-kanji=utf8 -no-guess-input-enc -synctex=1" hogehoge
 % #!tasklist /fi "IMAGENAME eq AcroRd32.exe" /nh | findstr "AcroRd32.exe" > nul && pdfopen --rxi --file hogehoge.pdf && pdfclose --rxi --file hogehoge.pdf & ptex2pdf -u -l hogehoge && pdfopen --rxi --file hogehoge.pdf
 %#BIBTEX upbibtex hogehoge
 %#MAKEINDEX mendex -U hogehoge
 %#LPR if exist "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe" ("C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe" /p hogehoge.pdf) else "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /p hogehoge.pdf
 % #!tasklist /fi "IMAGENAME eq Acrobat.exe" /nh | findstr "Acrobat.exe" > nul && taskkill /im Acrobat.exe & ptex2pdf -u -l hogehoge && start Acrobat hogehoge.pdf
 %#BIBTEX bibtexu hogehoge
 %#MAKEINDEX upmendex hogehoge
 %#LPR if exist "C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" ("C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /p hogehoge.pdf) else "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /p hogehoge.pdf
 % #LPR acroread.bat /p hogehoge.pdf

 \documentclass[uplatex]{jsarticle}
 \documentclass[uplatex,dvipdfmx,ja=standard]{bxjsarticle}
 \begin{document}
 Welcom to YaTeX World!
 \end{document}

 %%% Local Variables: 
 %%% Local Variables:
 %%% TeX-master: "hogehoge"
 %%% End: 
 %%% End:

PDF ファイルでの印刷が多くなってきているので,LPR も PDF ファイルに対応させてみました.~
パスの通ったところに,acroread.bat というファイル名で以下のスクリプトを保存します.~
PDF ファイルでの印刷が多くなってきているので,LPR も PDF ファイルに対応させてみました.
パスの通ったところに,acroread.bat というファイル名で以下のスクリプトを保存します.
 @echo off
 REM USAGE: acroread.bat [options] filename
 if exist "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe" (
   "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
 if exist "C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" (
   "C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
 ) else (
   "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
   "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
 )

*&#x7e;/.emacs.d/init.el 見せてください. [#uc0145ec]
あくまで一例です。~
ぜひ修正、加筆お願いします。~
あくまで一例です。
ぜひ修正、加筆お願いします。

**‘load-path’に yatex.el が存在するフォルダー (ディレクトリ) を追加 [#pe637e19]

 (add-to-list 'load-path "~/.emacs.d/site-lisp/yatex")

** *.texで自動的にYaTeXモード [#d7fc1e0e]

 (setq auto-mode-alist
       (append '(("\\.tex$" . yatex-mode)) auto-mode-alist))
 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

または

 (setq auto-mode-alist
       (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

**YaTeX-inhibit-prefix-letter [#j42805c2]
**ファイルを保存する際の文字コードの指定 [#j78164d5]

(setq YaTeX-inhibit-prefix-letter t) を使用してください.~
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.~
YaTeX-kanji-code を nil 以外にすると''指定した文字コード以外の TeX ファイルや sty ファイルも指定した文字コードで保存されてしまう''ので ''nil を指定することをおすすめします''.

 (setq YaTeX-inhibit-prefix-letter t)
YaTeX 1.80 で YaTeX-kanji-code のデフォルトが nil に変更されました.

**Kanji code [#j78164d5]

YaTeX-kanji-code を nil 以外にすると''指定した文字コード以外の TeX ファイルも指定した文字コードで保存されてしまう''ので nil を指定することをおすすめします.

-[[8.4.3 文字エンコーディングの設定:http://hwb.ecc.u-tokyo.ac.jp/current/literacy/editor/emacs/encoding/]]
-http://www.mzks.org/wiki/index.php?Emacs

 ;;;   nil=YaTeX-kanji-code が nil なら coding-system に感知しない
 ;;;   0=no-converion -> Emacs 内部で使用されている文字コードで保存される (Emacs 23 以降では utf-8-emacs)
 ;;;   1=Shift JIS (Shift_JIS)
 ;;;   2=JIS (ISO-2022-JP)
 ;;;   3=EUC (EUC-JP)
 ;;;   4=UTF-8
 ;;;   nil: Do not care (Preserve coding-system) -> ファイルの文字コードを変更せずに保存する
 ;;;   0: no-converion -> Emacs 内部で使用されている文字コードで保存される(Emacs 23 以降では utf-8-emacs)
 ;;;   1: Shift JIS (Shift_JIS) -> Shift_JIS で保存される
 ;;;   2: JIS (ISO-2022-JP) -> ISO-2022-JP で保存される
 ;;;   3: EUC (EUC-JP) -> EUC-JP で保存される
 ;;;   4: UTF-8 -> UTF-8 で保存される
 (setq YaTeX-kanji-code nil)

**LaTeX でタイプセットしたときに出力されるメッセージの文字コードを指定 (*YaTeX-typesetting* バッファの文字コードの指定) [#v14da95b]

 (setq YaTeX-latex-message-code 'utf-8)

**TeX typeset [#h9687728]
***upLaTeX (ptex2pdf) [#u98acf96]

 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
     (setq tex-command "ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
   (setq tex-command "ptex2pdf -u -l -ot \"-synctex=1\""))
***pdfLaTeX [#haa09a91]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c pdflatex -synctex=1")
   (setq tex-command "pdflatex -synctex=1"))

***LuaLaTeX [#r2c74452]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c lualatex -synctex=1")
     (setq tex-command "lualatex -synctex=1")
   (setq tex-command "lualatex -synctex=1"))
***LuaJITLaTeX [#kfa37927]

***upLaTeXmk [#bc88da07]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c luajitlatex -synctex=1")
   (setq tex-command "luajitlatex -synctex=1"))
***XeLaTeX [#h279d9b8]
     (setq tex-command "latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/upmendex %O -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
   (setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi"))

***LuaLaTeXmk [#d4a80fb8]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c xelatex -synctex=1")
   (setq tex-command "xelatex -synctex=1"))
***Latexmk [#me8a1b75]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk")
   (setq tex-command "latexmk"))
***Latexmk-pdfupLaTeX [#bc88da07]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/upbibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/mendex %O -U -o %D %S/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
   (setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi"))
***Latexmk-pdfupLaTeX2 [#od385031]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$latex=q/uplatex %O -kanji=utf8 -no-guess-input-enc -synctex=1 %S/\" -e \"$bibtex=q/upbibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/mendex %O -U -o %D %S/\" -e \"$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/\" -e \"$ps2pdf=q/ps2pdf.exe %O %S %D/\" -norc -gg -pdfps")
   (setq tex-command "latexmk -e '$latex=q/uplatex %O -synctex=1 %S/' -e '$bibtex=q/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/mendex %O -U -o %D %S/' -e '$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/' -e '$ps2pdf=q/ps2pdf %O %S %D/' -norc -gg -pdfps"))
***Latexmk-pdfLaTeX [#n70096b8]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/pdflatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtex %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
   (setq tex-command "latexmk -e '$pdflatex=q/pdflatex %O -synctex=1 %S/' -e '$bibtex=q/bibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf"))
***Latexmk-LuaLaTeX [#d4a80fb8]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/lualatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
   (setq tex-command "latexmk -e '$pdflatex=q/lualatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf"))
***Latexmk-LuaJITLaTeX [#wfb7e387]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/luajitlatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
   (setq tex-command "latexmk -e '$pdflatex=q/luajitlatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf"))
***Latexmk-XeLaTeX [#gac50540]
 (if (eq system-type 'windows-nt)
     (setq tex-command "rundll32 shell32,ShellExec_RunDLL cmd /c latexmk -e \"$pdflatex=q/xelatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/makeindex %O -o %D %S/\" -norc -gg -pdf")
   (setq tex-command "latexmk -e '$pdflatex=q/xelatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/makeindex %O -o %D %S/' -norc -gg -pdf"))
     (setq tex-command "latexmk -e \"$lualatex=q/lualatex %O -synctex=1 %S/\" -e \"$bibtex=q/bibtexu %O %B/\" -e \"$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/\" -e \"$makeindex=q/upmendex %O -o %D %S/\" -norc -gg -pdflua")
   (setq tex-command "latexmk -e '$lualatex=q/lualatex %O -synctex=1 %S/' -e '$bibtex=q/bibtexu %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -o %D %S/' -norc -gg -pdflua"))

**upbibtex の指定 [#q198d21d]
 (setq bibtex-command "upbibtex")
**bibtexu の指定 [#q198d21d]
 (setq bibtex-command "bibtexu")

**biber の指定 [#o3f4bd25]
 (setq bibtex-command "biber --bblencoding=utf8 -u -U --output_safechars")

**mendex の指定 [#i3950de0]
 (setq makeindex-command "mendex -U")
**upmendex の指定 [#i3950de0]
 (setq makeindex-command "upmendex")

**YaTeX-dvi2-command-ext-alist [#x19206ad]
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))

**dvi2-command (C-c C-t j でタイプセットしたあとで C-c C-t p すると表示される PDF ビューア) [#t737f278]
***SumatraPDF [#d0c29303]
 (setq dvi2-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")

***TeXworks [#v93f2569]
 (if (eq system-type 'darwin)
     (setq dvi2-command "/Applications/TeXworks.app/Contents/MacOS/TeXworks")
   (setq dvi2-command "texworks"))

***TeXstudio [#y5d1ba30]
 (if (eq system-type 'darwin)
     (setq dvi2-command "/Applications/texstudio.app/Contents/MacOS/texstudio --pdf-viewer-only")
   (setq dvi2-command "texstudio --pdf-viewer-only"))

***MuPDF [#n79f13fd]
 (setq dvi2-command "mupdf")

***Firefox (PDF.js) [#r971ee00]
 (if (eq system-type 'windows-nt)
     (setq dvi2-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFileName($args),'\"\"\"');Start-Process firefox -ArgumentList ('-new-window',$p)}\"")
   (setq dvi2-command "firefox -new-window"))

***Chrome/Chromium PDF Viewer (PDFium) [#r552a7fd]
 (if (eq system-type 'windows-nt)
     (setq dvi2-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFullPath($args),'\"\"\"');Start-Process chrome -ArgumentList ('--new-window',$p)}\"")
   (setq dvi2-command "chromium --new-window"))

***Preview [#j3fea9fe]
 (setq dvi2-command "/usr/bin/open -a Preview")
 (setq dvi2-command "open -a Preview")

***Skim [#vb4cc051]
 (setq dvi2-command "/usr/bin/open -a Skim")
 (setq dvi2-command "open -a Skim")

***TeXShop [#w3687acc]
 (setq dvi2-command "/usr/bin/open -a TeXShop")
 (setq dvi2-command "open -a TeXShop")

***Evince [#k6ed9ab5]
 (setq dvi2-command "evince")

***Atril [#vf039437]
 (setq dvi2-command "atril")

***Okular [#uf59e41d]
 (setq dvi2-command "okular --unique")

***zathura [#g500937c]
 (setq dvi2-command "zathura -s -x \"emacsclient --no-wait +%{line} %{input}\"")
 (setq dvi2-command "zathura -x \"emacsclient --no-wait +%{line} %{input}\"")

***qpdfview [#ze129dad]
 (setq dvi2-command "qpdfview --unique")

**tex-pdfview-command (C-c C-t d でタイプセットしたあとで C-c C-t p すると表示される PDF ビューア) [#ia0437ce]
***SumatraPDF [#i2f07080]
 (setq tex-pdfview-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")

***TeXworks [#y4efa0cf]
 (if (eq system-type 'darwin)
     (setq tex-pdfview-command "/Applications/TeXworks.app/Contents/MacOS/TeXworks")
   (setq tex-pdfview-command "texworks"))

***TeXstudio [#wb93592a]
 (if (eq system-type 'darwin)
     (setq tex-pdfview-command "/Applications/texstudio.app/Contents/MacOS/texstudio --pdf-viewer-only")
   (setq tex-pdfview-command "texstudio --pdf-viewer-only"))

***MuPDF [#q15298f3]
 (setq tex-pdfview-command "mupdf")

***Firefox (PDF.js) [#j10835f3]
 (if (eq system-type 'windows-nt)
     (setq tex-pdfview-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFileName($args),'\"\"\"');Start-Process firefox -ArgumentList ('-new-window',$p)}\"")
   (setq tex-pdfview-command "firefox -new-window"))

***Chrome/Chromium PDF Viewer (PDFium) [#k977257b]
 (if (eq system-type 'windows-nt)
     (setq tex-pdfview-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFullPath($args),'\"\"\"');Start-Process chrome -ArgumentList ('--new-window',$p)}\"")
   (setq tex-pdfview-command "chromium --new-window"))

***Preview [#u986e521]
 (setq tex-pdfview-command "/usr/bin/open -a Preview")
 (setq tex-pdfview-command "open -a Preview")

***Skim [#c9ac9d17]
 (setq tex-pdfview-command "/usr/bin/open -a Skim")
 (setq tex-pdfview-command "open -a Skim")

***TeXShop [#g2f83bb4]
 (setq tex-pdfview-command "/usr/bin/open -a TeXShop")
 (setq tex-pdfview-command "open -a TeXShop")

***Evince [#j390cbe8]
 (setq tex-pdfview-command "evince")

***Atril [#vb288c5f]
 (setq tex-pdfview-command "atril")

***Okular [#y8537029]
 (setq tex-pdfview-command "okular --unique")

***zathura [#v709670e]
 (setq tex-pdfview-command "zathura -s -x \"emacsclient --no-wait +%{line} %{input}\"")
 (setq tex-pdfview-command "zathura -x \"emacsclient --no-wait +%{line} %{input}\"")

***qpdfview [#l8d529be]
 (setq tex-pdfview-command "qpdfview --unique")

**use LaTeX2e and AMS-LaTeX [#s49fcef1]

YaTeX 1.78 以降は YaTeX-use-AMS-LaTeX が t になりました.~
デフォルトでは YaTeX-use-AMS-LaTeX の値は t です.
AMS-LaTeX がうまく動作しない場合は YaTeX をロードする前に設定してみてください.(参照 [[その1:https://twitter.com/hiroseyuuji/status/173544126686572544]], [[その2:https://twitter.com/liquid_amber/status/173975511570194432]])

 (setq YaTeX-use-LaTeX2e t)
 (setq YaTeX-use-AMS-LaTeX t)

**font latex hook [#j998f541]
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (require 'font-latex)
              (font-latex-setup))) 
              (font-latex-setup)))

**RefTeX mode [#iabc8ab6]
 (add-hook 'yatex-mode-hook 'turn-on-reftex)

または

 (add-hook 'yatex-mode-hook '(lambda () (reftex-mode t)))

YaTeX の comment region, uncomment region, insert parens region のキーバインドを優先させる場合は以下のようにします.(参照 [[YaTeXとRefTeXの共存:http://ubutun.blogspot.jp/2011/06/yatexreftex.html]])

 (add-hook 'yatex-mode-hook
           '(lambda ()
              (reftex-mode 1)
              (define-key reftex-mode-map (concat YaTeX-prefix ">") 'YaTeX-comment-region)
              (define-key reftex-mode-map (concat YaTeX-prefix "<") 'YaTeX-uncomment-region)
              (define-key reftex-mode-map (concat YaTeX-prefix ")") 'YaTeX-insert-parens-region)))

**auto fill mode [#ua5c62a9]

on の場合
 (add-hook 'yatex-mode-hook '(lambda () (auto-fill-mode t) (setq fill-column 70)))

off の場合
 (add-hook 'yatex-mode-hook '(lambda () (auto-fill-mode -1)))

**color [#ee4c8027]
 ;(setq YaTeX-use-font-lock t)
 ; section color
 ;(setq YaTeX-hilit-sectioning-face '(light時のforecolor/backcolor dark時の forecolor/backcolor))
 ;(setq YaTeX-hilit-sectioning-face '(white/snow3 snow1/snow3))
 (add-hook 'yatex-mode-hook
 '(lambda () (require 'font-latex)
             (font-latex-setup)
             (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]*[[{]")
                     ))))

**outline-minor-mode [#nf399cda]
 (add-hook 'yatex-mode-hook '(lambda () (outline-minor-mode t)))
 (setq-default outline-level 'outline-level)

 (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))))))
**misc mode [#w545e459]
 (add-hook 'yatex-mode-load-hook
           (function
            (lambda ()
              (YaTeX-define-key "w" 'sdic-describe-word)
              (YaTeX-define-key "\C-w" 'YaTeX-switch-mode-menu)))) 
              (YaTeX-define-key "\C-w" 'YaTeX-switch-mode-menu))))
**math-sign の追加 [#teb10e47]
 (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 ~")
    ))

**テンプレート [#pff757f3]
 ; ~/.LaTeX-templateは新規ファイル作成時に自動挿入するファイル名
 (setq YaTeX-template-file "~/.LaTeX-template")

** \textit{...}など対するフォント変更 [#j27c726d]
なぜか,\textbf{...}以外の\textXX{...}のフォント変更がうまく働いていないようなので少々 ~/.emacs.d/init.el に追加。ついでに\emph{...}にも対応。

// どなたか、開発元に連絡してくださるかたがいらっしゃいませんか。
// よろしくお願いします。

 ;ここはすでにyatex19.elに記述されてる
 ;(add-to-list 'YaTeX-hilit-patterns-alist
 ;      '(YaTeX-19-region-section-type "\\\\textbf\\>" bold))
 (add-to-list 'YaTeX-hilit-patterns-alist
 	     '(YaTeX-19-region-section-type "\\\\textgt\\>" bold))
 (add-to-list 'YaTeX-hilit-patterns-alist
 	     '(YaTeX-19-region-section-type "\\\\textit\\>" italic))
 (add-to-list 'YaTeX-hilit-patterns-alist
 	     '(YaTeX-19-region-section-type "\\\\textsl\\>" italic))
 (add-to-list 'YaTeX-hilit-patterns-alist
 	     '(YaTeX-19-region-section-type "\\\\emph\\>" italic))
 (add-to-list 'YaTeX-hilit-patterns-alist
 	     '(YaTeX-19-region-section-type "\\\\texttt\\>" tt))
 
**SumatraPDF との連携 (forward search) → YaTeX 1.77.5 以降は SumatraPDF の forward search に対応しています [#ra95ecfb]

**SumatraPDF との連携 (forward search) [#ra95ecfb]

***SumatraPDF を前面に表示したい場合 [#x4a4f83a]

 (defun sumatrapdf-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "sumatrapdf"
       nil
       "rundll32"
       "shell32,ShellExec_RunDLL"
       "SumatraPDF"
       "-reuse-instance"
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       "-forward-search"
       (buffer-name)
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c s") 'sumatrapdf-forward-search)))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq dvi2-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")
 (setq tex-pdfview-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")

SumatraPDF の forward search は C-c s または M-x sumatrapdf-forward-search RET をタイプします.
を設定して C-c C-g を入力すれば SumatraPDF で forward seasrch ができます.

***SumatraPDF を前面に表示したくない場合 [#d9c64d40]

 (defun fwdsumatrapdf-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
     (process-query-on-exit-flag
      (start-process
       "fwdsumatrapdf"
       nil
       "fwdsumatrapdf"
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       (buffer-name)
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))))))
 

 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c f") 'fwdsumatrapdf-forward-search)))

fwdsumatrapdf は [[SumatraPDF/fwdsumatrapdf]] の fwdsumatrapdf.exe を使用します.~
fwdsumatrapdf は [[SumatraPDF/fwdsumatrapdf]] にあるものを使用します.
forward search は C-c f または M-x fwdsumatrapdf-forward-search RET をタイプします.

fwdsumatrapdf での forward search は C-c f または M-x fwdsumatrapdf-forward-search RET をタイプします.
**Skim との連携 (forward search) [#f978a43b]

**Skim との連携 (forward search) → YaTeX 1.77.5 以降は Skim の forward search に対応しています [#f978a43b]
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq dvi2-command "open -a Skim")
 (setq tex-pdfview-command "open -a Skim")

 (defun skim-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process  
       "displayline"
       nil
       "/Applications/Skim.app/Contents/SharedSupport/displayline"
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       buffer-file-name))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c s") 'skim-forward-search)))
を設定して C-c C-g を入力すれば Skim で forward seasrch ができます.

displayline での forward search は C-c s または M-x skim-forward-search RET をタイプします.

-[[skim-forward-search.el:https://gist.github.com/ryseto/5710882]], [[EmacsとSkim.appでTeX・PDFシンクロ:http://d.hatena.ne.jp/setoryohei/20110102/1294003836]] も参照してください.

**Evince との連携 (forward and inverse search) [#g214bbe8]

-https://gitorious.org/latex-math-preview/synctex-for-evince-yatex/source/synctex-for-evince-yatex.el
-https://gitlab.com/latex-math-preview/synctex-for-evince-yatex
-http://kurasawa.c.ooco.jp/ubuntu.html#emacs

**Evince との連携 (forward search) → YaTeX 1.77.5 以降は Evince の forward search に対応しています [#h118b5e5]
**Evince との連携 (forward search) [#h118b5e5]

 (defun evince-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "fwdevince"
       nil
       "fwdevince"
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
       (number-to-string (save-restriction
                           (widen)
                           (count-lines (point-min) (point))))
       (buffer-name)))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c e") 'evince-forward-search)))
[[Evince/fwdevince]] をインストールして

fwdevince は [[Evince/fwdevince]] の fwdevince を使用します.~
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq dvi2-command "evince")
 (setq tex-pdfview-command "evince")

fwdevince での forward search は C-c e または M-x evince-forward-search RET をタイプします.
を設定して C-c C-g を入力すれば Evince で forward seasrch ができます.

//-[[SyncTeXの設定。 Emacs(YaTeX) + Evince:http://ubutun.blogspot.jp/2012/05/synctex-emacsyatex-evince.html]] も参照してください.

**Evince との連携 (inverse search) [#tfced2b6]

Evince の inverse search については [[Emacs#Evince との連携#inverse search>Emacs#vecb4fd9]] を参照してください.~
Evince の inverse search については [[Emacs#Evince との連携#inverse search>Emacs#vecb4fd9]] を参照してください.

**Okular との連携 (forward search) [#o8772291]

 (defun okular-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "okular"
       nil
       "okular"
       "--unique"
       (concat (expand-file-name
                (concat (file-name-sans-extension (or YaTeX-parent-file
                                                      (save-excursion
                                                        (YaTeX-visit-main t)
                                                        buffer-file-name)))
                        ".pdf"))
               "#src:"
               (number-to-string (save-restriction
                                   (widen)
                                   (count-lines (point-min) (point))))
               (buffer-file-name))))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c o") 'okular-forward-search)))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq dvi2-command "okular --unique")
 (setq tex-pdfview-command "okular --unique")
 (with-eval-after-load 'yatexprc
   (defun YaTeX-preview-jump-line ()
     "Call jump-line function of various previewer on current main file"
     (interactive)
     (save-excursion
       (save-restriction
         (widen)
         (let*((pf (or YaTeX-parent-file
                       (save-excursion (YaTeX-visit-main t) (buffer-file-name))))
               (pdir (file-name-directory pf))
               (bnr (substring pf 0 (string-match "\\....$" pf)))
               ;(cf (file-relative-name (buffer-file-name) pdir))
               (cf (buffer-file-name)) ;2016-01-08
               (buffer (get-buffer-create " *preview-jump-line*"))
               (line (count-lines (point-min) (point-end-of-line)))
               (previewer (YaTeX-preview-default-previewer))
               (cmd (cond
                     ((string-match "Skim" previewer)
                      (format "%s %d '%s.pdf' '%s'"
                              YaTeX-cmd-displayline line bnr cf))
                     ((string-match "evince" previewer)
                      (format "%s '%s.pdf' %d '%s'"
                              "fwdevince" bnr line cf))
                     ((string-match "sumatra" previewer)
                      (format "%s \"%s.pdf\" -forward-search \"%s\" %d"
                              previewer bnr cf line))
                     ((string-match "zathura" previewer)
                      (format "%s --synctex-forward '%d:0:%s' '%s.pdf'"
                              previewer line cf bnr))
                     ((string-match "qpdfview" previewer)
                      (format "%s '%s.pdf#src:%s:%d:0'"
                              previewer bnr cf line))
                     ((string-match "okular" previewer)
                      (format "%s '%s.pdf#src:%d %s'"
                              previewer bnr line (expand-file-name cf)))
                     )))
           (YaTeX-system cmd "jump-line" 'noask pdir))))))

okular での forward search は C-c o または M-x okular-forward-search RET をタイプします.
を設定して C-c C-g を入力すれば Okular で forward seasrch ができます.

**zathura との連携 (forward search) [#j4034f6b]

 (defun zathura-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "zathura"
       nil
       "zathura"
       "--synctex-forward"
       (concat (number-to-string (save-restriction
                                   (widen)
                                   (count-lines (point-min) (point))))
               ":0:"
               (buffer-name))
       (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c z") 'zathura-forward-search)))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq dvi2-command "zathura -x \"emacsclient --no-wait +%{line} %{input}\"")
 (setq tex-pdfview-command "zathura -x \"emacsclient --no-wait +%{line} %{input}\"")
 (with-eval-after-load 'yatexprc
   (defun YaTeX-preview-jump-line ()
     "Call jump-line function of various previewer on current main file"
     (interactive)
     (save-excursion
       (save-restriction
         (widen)
         (let*((pf (or YaTeX-parent-file
                       (save-excursion (YaTeX-visit-main t) (buffer-file-name))))
               (pdir (file-name-directory pf))
               (bnr (substring pf 0 (string-match "\\....$" pf)))
               ;(cf (file-relative-name (buffer-file-name) pdir))
               (cf (buffer-file-name)) ;2016-01-08
               (buffer (get-buffer-create " *preview-jump-line*"))
               (line (count-lines (point-min) (point-end-of-line)))
               (previewer (YaTeX-preview-default-previewer))
               (cmd (cond
                     ((string-match "Skim" previewer)
                      (format "%s %d '%s.pdf' '%s'"
                              YaTeX-cmd-displayline line bnr cf))
                     ((string-match "evince" previewer)
                      (format "%s '%s.pdf' %d '%s'"
                              "fwdevince" bnr line cf))
                     ((string-match "sumatra" previewer)
                      (format "%s \"%s.pdf\" -forward-search \"%s\" %d"
                              previewer bnr cf line))
                     ((string-match "zathura" previewer)
                      (format "%s --synctex-forward '%d:0:%s' '%s.pdf'"
                              previewer line cf bnr))
                     ((string-match "qpdfview" previewer)
                      (format "%s '%s.pdf#src:%s:%d:0'"
                              previewer bnr cf line))
                     ((string-match "okular" previewer)
                      (format "%s '%s.pdf#src:%d %s'"
                              previewer bnr line (expand-file-name cf)))
                     )))
           (YaTeX-system cmd "jump-line" 'noask pdir))))))

zathura での forward search は C-c z または M-x zathura-forward-search RET をタイプします.
を設定して C-c C-g を入力すれば zathura で forward seasrch ができます.

**qpdfview との連携 (forward search) [#ic7abdb4]
**qpdfview との連携 (forward search) [#c86f086b]

 (defun qpdfview-forward-search ()
   (interactive)
   (progn
     (process-kill-without-query
      (start-process
       "qpdfview"
       nil
       "qpdfview"
       "--unique"
       (concat (expand-file-name
                (concat (file-name-sans-extension (or YaTeX-parent-file
                                                      (save-excursion
                                                        (YaTeX-visit-main t)
                                                        buffer-file-name)))
                        ".pdf"))
               "#src:"
               (buffer-name)
               ":"
               (number-to-string (save-restriction
                                   (widen)
                                   (count-lines (point-min) (point))))
               ":0")))))
 
 (add-hook 'yatex-mode-hook
           '(lambda ()
              (define-key YaTeX-mode-map (kbd "C-c q") 'qpdfview-forward-search)))
 (setq YaTeX-inhibit-prefix-letter t)
 (setq YaTeX-dvi2-command-ext-alist
       '(("TeXworks\\|texworks\\|texstudio\\|mupdf\\|SumatraPDF\\|Preview\\|Skim\\|TeXShop\\|evince\\|atril\\|xreader\\|okular\\|zathura\\|qpdfview\\|Firefox\\|firefox\\|chrome\\|chromium\\|MicrosoftEdge\\|microsoft-edge\\|Adobe\\|Acrobat\\|AcroRd32\\|acroread\\|pdfopen\\|xdg-open\\|open\\|start" . ".pdf")))
 (setq dvi2-command "qpdfview --unique")
 (setq tex-pdfview-command "qpdfview --unique")

qpdfview での forward search は C-c q または M-x qpdfview-forward-search RET をタイプします.
を設定して C-c C-g を入力すれば qpdfview で forward seasrch ができます.

*その他(改造など) [#q5a5c09f]

**includegraphicsにclipオプションを追加 [#r1cf7758]
yatexadd.elのYaTeX:includegraphicsの最後を下記のように変更
 (if (string= "" str) "[clip]"
      (concat "[" str ",clip]")) ;

**コマンドおよび環境などの入力支援のカスタマイズ [#c42fc6d4]
yatexhks.elにカスタマイズした関数を記述しておけばYaTeXの入力支援に利用できる.
例えば,enumitemパッケージのenumerate環境でresumeオプションを使うか常に問う場合は次のような関数を記述しておけばよい.
 (defun YaTeX:enumerate ()
  ((let (op (if y-or-n-p "resume オプションを使いますか? ")
	    "resume"))
   (if (> (length op) 0)
       (concat "[" op "]"))))

**コンパイルプログラムの使い分け [#ga20e87e]
普段は ptex2pdf (uplatex + dvipdfmx) を使っていても,投稿先のスタイルシートによっては pdflatex を前提としているものがあります.~
普段は upLaTeX (ptex2pdf) を使っていても,投稿先のスタイルシートによっては pdfLaTeX を前提としているものがあります.
TeX ソースの先頭行に例えば,
 %#!pdflatex
と書いておくと、普段は typeset の時に ptex2pdf (uplatex + dvipdfmx) で処理されていても,この場合だけ pdflatex で処理してくれます.
と書いておくと、普段はタイプセットの時に upLaTeX (ptex2pdf) で処理されていても,この場合だけ pdfLaTeX で処理してくれます.

記述例をいくつかあげると,Windows では、
記述例をいくつかあげると,Windows では
 %#!ptex2pdf -u -l -ot "-kanji=utf8 -no-guess-input-enc -synctex=1" hogehoge
としたり,GNU/Linux, UNIXでは,
としたり,macOS, Linux では
 %#!ptex2pdf -u -l -ot "-synctex=1" hogehoge
としたりできます.

*関連リンク [#fcad5d2d]

-[[私的 YaTeX 事始め:http://mtino1594.hatenablog.com/entry/2019/04/07/200000]]
-[[YaTeXのカスタマイズおよびevinceとの連携:http://startlinux.ninja-mania.jp/yatex/index.html]]
-[[ Emacs26.1を入れてみる(その15)EmacsでLaTeX:https://blogs.yahoo.co.jp/t_terui/66967449.html]], [[ Emacs26.1を入れてみる(その16)YaTeX にアウトラインモードを追加:https://blogs.yahoo.co.jp/t_terui/66970175.html]]
-[http://www-he.scphys.kyoto-u.ac.jp/member/shotakaha/dokuwiki/doku.php?id=toolbox:emacs:yatex:start YaTeX [ShotakahaDokuWiki]]
-[http://qiita.com/ynakayama/items/706ae9e59c1b6fd3e3d2 モダンな日本語 TeX 環境を整える]
-[http://ubutun.blogspot.jp/2014/06/ubuntu-1404emacs.html Ubuntu 14.04でのEmacsの設定]
-[[Linux Mintを導入する(8):http://note.chiebukuro.yahoo.co.jp/detail/n220718]]
-[[NTEmacsでYaTeXによるフルパス内に日本語を含む .tex のタイプセット:http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12106481462]], [[(再)NTEmacsでYaTeXによるフルパス内に日本語を含む .tex のタイプセット:http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11106826351]]
-[[文字コード毎の tex-command and bibtex-command 切り替え for yatex:http://meq-yo.sblo.jp/article/64863422.html]]
-[[YaTeX の設定と利用法:http://www.proton.jp/main/latex/yatex.html]]
-[[yatex-modeでPDFプレビュー:http://d.hatena.ne.jp/hico_horiuchi/20130329/1364563601]]
-[[YaTeXモードで句読点と全角英数字を変換して保存するEmacsLisp:http://d.hatena.ne.jp/FromAtom/20130112/1358009997]]
-[[Emacsへフォーカス:http://d.hatena.ne.jp/eggtoothcroc/20121106/p1]]
-[[YaTeXメモ:http://d.hatena.ne.jp/su48us/20120731]]
-[[YaTeX でタイプセットからプレビューまで一括して行う:http://ryo1miya.hatenablog.com/entry/20120614/1339697123]]
-[[Yatex導入:http://blogs.yahoo.co.jp/echotechsoft/158191.html]]
-[[Emacs+YaTex-導入編:http://d.hatena.ne.jp/tukasa1919/20110507/1304783879]]
-[[Emacs+YaTeX-使い方編:http://d.hatena.ne.jp/tukasa1919/20110509/1304937507]]
-[[YaTeX reftex-modeの動作について:http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=308]]
-[[YaTeX reftex-modeの動作について:https://okumuralab.org/tex/mod/forum/discuss.php?d=308]]
-[[YaTeX World (野鳥わぁるど):http://www.nk.rim.or.jp/~naru/yatex/]] (成宮 隆之 さん)
-[[yatex キー操作:http://www.cosmo.sci.hokudai.ac.jp/~kk/emacs/yatex_key.html]]
-[[LaTeX on Linux with Emacs, YaTeX, BibTeX, RefTeX:http://www.eis.t.u-tokyo.ac.jp/~hara/tex/tex.html]] (原 貴弘 さん)
-[[YaTeXとRefTeXの共存:http://ubutun.blogspot.com/2011/06/yatexreftex.html]]
-[[SyncTeXの設定。 Emacs(YaTeX) + Evince:http://ubutun.blogspot.jp/2012/05/synctex-emacsyatex-evince.html]]
-[[SweaveでエディタとDVIビューア間の相互移動 - RjpWiki:http://www.okada.jp.org/RWiki/?Sweave%A4%C7%A5%A8%A5%C7%A5%A3%A5%BF%A4%C8DVI%A5%D3%A5%E5%A1%BC%A5%A2%B4%D6%A4%CE%C1%EA%B8%DF%B0%DC%C6%B0]]
-[[MacWiki - CarbonEmacsAndYatex:http://macwiki.sourceforge.jp/wiki/index.php/CarbonEmacsAndYatex]]
-[[RjpWiki:SweaveでエディタとDVIビューア間の相互移動]]
-[[EmacsとSkim.appでTeX・PDFシンクロ:http://d.hatena.ne.jp/setoryohei/20110102/1294003836]]
-http://d.hatena.ne.jp/munepi/searchdiary?word=YaTeX
-[[yatex-modeになったときにマイナーモードcdlatexを起動する:http://d.hatena.ne.jp/daharu/20111106/1320562641]]
-[[YaTeX の気になる所:http://d.hatena.ne.jp/setoryohei/20120127/1327680856]]
-[[File #osqaqi27-12106:http://www.sourcepod.com/osqaqi27-12106]]
-[[TeX Memo [Internet Archive]:http://web.archive.org/web/20100601184838/http://homepages.inf.ed.ac.uk/s0675112/tex_memo.html]]

**リリース情報 [#w889e1b2]

[[yatex: tags:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/tags]] を参照.

**[[ChangeLog:https://www.yatex.org/yatex-new.txt]] [#n0cf386c]

-[[YaTeX Mercurial Repositories:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/]]
--[[コミットログ:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/shortlog/]]
--[[変更点:https://www.yatex.org/hgrepos/hgweb.cgi/yatex/file/tip/yatex.new]]
-[[YaTeX Git Repositories:https://www.yatex.org/gitbucket/yuuji/yatex]]
--[[コミットログ:https://www.yatex.org/gitbucket/yuuji/yatex/commits/devel]]
--[[変更点:https://www.yatex.org/gitbucket/yuuji/yatex/blob/devel/yatex.new]]
-[[What's new in Japanese:https://www.yatex.org/yatex-new.txt]]
-http://twilog.org/hiroseyuuji/search?word=YaTeX