2017-12-03 18 views
0

emacs 25.3에서 최신 마스터 버전 0.200.10.x Spacemacs을 사용했습니다. 나는 사용자가 사용하고자하는 라텍스 컴파일러를 정의 할 수 있도록하기 위해 orgmodedocumentation으로 권장되는 함수를 구현하려고 시도했다. 함수를 구현했지만 작동하지 않는 것 같습니다. 라텍스 컴파일 단계는 파일 헤더에 지정된대로 xelatex 대신 pdflatex을 계속 사용합니다. 그래서 나는 어떤 조정을해야하는지 알아 내려고 노력했습니다.orgmode 헤더를 기반으로 latex 컴파일러를 변경하는 함수를 받아들이도록 Emacs`spacemacs '가져 오기

;; 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) 

Spacemacs 문제에 따라 list 나는 spacemacs-configuration-layers에 변화가 a la을 설정해야 :

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)