2017-12-03 10 views
0

emacs 25.3で最新マスタバージョン0.200.10.x Spacemacsを使用しました。私はユーザーが使用したいLatexコンパイラを定義できるように、orgmodedocumentationで推奨されている関数を実装しようとしていました。私はその機能を実装しましたが、うまくいかないようです。ラテックスのコンパイルステップでは、ファイルヘッダに指定されているようにxelatexの代わりにpdflatexを使用し続けます。だから私はどのような調整をするかを考えようとしていました。Emacsの `spacemacs`がorgmodeヘッダに基づいてlatexコンパイラを変更する関数を受け入れるようにしました

;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432 
;; but adapted to use latexmk 4.20 or higher. 
(defun my-auto-tex-cmd() 
    "When exporting from .org with latex, automatically run latex, 
    pdflatex, or xelatex as appropriate, using latexmk." 
    (let ((texcmd))) 
    ;; default command: oldstyle latex via dvi 
    (setq texcmd "latexmk -dvi -pdfps -quiet %f") 
    ;; pdflatex -> .pdf 
    (if (string-match "LATEX_CMD: pdflatex" (buffer-string)) 
     (setq texcmd "latexmk -pdf -quiet %f")) 
    ;; xelatex -> .pdf 
    (if (string-match "LATEX_CMD: xelatex" (buffer-string)) 
     (setq texcmd "latexmk -pdflatex=xelatex -pdf -quiet %f")) 
    ;; LaTeX compilation command 
    (setq org-latex-to-pdf-process (list texcmd))) 

(add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd) 

私はa la設定spacemacs-configuration-layersの変更を加える必要がありSpacemacs問題listによると:

dotspacemacs-configuration-layers '(
    (latex :variables latex-build-command "LaTeX")) 

問題がdotspacemacs-configuration-layersの変更を行うことは、私が適用できていないようだということですファイル固有の設定に基づいて変更します。

spacemacsで上記(my-auto-tex-cmd)のこの機能を実装する正しい方法を知っている人はいますか?

答えて

0

解決策はブログpostで見つかりました。

実際のelispのコードは次のとおり

;; Default packages included in every tex file, pdflatex or xelatex 
(setq org-latex-packages-alist 
     '(("" "graphicx" t) 
     ("" "longtable" nil) 
     ("" "float" nil))) 

;; source: https://lists.gnu.org/archive/html/emacs-orgmode/2013-06/msg00240.html 
(defun my-auto-tex-cmd (backend) 
    "When exporting from .org with latex, 
    automatically run latex, pdflatex, or xelatex as appropriate, 
    using latexmk." 
    (let ((texcmd)) 
    (setq texcmd "latexmk -pdf %f") 
    (if (string-match "LATEX_CMD: pdflatex" (buffer-string)) 
     (progn 
      (setq texcmd "latexmk -pdf -pdflatex='pdflatex -file-line-error --shell-escape -synctex=1' %f") 
      (setq org-latex-default-packages-alist 
       '(("AUTO" "inputenc" t) 
        ("T1" "fontenc" t) 
        (""  "fixltx2e" nil) 
        (""  "wrapfig" nil) 
        (""  "soul"  t) 
        (""  "textcomp" t) 
        (""  "marvosym" t) 
        (""  "wasysym" t) 
        (""  "latexsym" t) 
        (""  "amssymb" t) 
        (""  "hyperref" nil))))) 
    (if (string-match "LATEX_CMD: xelatex" (buffer-string)) 
     (progn 
      (setq texcmd "latexmk -pdflatex='xelatex -file-line-error --shell-escape -synctex=1' -pdf %f") 
      (setq org-latex-default-packages-alist 
       '(("" "fontspec" t) 
        ("" "xunicode" t) 
        ("" "url" t) 
        ;; ("" "rotating" t) 
        ;; ("" "memoir-article-styles" t) 
        ;; ("american" "babel" t) 
        ;; ("babel" "csquotes" t) 
        ;; ("" "listings" nil) 
        ("svgnames" "xcolor" t) 
        ("" "soul" t) 
        ("xetex, colorlinks=true, urlcolor=FireBrick, plainpages=false, pdfpagelabels, bookmarksnumbered" "hyperref" nil) 
       )) 
      (setq org-latex-classes 
       (cons '("memarticle" 
         "\\documentclass[11pt,oneside,article]{memoir}" 
         ("\\section{%s}" . "\\section*{%s}") 
         ("\\subsection{%s}" . "\\subsection*{%s}") 
         ("\\subsubsection{%s}" . "\\subsubsection*{%s}") 
         ("\\paragraph{%s}" . "\\paragraph*{%s}") 
         ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) 
         org-latex-classes)))) 

    (setq org-latex-pdf-process (list texcmd)))) 
(add-hook 'org-export-before-parsing-hook 'my-auto-tex-cmd) 
関連する問題