Emacs > YaTeX

◆目次◆
YaTeX(野鳥)は GNU Emacs / XEmacs の TeX モードです.
yatex: tags を参照.
Emacs 24.3 を使用している場合は YaTeX 1.77 以降を使用してください.

YaTeX 1.77, 1.76 で Windows の Emacs で C-c ' でエラー行にジャンプしません.
YaTeX 1.75, 1.74 では C-c ' でエラー行にジャンプします.
Linux ではこの現象は起きませんでした.
YaTeX 1.77, 1.76 では Windows の Emacs で C-c ' でエラー行にジャンプしなくなったので Emacs が固まらなくなりました.
YaTeX 1.75, 1.74 で Windows の Emacs で C-c ' でエラー行にジャンプして C-c C-t j でタイプセットしようとすると Emacs が固まります.
Linux ではこの現象は起きませんでした.
(defun YaTeX-typeset-buffer (&optional pp)
の中に
(switch-to-buffer cb)) ;for 19
(YaTeX-typeset cmd YaTeX-typeset-buffer nil nil ppcmd)
(put 'dvi2-command 'region nil)))
といった記述があります.
これを以下のように修正すれば回避できます.
(switch-to-buffer cb)) ;for 19
(if (eq (process-status "LaTeX") 'run)
(progn (kill-process (get-process "LaTeX"))
(sleep-for 0 100)))
(YaTeX-typeset cmd YaTeX-typeset-buffer nil nil ppcmd)
(put 'dvi2-command 'region nil)))
~/.emacs.d/init.el に以下のように関数 call-compile を定義してエラー行にジャンプしてタイプセットする場合に M-x call-compile としても回避できます.
(defun call-compile ()
(interactive)
(require 'yatexprc)
(if (eq (process-status "LaTeX") 'run)
(progn (kill-process (get-process "LaTeX"))
(sleep-for 0 100)))
(YaTeX-typeset-buffer))
エラーが発生した場合にジャンプできなくてもいい場合はオプションに -interaction=nonstopmode を追加しても OK です.
(setq tex-command "powershell -Command \"& {$b = [System.IO.Path]::GetFileNameWithoutExtension($args);$texopt = [System.String]::Concat('\"\"\"','-kanji=utf8 -guess-input-enc -synctex=1 -interaction=nonstopmode -sjis-terminal -jobname=',[char]0x27,$b,[char]0x27,'\"\"\"');ptex2pdf -l -ot $texopt $b}\"")
Emacs 24.3 は last-input-char, last-command-char が削除されています.
YaTeX 1.77 以降にアップデートしてください.
YaTeX 1.77 で Canna を使用している場合のみ YaTeX-use-jmode-hook が有効になりました (→ Activate YaTeX-use-jmode-hook only if using canna.)
SKK を使用していて YaTeX-use-jmode-hook が t の場合に数式モードで固まることがあるようです.
YaTeX をロードするよりも前に
(setq YaTeX-use-jmode-hook nil)
を記述することで回避できるようです.→ (参照 その1, その2)
emacs for gnupack をインストールします.
YaTeX リリース版 または YaTeX テスト版 をダウンロードして展開します.
展開したフォルダ名を yatex に変更します.
Emacs を起動して
C-x C-f ~/
で,ホームディレクトリ (~/) の場所を確認します.
yatex フォルダをコピーして ~/.emacs.d/site-lisp/ にペーストします.(~/.emacs.d/site-lisp/ が無ければ新規に作成します.)
~
└─.emacs.d
└─site-lisp
└─yatex
~/.emacs.d/init.el に設定を記述します.
以下の設定では TeX Live 2013 以降, W32TeX [2013/03/11] 以降に含まれている ptex2pdf を使用しています.
pdfplatex.bat を使用する場合は TeXworks の pdfplatex.bat を使用してください.
W32TeX の場合は latexmk の実行には Strawberry Perl が必要です.
;;
;; 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-use-LaTeX2e t)
(setq YaTeX-use-AMS-LaTeX t)
(setq YaTeX-dvi2-command-ext-alist
'(("TeXworks\\|SumatraPDF\\|evince\\|okular\\|firefox\\|chrome\\|AcroRd32\\|pdfopen" . ".pdf")))
(setq tex-command "powershell -Command \"& {$b = [System.IO.Path]::GetFileNameWithoutExtension($args);$texopt = [System.String]::Concat('\"\"\"','-kanji=utf8 -guess-input-enc -synctex=1 -sjis-terminal -jobname=',[char]0x27,$b,[char]0x27,'\"\"\"');ptex2pdf -l -ot $texopt $b}\"")
;(setq tex-command "ptex2pdf -l -u -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
;(setq tex-command "pdfplatex.bat")
;(setq tex-command "pdfplatex2.bat")
;(setq tex-command "pdfuplatex.bat")
;(setq tex-command "pdfuplatex2.bat")
;(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/platex -kanji=utf8 -guess-input-enc -synctex=1/\" -e \"$bibtex=q/pbibtex -kanji=utf8/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
;(setq tex-command "latexmk -e \"$latex=q/platex -kanji=utf8 -guess-input-enc -synctex=1/\" -e \"$bibtex=q/pbibtex -kanji=utf8/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvips=q/dvips %O -z -f %S | convbkmk -g > %D/\" -e \"$ps2pdf=q/ps2pdf.bat %O %S %D/\" -norc -gg -pdfps")
;(setq tex-command "latexmk -e \"$latex=q/uplatex -kanji=utf8 -no-guess-input-enc -synctex=1/\" -e \"$bibtex=q/upbibtex/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi")
;(setq tex-command "latexmk -e \"$latex=q/uplatex -kanji=utf8 -no-guess-input-enc -synctex=1/\" -e \"$bibtex=q/upbibtex/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/\" -e \"$ps2pdf=q/ps2pdf.bat %O %S %D/\" -norc -gg -pdfps")
;(setq tex-command "latexmk -e \"$pdflatex=q/pdflatex -synctex=1/\" -e \"$bibtex=q/bibtex/\" -e \"$makeindex=q/makeindex/\" -norc -gg -pdf")
;(setq tex-command "latexmk -e \"$pdflatex=q/lualatex -synctex=1/\" -e \"$bibtex=q/bibtexu/\" -e \"$makeindex=q/texindy/\" -norc -gg -pdf")
;(setq tex-command "latexmk -e \"$pdflatex=q/luajitlatex -synctex=1/\" -e \"$bibtex=q/bibtexu/\" -e \"$makeindex=q/texindy/\" -norc -gg -pdf")
;(setq tex-command "latexmk -e \"$pdflatex=q/xelatex -synctex=1/\" -e \"$bibtex=q/bibtexu/\" -e \"$makeindex=q/texindy/\" -norc -gg -xelatex")
(setq bibtex-command (cond ((string-match "uplatex\\|-u" tex-command) "upbibtex")
((string-match "platex" tex-command) "pbibtex -kanji=utf8")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "bibtexu")
((string-match "pdflatex\\|latex" tex-command) "bibtex")
(t "pbibtex -kanji=utf8")))
(setq makeindex-command (cond ((string-match "uplatex\\|-u" tex-command) "mendex -U")
((string-match "platex" tex-command) "mendex -U")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "texindy")
((string-match "pdflatex\\|latex" tex-command) "makeindex")
(t "mendex -U")))
(setq dvi2-command "texworks")
;(setq dvi2-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")
;(setq dvi2-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFileName($args),'\"\"\"');Start-Process firefox -ArgumentList ('-new-window',$p)}\"")
;(setq dvi2-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFullPath($args),'\"\"\"');Start-Process chrome -ArgumentList ('--new-window',$p)}\"")
(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)))
(defun fwdsumatrapdf-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 w") '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)))
SumatraPDF の forward search は C-c s または M-x sumatrapdf-forward-search をタイプします.
SumatraPDF を前面に表示したくない場合は SumatraPDF#fwdsumatrapdf.exe の fwdsumatrapdf.exe を使用します.
fwdsumatrapdf の forward search は C-c w または M-x fwdsumatrapdf-forward-search をタイプします.
SumatraPDF の inverse search については Emacs#SumatraPDF との連携#inverse search を参照してください.
YaTeX-inhibit-prefix-letter は t に設定しました.
YaTeX-kanji-code を nil 以外にすると指定した文字コード以外の TeX ファイルも指定した文字コードで保存されてしまうので nil を指定することをおすすめします.
最新版の W32TeX では ptexenc を用いて文字コードを自動判別するので,通常は Emacs の自動判別機能を使用して,変更する必要があればその場合に手動で変更すればよいと思います.
W32TeX の pdfplatex.bat は自動判別でタイプセットを行うので,異なる文字コードの文書が混ざっていてもタイプセットしてくれます.
を参照.
MacEmacs JP または Emacs.app をインストールします.
YaTeX リリース版 または YaTeX テスト版 をダウンロードして展開します.
展開したフォルダ名を yatex に変更します.
Emacs を起動して
C-x C-f ~/
で,ホームディレクトリ (~/) の場所を確認します.
yatex フォルダをコピーして ~/.emacs.d/site-lisp/ にペーストします.(~/.emacs.d/site-lisp/ が無ければ新規に作成します.)
~
└─.emacs.d
└─site-lisp
└─yatex
動作未確認です.
Mac OS X 10.6.6, Carbon Emacs 22.3 では動作するようです. → YaTeXのMacOSXでの動作について報告と質問
Preview で PDF ファイルが自動更新されない場合は Skim を使用してください. → emacs( 22.3 )でYaTeXが再び使えた
Skim で PDF ファイルが自動更新されない場合は YaTeX と Skim を組み合わせて使う1つの例を参照してください.
~/.emacs.d/init.el に設定を記述します.
以下の設定では TeX Live 2013 以降に含まれている ptex2pdf を使用しています.
pdfplatex を使用する場合は TeXworks の pdfplatex を使用します.
;;
;; 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-use-LaTeX2e t)
(setq YaTeX-use-AMS-LaTeX t)
(setq YaTeX-dvi2-command-ext-alist
'(("Preview\\|TeXShop\\|TeXworks\\|Skim\\|mupdf\\|xpdf\\|Firefox\\|Adobe" . ".pdf")))
(setq tex-command "/usr/texbin/ptex2pdf -l -ot '-synctex=1'")
;(setq tex-command "/usr/texbin/ptex2pdf -l -u -ot '-synctex=1'")
;(setq tex-command "/usr/local/bin/pdfplatex")
;(setq tex-command "/usr/local/bin/pdfplatex2")
;(setq tex-command "/usr/local/bin/pdfuplatex")
;(setq tex-command "/usr/local/bin/pdfuplatex2")
;(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/platex -synctex=1/' -e '$bibtex=q/pbibtex/' -e '$makeindex=q/mendex/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
;(setq tex-command "/usr/texbin/latexmk -e '$latex=q/platex -synctex=1/' -e '$bibtex=q/pbibtex/' -e '$makeindex=q/mendex/' -e '$dvips=q/dvips %O -z -f %S | convbkmk -g > %D/' -e '$ps2pdf=q/ps2pdf %O %S %D/' -norc -gg -pdfps")
;(setq tex-command "/usr/texbin/latexmk -e '$latex=q/uplatex -synctex=1/' -e '$bibtex=q/upbibtex/' -e '$makeindex=q/mendex/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
;(setq tex-command "/usr/texbin/latexmk -e '$latex=q/uplatex -synctex=1/' -e '$bibtex=q/upbibtex/' -e '$makeindex=q/mendex/' -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 -synctex=1/' -e '$bibtex=q/bibtex/' -e '$makeindex=q/makeindex/' -norc -gg -pdf")
;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/lualatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -pdf")
;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/luajitlatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -pdf")
;(setq tex-command "/usr/texbin/latexmk -e '$pdflatex=q/xelatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -xelatex")
(setq bibtex-command (cond ((string-match "uplatex\\|-u" tex-command) "/usr/texbin/upbibtex")
((string-match "platex" tex-command) "/usr/texbin/pbibtex")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "/usr/texbin/bibtexu")
((string-match "pdflatex\\|latex" tex-command) "/usr/texbin/bibtex")
(t "/usr/texbin/pbibtex")))
(setq makeindex-command (cond ((string-match "uplatex\\|-u" tex-command) "/usr/texbin/mendex")
((string-match "platex" tex-command) "/usr/texbin/mendex")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "/usr/texbin/texindy")
((string-match "pdflatex\\|latex" tex-command) "/usr/texbin/makeindex")
(t "/usr/texbin/mendex")))
(setq dvi2-command "/usr/bin/open -a Preview")
;(setq dvi2-command "/usr/bin/open -a Skim")
;(setq dvi2-command "/usr/bin/open -a TeXShop")
;(setq dvi2-command "/usr/bin/open -a TeXworks")
;(setq dvi2-command "/usr/bin/open -a Firefox")
(setq dviprint-command-format "/usr/bin/open -a \"Adobe Reader\" `echo %s | sed -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)))
YaTeX リリース版 または YaTeX テスト版 をダウンロードして展開します.
展開したフォルダ名を yatex に変更します.
Emacs を起動して
C-x C-f ~/
で,ホームディレクトリ (~/) の場所を確認します.
yatex フォルダをコピーして ~/.emacs.d/site-lisp/ にペーストします.(~/.emacs.d/site-lisp/ が無ければ新規に作成します.)
~
└─.emacs.d
└─site-lisp
└─yatex
~/.emacs.d/init.el に設定を記述します.
以下の設定では TeX Live 2013 以降に含まれている ptex2pdf を使用しています.
pdfplatex を使用する場合は TeXworks の pdfplatex を使用します.
;;
;; 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-use-LaTeX2e t)
(setq YaTeX-use-AMS-LaTeX t)
(setq YaTeX-dvi2-command-ext-alist
'(("texworks\\|evince\\|okular\\|zathura\\|qpdfview\\|pdfviewer\\|mupdf\\|xpdf\\|firefox\\|chromium\\|acroread\\|pdfopen" . ".pdf")))
(setq tex-command "ptex2pdf -l -ot '-synctex=1'")
;(setq tex-command "ptex2pdf -l -u -ot '-synctex=1'")
;(setq tex-command "pdfplatex")
;(setq tex-command "pdfplatex2")
;(setq tex-command "pdfuplatex")
;(setq tex-command "pdfuplatex2")
;(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/platex -synctex=1/' -e '$bibtex=q/pbibtex/' -e '$makeindex=q/mendex/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
;(setq tex-command "latexmk -e '$latex=q/platex -synctex=1/' -e '$bibtex=q/pbibtex/' -e '$makeindex=q/mendex/' -e '$dvips=q/dvips %O -z -f %S | convbkmk -g > %D/' -e '$ps2pdf=q/ps2pdf %O %S %D/' -norc -gg -pdfps")
;(setq tex-command "latexmk -e '$latex=q/uplatex -synctex=1/' -e '$bibtex=q/upbibtex/' -e '$makeindex=q/mendex/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi")
;(setq tex-command "latexmk -e '$latex=q/uplatex -synctex=1/' -e '$bibtex=q/upbibtex/' -e '$makeindex=q/mendex/' -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 -synctex=1/' -e '$bibtex=q/bibtex/' -e '$makeindex=q/makeindex/' -norc -gg -pdf")
;(setq tex-command "latexmk -e '$pdflatex=q/lualatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -pdf")
;(setq tex-command "latexmk -e '$pdflatex=q/luajitlatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -pdf")
;(setq tex-command "latexmk -e '$pdflatex=q/xelatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -xelatex")
(setq bibtex-command (cond ((string-match "uplatex\\|-u" tex-command) "upbibtex")
((string-match "platex" tex-command) "pbibtex")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "bibtexu")
((string-match "pdflatex\\|latex" tex-command) "bibtex")
(t "pbibtex")))
(setq makeindex-command (cond ((string-match "uplatex\\|-u" tex-command) "mendex")
((string-match "platex" tex-command) "mendex")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "texindy")
((string-match "pdflatex\\|latex" tex-command) "makeindex")
(t "mendex")))
(setq dvi2-command "evince")
;(setq dvi2-command "okular --unique")
;(setq dvi2-command "zathura -s -x \"emacsclient --no-wait +%{line} %{input}\"")
;(setq dvi2-command "qpdfview --unique")
;(setq dvi2-command "pdfviewer")
;(setq dvi2-command "texworks")
;(setq dvi2-command "mupdf")
;(setq dvi2-command "firefox -new-window")
;(setq dvi2-command "chromium --new-window")
(setq dviprint-command-format "acroread `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)))))
(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 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)))
(defun pdfviewer-forward-search ()
(interactive)
(progn
(process-kill-without-query
(start-process
"pdfviewer"
nil
"pdfviewer"
(concat "file:"
(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-name))))))
(add-hook 'yatex-mode-hook
'(lambda ()
(define-key YaTeX-mode-map (kbd "C-c p") 'pdfviewer-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)))
さまざまな機能がありますので、まずは少しだけ。
(setq YaTeX-inhibit-prefix-letter t) を使用してください.
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.
YaTeX-inhibit-prefix-letter は t と nil でキーバインドが異なります.
Ubuntu, Debian, Vine の最新版はデフォルトで t となっており,YaTeX の作者も t を推奨しています (YaTeX ML [yatex:04567] を参照).
変更の理由は YaTeX が使用していたキーバインドがユーザー向けに予約されていた C-c letter に設定されていたためと思われます.
かわりに、C-c のあとにコントロール文字か数字文字か特定の句読点文字が続く キー列を定義する。 これらのキー列は、メジャーモード用に予約してある。
Emacs のすべてのモードをこの慣習に従うように変換するのは たいへんな作業量であった。 この慣習を捨てさるとその作業をむだにしてしまい、ユーザーにも不便である。
メニュー [YaTeX] 入力 (setq YaTeX-inhibit-prefix-letter t) 機能 Process -> LaTeX C-c C-t 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 プレビュー Process -> BibTeX C-c C-t b BibTeX Process -> makeindex C-c C-t i MakeIndex Process -> lpr C-c C-t l LPR (印刷) C-c ' エラー行にジャンプ
emacs@YaTeX [ ◛ ][ ▭ ][ ✕ ]
ファイル 編集 オプション バッファ ツール YaTeX Ref ヘルプ
...
-U\--- yatex.tex Top L1 (やてふ Ref)--------------------------------
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
(setq YaTeX-inhibit-prefix-letter t) を使用してください.
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.
メニュー [YaTeX] 入力 (setq YaTeX-inhibit-prefix-letter t) 補完 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}
を補完してくれます.
入力 タイプセット方式 M-x set-variable RET tex-command RET "latexmk" RET latexmk M-x set-variable RET tex-command RET "pdfplatex" RET pdfplatex M-x set-variable RET tex-command RET "pdfplatex2" RET pdfplatex2 M-x set-variable RET tex-command RET "pdfuplatex" RET pdfuplatex M-x set-variable RET tex-command RET "pdfuplatex2" RET pdfuplatex2 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
入力 M-x describe-variable RET tex-command RET
『野鳥』クイックリファレンス もご覧下さい.
詳細は Yet Another tex-mode for Emacs - Table of Contents をご覧下さい.
瀬戸 亮平 さんの YaTeX demo で YaTeX の機能が紹介されています.
ヘッダー部分に用途別に追加してみました.テンプレートとしても使えるかもしれません.
%% -*- coding: utf-8-unix -*-
%#!platex -kanji=utf8 -guess-input-enc -synctex=1 hogehoge && dvipdfmx hogehoge.dvi
% #!tasklist /fi "IMAGENAME eq AcroRd32.exe" /nh | findstr "AcroRd32.exe" > nul && pdfopen --rxi --file hogehoge.pdf && pdfclose --rxi --file hogehoge.pdf & platex hogehoge && dvipdfmx hogehoge.dvi && pdfopen --rxi --file hogehoge.pdf
% #!uplatex -kanji=utf8 -no-guess-input-enc -synctex=1 hogehoge && dvipdfmx hogehoge.dvi
%#BIBTEX pbibtex -kanji=utf8 hogehoge
% #BIBTEX upbibtex hogehoge
%#MAKEINDEX mendex -U hogehoge
%#LPR dvipdfmx hogehoge.dvi && 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
% #LPR dvipdfmx hogehoge.dvi && acroread.bat /p hogehoge.pdf
% #LPR dvips -Ppdf -f hogehoge.dvi | lpr
\documentclass{jsarticle}
\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\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 ) else ( "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 )
あくまで一例です。ぜひ修正、加筆お願いします。
(add-to-list 'load-path "~/.emacs.d/site-lisp/yatex")
(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)
(setq YaTeX-inhibit-prefix-letter t) を使用してください.
(setq YaTeX-inhibit-prefix-letter nil) は,非推奨 (deprecated) です.
(setq YaTeX-inhibit-prefix-letter t)
YaTeX-kanji-code を nil 以外にすると指定した文字コード以外の TeX ファイルも指定した文字コードで保存されてしまうので nil を指定することをおすすめします.
;;; nil=YaTeX-kanji-code が nil なら coding-system に感知しない ;;; 0=no-converion -> Emacs内部で使用されている文字コード (Emacs23では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)
(setq tex-command "powershell -Command \"& {$b = [System.IO.Path]::GetFileNameWithoutExtension($args);$texopt = [System.String]::Concat('\"\"\"','-kanji=utf8 -guess-input-enc -synctex=1 -sjis-terminal -jobname=',[char]0x27,$b,[char]0x27,'\"\"\"');ptex2pdf -l -ot $texopt $b}\"")
(setq tex-command "ptex2pdf -l -u -ot \"-kanji=utf8 -no-guess-input-enc -synctex=1\"")
(setq tex-command "pdfplatex.bat")
(setq tex-command "pdfplatex2.bat")
(setq tex-command "pdfuplatex.bat")
(setq tex-command "pdfuplatex2.bat")
(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 bibtex-command (cond ((string-match "uplatex\\|-u" tex-command) "upbibtex")
((string-match "platex" tex-command) "pbibtex -kanji=utf8")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "bibtexu")
((string-match "pdflatex\\|latex" tex-command) "bibtex")
(t "pbibtex -kanji=utf8")))
(setq bibtex-command "pbibtex -kanji=utf8")
(setq bibtex-command "upbibtex")
(setq bibtex-command "bibtex")
(setq bibtex-command "bibtexu")
(setq bibtex-command "biber")
(setq makeindex-command (cond ((string-match "uplatex\\|-u" tex-command) "mendex -U")
((string-match "platex" tex-command) "mendex -U")
((string-match "lualatex\\|luajitlatex\\|xelatex" tex-command) "texindy")
((string-match "pdflatex\\|latex" tex-command) "makeindex")
(t "mendex -U")))
(setq makeindex-command "mendex -U")
(setq makeindex-command "makeindex")
(setq makeindex-command "texindy")
(setq dvi2-command "texworks")
(setq dvi2-command "rundll32 shell32,ShellExec_RunDLL SumatraPDF -reuse-instance")
(setq dvi2-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFileName($args),'\"\"\"');Start-Process firefox -ArgumentList ('-new-window',$p)}\"")
(setq dvi2-command "powershell -Command \"& {$p = [System.String]::Concat('\"\"\"',[System.IO.Path]::GetFullPath($args),'\"\"\"');Start-Process chrome -ArgumentList ('--new-window',$p)}\"")
(setq dvi2-command "/usr/bin/open -a Preview")
(setq dvi2-command "/usr/bin/open -a Skim")
(setq dvi2-command "/usr/bin/open -a TeXShop")
(setq dvi2-command "/usr/bin/open -a TeXworks")
(setq dvi2-command "/usr/bin/open -a Firefox")
(setq dvi2-command "evince")
(setq dvi2-command "okular --unique")
(setq dvi2-command "zathura -s -x \"emacsclient --no-wait +%{line} %{input}\"")
(setq dvi2-command "qpdfview --unique")
(setq dvi2-command "pdfviewer")
(setq dvi2-command "mupdf")
(setq dvi2-command "firefox -new-window")
(setq dvi2-command "chromium --new-window")
(setq YaTeX-dvi2-command-ext-alist
'(("TeXworks\\|SumatraPDF\\|evince\\|okular\\|firefox\\|chrome\\|AcroRd32\\|pdfopen" . ".pdf")))
(setq YaTeX-dvi2-command-ext-alist
'(("Preview\\|TeXShop\\|TeXworks\\|Skim\\|mupdf\\|xpdf\\|Firefox\\|Adobe" . ".pdf")))
(setq YaTeX-dvi2-command-ext-alist
'(("texworks\\|evince\\|okular\\|zathura\\|qpdfview\\|pdfviewer\\|mupdf\\|xpdf\\|firefox\\|chromium\\|acroread\\|pdfopen" . ".pdf")))
AMS-LaTeX がうまく動作しない場合は YaTeX をロードする前に設定してみてください.(参照 その1, その2)
(setq YaTeX-use-LaTeX2e t) (setq YaTeX-use-AMS-LaTeX t)
(add-hook 'yatex-mode-hook
'(lambda ()
(require 'font-latex)
(font-latex-setup)))
(add-hook 'yatex-mode-hook 'turn-on-reftex)
または
(add-hook 'yatex-mode-hook '(lambda () (reftex-mode t)))
YaTeX の comment region, uncomment region のキーバインドを優先させる場合は以下のようにします.
(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)))
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)))
;(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]*[[{]")
))))
(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))))))
(add-hook 'yatex-mode-load-hook
(function
(lambda ()
(YaTeX-define-key "w" 'sdic-describe-word)
(YaTeX-define-key "\C-w" 'YaTeX-switch-mode-menu))))
(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 ~")
))
■ $HOME/.latexmkrc またはカレントディレクトリの latexmkrc, .latexmkrc を読み込まない場合 (Windows の場合)
(setq tex-command "latexmk -e \"$latex=q/platex -kanji=utf8 -guess-input-enc -synctex=1/\" -e \"$bibtex=q/pbibtex -kanji=utf8/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi") (setq tex-command "latexmk -e \"$latex=q/platex -kanji=utf8 -guess-input-enc -synctex=1/\" -e \"$bibtex=q/pbibtex -kanji=utf8/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvips=q/dvips %O -z -f %S | convbkmk -g > %D/\" -e \"$ps2pdf=q/ps2pdf.bat %O %S %D/\" -norc -gg -pdfps") (setq tex-command "latexmk -e \"$latex=q/uplatex -kanji=utf8 -no-guess-input-enc -synctex=1/\" -e \"$bibtex=q/upbibtex/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvipdf=q/dvipdfmx %O -o %D %S/\" -norc -gg -pdfdvi") (setq tex-command "latexmk -e \"$latex=q/uplatex -kanji=utf8 -no-guess-input-enc -synctex=1/\" -e \"$bibtex=q/upbibtex/\" -e \"$makeindex=q/mendex -U/\" -e \"$dvips=q/dvips %O -z -f %S | convbkmk -u > %D/\" -e \"$ps2pdf=q/ps2pdf.bat %O %S %D/\" -norc -gg -pdfps") (setq tex-command "latexmk -e \"$pdflatex=q/pdflatex -synctex=1/\" -e \"$bibtex=q/bibtex/\" -e \"$makeindex=q/makeindex/\" -norc -gg -pdf") (setq tex-command "latexmk -e \"$pdflatex=q/lualatex -synctex=1/\" -e \"$bibtex=q/bibtexu/\" -e \"$makeindex=q/texindy/\" -norc -gg -pdf") (setq tex-command "latexmk -e \"$pdflatex=q/luajitlatex -synctex=1/\" -e \"$bibtex=q/bibtexu/\" -e \"$makeindex=q/texindy/\" -norc -gg -pdf") (setq tex-command "latexmk -e \"$pdflatex=q/xelatex -synctex=1/\" -e \"$bibtex=q/bibtexu/\" -e \"$makeindex=q/texindy/\" -norc -gg -xelatex")
■ $HOME/.latexmkrc またはカレントディレクトリの latexmkrc, .latexmkrc を読み込まない場合 (OS X, Linux の場合)
(setq tex-command "latexmk -e '$latex=q/platex -synctex=1/' -e '$bibtex=q/pbibtex/' -e '$makeindex=q/mendex/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi") (setq tex-command "latexmk -e '$latex=q/platex -synctex=1/' -e '$bibtex=q/pbibtex/' -e '$makeindex=q/mendex/' -e '$dvips=q/dvips %O -z -f %S | convbkmk -g > %D/' -e '$ps2pdf=q/ps2pdf %O %S %D/' -norc -gg -pdfps") (setq tex-command "latexmk -e '$latex=q/uplatex -synctex=1/' -e '$bibtex=q/upbibtex/' -e '$makeindex=q/mendex/' -e '$dvipdf=q/dvipdfmx %O -o %D %S/' -norc -gg -pdfdvi") (setq tex-command "latexmk -e '$latex=q/uplatex -synctex=1/' -e '$bibtex=q/upbibtex/' -e '$makeindex=q/mendex/' -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 -synctex=1/' -e '$bibtex=q/bibtex/' -e '$makeindex=q/makeindex/' -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/lualatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/luajitlatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -pdf") (setq tex-command "latexmk -e '$pdflatex=q/xelatex -synctex=1/' -e '$bibtex=q/bibtexu/' -e '$makeindex=q/texindy/' -norc -gg -xelatex")
■ $HOME/.latexmkrc またはカレントディレクトリの latexmkrc, .latexmkrc を読み込む場合
(setq tex-command "latexmk") (setq tex-command "latexmk -gg -pdfdvi") (setq tex-command "latexmk -gg -pdfps") (setq tex-command "latexmk -pvc -gg -pdfdvi") (setq tex-command "latexmk -pvc -gg -pdfps")
; ~/.LaTeX-templateは新規ファイル作成時に自動挿入するファイル名 (setq YaTeX-template-file "~/.LaTeX-template")
なぜか,\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))
(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)))
SumatraPDF の forward search は C-c s または M-x sumatrapdf-forward-search をタイプします.
(defun fwdsumatrapdf-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 w") 'fwdsumatrapdf-forward-search)))
fwdsumatrapdf は SumatraPDF#fwdsumatrapdf.exe の fwdsumatrapdf.exe を使用します.
fwdsumatrapdf での forward search は C-c w または M-x fwdsumatrapdf-forward-search をタイプします.
(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)))
displayline での forward search は C-c s または M-x skim-forward-search をタイプします.
(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)))
fwdevince は Evince - TeX Wiki の fwdevince を使用します.
fwdevince での forward search は C-c e または M-x evince-forward-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)))
okular での forward search は C-c o または M-x okular-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)))
qpdfview での forward search は C-c q または M-x qpdfview-forward-search をタイプします.
(defun pdfviewer-forward-search ()
(interactive)
(progn
(process-kill-without-query
(start-process
"pdfviewer"
nil
"pdfviewer"
(concat "file:"
(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-name))))))
(add-hook 'yatex-mode-hook
'(lambda ()
(define-key YaTeX-mode-map (kbd "C-c p") 'pdfviewer-forward-search)))
pdfviewer での forward search は C-c p または M-x pdfviewer-forward-search をタイプします.
yatexadd.elのYaTeX:includegraphicsの最後を下記のように変更
(if (string= "" str) "[clip]"
(concat "[" str ",clip]")) ;
普段は ptex2pdf (platex + dvipdfmx) を使っていても,投稿先のスタイルシートによっては pdflatex を前提としているものがあります.TeX ソースの先頭行に例えば,
%#!pdflatex
と書いておくと、普段は typeset の時に ptex2pdf (platex + dvipdfmx) で処理されていても,この場合だけ pdflatex で処理してくれます.
記述例をいくつかあげると,Windows では、
%#!ptex2pdf -l -ot "-kanji=utf8 -guess-input-enc -synctex=1" hogehoge
としたり,GNU/Linux, UNIXでは,
%#!ptex2pdf -l -ot "-synctex=1" hogehoge
としたりできます.