[[Emacs]] > YaTeX *[[YaTeX:https://www.yatex.org/]] [#o2c95a66] YaTeX(野鳥)は Emacs の TeX 用メジャーモードです. [[TeX mode>Emacs/TeX mode]] に比べ機能が大幅に拡張されています. もう一つ,有名な拡張として [[AUCTeX]] があり,海外ではこちらがよく使われているようです. 国内では YaTeX の方が人気があり,そのため日本語の情報が Web 上でたくさん見つかります. ---- #contents ---- *YaTeX とは [#q88fd71b] -[[YaTeX (Yet Another TeX 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]] **スクリーンショット [#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(http://www.emacswiki.org/pics/static/LaTeXMathPreviewScreenshot.png,nolink,latex-math-preview.el) *注意点 [#x8b18a1c] **" を入力しようとすると `` が入力される [#ibf10abb] -[[Emacs + YaTeX でダブルクォーテーションを入力:http://tetu1984.hateblo.jp/entry/20090123/1232651566]] YaTeX, TeX mode, AUCTeX では " を入力しようとすると `` が入力されます. `` ではなく " を入力したい場合は C-q " (Ctrl-Q を入力した後で " を入力) とします. *不具合 [#m12f4e1b] **YaTeX 1.78.10 で (setq dvi2-command "okular --unique") を設定して C-c C-g を入力すると forward search ができない [#l5f1c74e] 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 はフルパスになったため,この修正は必要ありません. Okular の format "%s '%s.pdf#src:%d' '%s'" の設定は間違いで,format "%s '%s.pdf#src:%d %s'" に修正する必要があります. ~/.emacs.d/init.el に yatexprc.el の YaTeX-preview-jump-line を修正したものを再設定します. // (expand-file-name cf) はフルパスには関係なくて,フルパスになったの2016-01-08 に修正された // (cf (buffer-file-name)) ではないのかと思います. // ↑ // ご指摘ありがとうございます. // たしかに cf がフルパスに変更されていますね. // Okular 以外のビューアはフルパスでなくても実行できると思うのですが // すべてフルパスになっていても問題ないと思います. (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)))))) *ダウンロード [#g0fb682c] -[[YaTeX リリース版:https://www.yatex.org/]] -[[YaTeX テスト版:http://www.gentei.org/~yuuji/bin/yatexcurrent.cgi]] *インストール [#b2ec65b9] **Emacs 標準のパッケージ管理システムを使用する場合 [#x0d7daaa] [[MELPA:https://melpa.org/]] から最新版がインストールできます. これからインストールするならば,この方法が一番良いでしょう. 初めて MELPA を利用する場合は,[[Getting started:https://melpa.org/#/getting-started]] に従って設定をする必要があります. -https://melpa.org/#/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 ---- ~/.emacs.d/init.el に以下の設定を記述します. (add-to-list 'load-path "~/.emacs.d/site-lisp/yatex") **Windows [#n699538a] Windows の Emacs を使用する場合は YaTeX 1.78.2 以降を使用してください. 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]] をインストールします. ***設定 [#edc51324] ~/.emacs.d/init.el に設定を記述します. プレビューと forward search は [[SumatraPDF]] を使用します. SumatraPDF を前面に表示したくない場合は [[SumatraPDF/fwdsumatrapdf]] の fwdsumatrapdf.exe を使用します. SumatraPDF の inverse search については [[Emacs#SumatraPDF との連携#inverse search>Emacs#a06810d6]] を参照してください. ---- ;; ;; 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 "ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"") ;(setq tex-command "platex-ng -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 -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/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 -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/upmendex %O -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 \"$pdflatex=q/platex-ng %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/upmendex %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") ;(setq tex-command "latexmk -e \"$pdflatex=q/lualatex %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/upmendex %O -o %D %S/\" -norc -gg -pdf") ;(setq tex-command "latexmk -e \"$pdflatex=q/luajitlatex %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/upmendex %O -o %D %S/\" -norc -gg -pdf") ;(setq tex-command "latexmk -e \"$pdflatex=q/xelatex %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/upmendex %O -o %D %S/\" -norc -gg -pdf") (setq bibtex-command "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/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/upbibtex %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 ('--r15','--file',$p)}\"") (defun sumatrapdf-forward-search () (interactive) (progn (process-kill-without-query (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 s") 'sumatrapdf-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:~機能| |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-upLaTeX-pdfdvi)| |Process -> makeindex|C-c C-t i RET|upmendex (Latexmk-upLaTeX-pdfdvi)| |Process -> Preview|C-c C-t p RET RET|PDF プレビュー| |Process -> lpr|C-c C-t l RET|Adobe Acrobat Reader DC で PDF プレビューまたは印刷| ||C-c C-g|SumatraPDF で forward search| ||C-c s または M-x sumatrapdf-forward-search RET|fwdsumatrapdf で forward search| < **OS X [#p7238e02] -[[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]] をインストールします. ***設定 [#qe563613] ~/.emacs.d/init.el に設定を記述します. プレビューと forward search は [[Skim]] を使用します. Skim の inverse search については [[Emacs#Skim との連携#inverse search>Emacs#e9c08b3d]] を参照してください. ---- ;; ;; PATH ;; (setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin")) ;; ;; 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 "/Library/TeX/texbin/ptex2pdf -u -l -ot '-synctex=1'") ;(setq tex-command "/Library/TeX/texbin/platex-ng -synctex=1") ;(setq tex-command "/Library/TeX/texbin/pdflatex -synctex=1") ;(setq tex-command "/Library/TeX/texbin/lualatex -synctex=1") ;(setq tex-command "/Library/TeX/texbin/luajitlatex -synctex=1") ;(setq tex-command "/Library/TeX/texbin/xelatex -synctex=1") ;(setq tex-command "/Library/TeX/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/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi") ;(setq tex-command "/Library/TeX/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/upmendex %O -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 "/Library/TeX/texbin/latexmk -e '$pdflatex=q/platex-ng %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/upmendex %O -o %D %S/' -norc -gg -pdf") ;(setq tex-command "/Library/TeX/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 "/Library/TeX/texbin/latexmk -e '$pdflatex=q/lualatex %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/upmendex %O -o %D %S/' -norc -gg -pdf") ;(setq tex-command "/Library/TeX/texbin/latexmk -e '$pdflatex=q/luajitlatex %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/upmendex %O -o %D %S/' -norc -gg -pdf") ;(setq tex-command "/Library/TeX/texbin/latexmk -e '$pdflatex=q/xelatex %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/upmendex %O -o %D %S/' -norc -gg -pdf") (setq bibtex-command "/Library/TeX/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/upmendex %O -o %D %S/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi") (setq makeindex-command "/Library/TeX/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/upmendex %O -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") ;(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 "/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 Acrobat Reader DC\" `echo %s | gsed -e \"s/\\.[^.]*$/\\.pdf/\"`") (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:~機能| |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-upLaTeX-pdfdvi)| |Process -> makeindex|C-c C-t i RET|upmendex (Latexmk-upLaTeX-pdfdvi)| |Process -> Preview|C-c C-t p RET RET|PDF プレビュー| |Process -> lpr|C-c C-t l RET|Adobe Acrobat Reader DC で PDF プレビューまたは印刷| ||C-c C-g|Skim で forward search| < **Linux [#e2cbcccd] ***設定 [#nec42ee2] ~/.emacs.d/init.el に設定を記述します. fwdevince は [[Evince/fwdevince]] にあるものを使用します. Evince の inverse search については [[Emacs#Evince との連携#inverse search>Emacs#vecb4fd9]] を参照してください. ---- ;; ;; 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 "ptex2pdf -u -l -ot '-synctex=1'") ;(setq tex-command "platex-ng -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 -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/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/upbibtex %O %B/' -e '$biber=q/biber %O --bblencoding=utf8 -u -U --output_safechars %B/' -e '$makeindex=q/upmendex %O -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/platex-ng %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/upmendex %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") ;(setq tex-command "latexmk -e '$pdflatex=q/lualatex %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/upmendex %O -o %D %S/' -norc -gg -pdf") ;(setq tex-command "latexmk -e '$pdflatex=q/luajitlatex %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/upmendex %O -o %D %S/' -norc -gg -pdf") ;(setq tex-command "latexmk -e '$pdflatex=q/xelatex %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/upmendex %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/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/upbibtex %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 "okular --unique") ;(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 "okular --unique") ;(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/\"`") (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 (decode-coding-string (url-unhex-string (un-urlify file)) 'utf-8)) (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)) (x-focus-frame (selected-frame))))) (dbus-register-signal :session nil "/org/gnome/evince/Window/0" "org.gnome.evince.Window" "SyncSource" 'evince-inverse-search) (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 () (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:~機能| |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-upLaTeX-pdfdvi)| |Process -> makeindex|C-c C-t i RET|upmendex (Latexmk-upLaTeX-pdfdvi)| |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|Evince で forward search&br;Okular で forward search&br;zathura で forward search&br;qpdfview で forward search| < *使い方 [#v90b1615] さまざまな機能がありますので、まずは少しだけ。 **キーバインドについての注意(昔からの利用者向け) [#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) Linux Mint, Debian GNU/Linux, Vine Linux に収録されている YaTeX の最新版はデフォルトで t となっており,YaTeX の作者も t を推奨しています (YaTeX ML [yatex:04567] を参照). 変更の理由は YaTeX が使用していたキーバインドがユーザー向けに予約されていた C-c letter に設定されていたためと思われます. ---- [[Emacs Lispのコーディングの慣習:http://www.bookshelf.jp/texi/elisp-manual/21-2-8/jp/elisp_42.html#IDX3219]] より ---- -読者のメジャーモードでは、 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:~機能| |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|親ファイルの再設定| < **補完 [#g3780d28] > |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 "platex-ng -synctex=1" RET|platex-ng| |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] M-x describe-variable RET tex-command RET **その他 [#za795743] 詳細は [[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 --r15 --file hogehoge.pdf && pdfclose --r15 --file hogehoge.pdf & ptex2pdf -u -l hogehoge && pdfopen --r15 --file hogehoge.pdf %#BIBTEX upbibtex hogehoge %#MAKEINDEX upmendex hogehoge %#LPR if exist "C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" ("C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.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,dvipdfmx,ja=standard]{bxjsarticle} \begin{document} Welcom to YaTeX World! \end{document} %%% Local Variables: %%% TeX-master: "hogehoge" %%% End: PDF ファイルでの印刷が多くなってきているので,LPR も PDF ファイルに対応させてみました. パスの通ったところに,acroread.bat というファイル名で以下のスクリプトを保存します. @echo off REM USAGE: acroread.bat [options] filename if exist "C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" ( "C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 ) else ( "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 ) *~/.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) **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 (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 "ptex2pdf -u -l -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"") (setq tex-command "ptex2pdf -u -l -ot \"-synctex=1\"")) ***pLaTeX-ng [#u7f2ca46] (setq tex-command "platex-ng -synctex=1") ***pdfLaTeX [#haa09a91] (setq tex-command "pdflatex -synctex=1") ***LuaLaTeX [#r2c74452] (setq tex-command "lualatex -synctex=1") ***LuaJITLaTeX [#kfa37927] (setq tex-command "luajitlatex -synctex=1") ***XeLaTeX [#h279d9b8] (setq tex-command "xelatex -synctex=1") ***Latexmk-upLaTeX-pdfdvi [#bc88da07] (if (eq system-type 'windows-nt) (setq tex-command "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/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/upbibtex %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")) ***Latexmk-upLaTeX-pdfps [#od385031] (if (eq system-type 'windows-nt) (setq tex-command "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/upmendex %O -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/upmendex %O -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-pLaTeX-ng [#wd79650d] (if (eq system-type 'windows-nt) (setq tex-command "latexmk -e \"$pdflatex=q/platex-ng %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/upmendex %O -o %D %S/\" -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/platex-ng %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/upmendex %O -o %D %S/' -norc -gg -pdf")) ***Latexmk-pdfLaTeX [#n70096b8] (if (eq system-type 'windows-nt) (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/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 "latexmk -e \"$pdflatex=q/lualatex %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/upmendex %O -o %D %S/\" -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/lualatex %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/upmendex %O -o %D %S/' -norc -gg -pdf")) ***Latexmk-LuaJITLaTeX [#wfb7e387] (if (eq system-type 'windows-nt) (setq tex-command "latexmk -e \"$pdflatex=q/luajitlatex %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/upmendex %O -o %D %S/\" -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/luajitlatex %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/upmendex %O -o %D %S/' -norc -gg -pdf")) ***Latexmk-XeLaTeX [#gac50540] (if (eq system-type 'windows-nt) (setq tex-command "latexmk -e \"$pdflatex=q/xelatex %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/upmendex %O -o %D %S/\" -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/xelatex %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/upmendex %O -o %D %S/' -norc -gg -pdf")) **upbibtex の指定 [#q198d21d] (setq bibtex-command "upbibtex") **biber の指定 [#o3f4bd25] (setq bibtex-command "biber --bblencoding=utf8 -u -U --output_safechars") **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"))) **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") ***Skim [#vb4cc051] (setq dvi2-command "/usr/bin/open -a Skim") ***TeXShop [#w3687acc] (setq dvi2-command "/usr/bin/open -a TeXShop") ***Evince [#k6ed9ab5] (setq dvi2-command "evince") ***Okular [#uf59e41d] (setq dvi2-command "okular --unique") ***zathura [#g500937c] (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") ***Skim [#c9ac9d17] (setq tex-pdfview-command "/usr/bin/open -a Skim") ***TeXShop [#g2f83bb4] (setq tex-pdfview-command "/usr/bin/open -a TeXShop") ***Evince [#j390cbe8] (setq tex-pdfview-command "evince") ***Okular [#y8537029] (setq tex-pdfview-command "okular --unique") ***zathura [#v709670e] (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 になりました. 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))) **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)))) **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) [#ra95ecfb] ***SumatraPDF を前面に表示したい場合 [#x4a4f83a] YaTeX 1.78.1 以降は (setq YaTeX-inhibit-prefix-letter 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 dvi2-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance") (setq tex-pdfview-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance") を設定して C-c C-g を入力すれば SumatraPDF で forward seasrch ができます. ***SumatraPDF を前面に表示したくない場合 [#d9c64d40] (defun sumatrapdf-forward-search () (interactive) (progn (process-kill-without-query (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 s") 'sumatrapdf-forward-search))) fwdsumatrapdf は [[SumatraPDF/fwdsumatrapdf]] にあるものを使用します. forward search は C-c s または M-x sumatrapdf-forward-search RET をタイプします. **Skim との連携 (forward search) [#f978a43b] YaTeX 1.78 以降は (setq YaTeX-inhibit-prefix-letter 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 dvi2-command "/usr/bin/open -a Skim") (setq tex-pdfview-command "/usr/bin/open -a Skim") を設定して C-c C-g を入力すれば Skim で forward seasrch ができます. **Evince との連携 (forward and inverse search) [#g214bbe8] -https://gitlab.com/latex-math-preview/synctex-for-evince-yatex -http://homepage2.nifty.com/kurasawa/ubuntu.html#emacs **Evince との連携 (forward search) [#h118b5e5] YaTeX 1.78 以降は [[Evince/fwdevince]] をインストールして (setq YaTeX-inhibit-prefix-letter 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 dvi2-command "evince") (setq tex-pdfview-command "evince") を設定して C-c C-g を入力すれば Evince で forward seasrch ができます. **Evince との連携 (inverse search) [#tfced2b6] Evince の inverse search については [[Emacs#Evince との連携#inverse search>Emacs#vecb4fd9]] を参照してください. **Okular との連携 (forward search) [#o8772291] (setq YaTeX-inhibit-prefix-letter 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 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)))))) を設定して C-c C-g を入力すれば Okular で forward seasrch ができます. **zathura との連携 (forward search) [#j4034f6b] (setq YaTeX-inhibit-prefix-letter 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 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)))))) を設定して C-c C-g を入力すれば zathura で forward seasrch ができます. **qpdfview との連携 (forward search) [#c86f086b] YaTeX 1.78.1 以降は (setq YaTeX-inhibit-prefix-letter 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 dvi2-command "qpdfview --unique") (setq tex-pdfview-command "qpdfview --unique") を設定して C-c C-g を入力すれば qpdfview で forward seasrch ができます. *その他(改造など) [#q5a5c09f] **includegraphicsにclipオプションを追加 [#r1cf7758] yatexadd.elのYaTeX:includegraphicsの最後を下記のように変更 (if (string= "" str) "[clip]" (concat "[" str ",clip]")) ; **コンパイルプログラムの使い分け [#ga20e87e] 普段は upLaTeX (ptex2pdf) を使っていても,投稿先のスタイルシートによっては pdfLaTeX を前提としているものがあります. TeX ソースの先頭行に例えば, %#!pdflatex と書いておくと、普段はタイプセットの時に upLaTeX (ptex2pdf) で処理されていても,この場合だけ pdfLaTeX で処理してくれます. 記述例をいくつかあげると,Windows では、 %#!ptex2pdf -u -l -ot "-kanji=utf8 -no-guess-input-enc -synctex=1" hogehoge としたり,GNU/Linux, UNIXでは, %#!ptex2pdf -u -l -ot "-synctex=1" hogehoge としたりできます. *関連リンク [#fcad5d2d] -[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 World (野鳥わぁるど):http://www.nk.rim.or.jp/~naru/yatex/]] (成宮 隆之 さん) -[[yatex キー操作:http://www.cosmo.sci.hokudai.ac.jp/~kk/emacs/yatex_key.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]] -[[RjpWiki:SweaveでエディタとDVIビューア間の相互移動]] -[[MacWiki - CarbonEmacsAndYatex:http://macwiki.osdn.jp/wiki/index.php/CarbonEmacsAndYatex]] -[[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]] --[[What's new in Japanese:https://www.yatex.org/yatex-new.txt]] -http://twilog.org/hiroseyuuji/search?word=YaTeX -http://twilog.org/ryseto/search?word=YaTeX