필자는 R + TeXShop에서 필자의 툴 체인을 리모델링하여보다 효율적인 Sweave -> LaTeX -> SyncteX -> emacs (Aquamacs, 구체적으로)를 통한 pdfview (skim) AUCTeX 모드 (emacs- 말하기 - 통계학 '스웨터 마이너 모드). 모든 것이 AUCTeX -> pdfview chain의 SyncteX와 잘 작동하며, 모든 것이 Sweave에서 .pdf로 잘 컴파일됩니다.ESS + AUCTeX + Sweave. .Rnw에서 SyncteX 통합 <-> pdfviewer?
첫 번째 단계로 Sweave를 추가하면 문제가 발생합니다. 이제 .Rnw 파일은 주요 원본 문서가되고 생성 한 .tex 파일은 중간 단계에 불과합니다. 물론 SyncteX가 잠그는 .tex 파일입니다.
.emacs 파일에 대한 유일한 변경 사항은 두 개의 새로운 명령을 등록하여 .Rnw에서 .pdf를 빌드하는 것입니다.
emacs가 SyncteX를 사용하여 출력 .pdf를 .tex 대신 .Rnw와 동기화하는 방법에 대한 조언을 제공 할 수 있습니까?
감사합니다.
편집 1 :경고 :이 내 멍청이 주위 오후 요약 었죠. 나는 솔루션에 매우 가깝지만 문서를 찾을 수 없다는 오류 끝에 좌절했다. 경고 2 : 오늘은 이맥스의 내부 동작에 대해이 근처에서 처음으로 본 적이 있습니다. 오류 또는 비효율적 일 가능성이 있습니다.
VitoshKa의 대답은 저에게 가장 많은 도움이되었습니다. Aquacacs가 나머지 init 파일보다 .emacs 파일을로드하는 것처럼 보이기 때문에 내 .emacs (물론 Preferences.el이지만 기능적으로 같은) 파일에 권장 사항을 추가하면 실행시 오류가 발생합니다 (Symbol’s value as variable is void: noweb-minor-mode-map
).
VitoshKa의 (define-key noweb-minor-mode-map (kbd "\C-c \C-c") 'Rnw-command-master)
바로 전에 (require 'ess-site) (require 'ess-eldoc)
을 추가하여이 문제를 해결했습니다. 아쉽게도 Aquamacs는 이미 ess-swv.elc 파일을 바이너리 형식으로 제공하고 M-n P 판독기를 강제로 실행합니다. 그래서 난 내 자신 이맥스의 바닥에 ESS-swv.el 파일의 일부를 다음 편집을 추가 :
(defun ess-makePDFandView()
(interactive)
(setq namestem (substring (buffer-name) 0 (search ".Rnw" (buffer-name))))
(setq tex-filename (concat "\"" namestem "\".tex"))
(setq my-command-string (concat "pdflatex -synctex=1" tex-filename))
(shell-command my-command-string)
(setq my-command-string (concat "/Applications/Skim.app/Contents/MacOS/Skim \"" namestem ".pdf\" &"))
(shell-command my-command-string))
(define-key noweb-minor-mode-map "\M-nv" 'ess-makePDFandView)
중 하나
망간 v를 이맥스에서 올바른 PDF 이름으로 탈지을 시작합니다
지금 이맥스 또는 참조 CC 참조 RET. ..........
emacs의 Command-Shift- 클릭은 filename.Rnw.pdf와 동기화를 시도합니다 (그러나 적어도 오류 메시지는 여전히 pdfviewer에서 올바른 동기화를 유발 함). pdfviewer에서 Command-Shift-Click을 클릭하면 소스로 다시 검색하여 emacs가 filename.tex 파일을 열고 그 파일과 동기화합니다. Fortunately, Cameron Bracken has a fix for that. 그는 단지 이맥스 통합으로 완전히 나아 가지 않습니다.
그래서 난 내 이맥스에 ESS-swv.el이 더 해킹을 추가 :(defun ess-swv-latex-rnw-sync()
"Run LaTeX on the product of Sweave()ing the current file."
(interactive)
(save-excursion
(let* ((namestem (file-name-sans-extension (buffer-file-name)))
(latex-filename (concat namestem ".tex"))
(synctex-filename (concat namestem ".synctex.gz"))
(tex-buf (get-buffer-create " *ESS-tex-output*"))
(patchDVI-command-string (concat "Rscript -e \"library('patchDVI');patchSynctex('" synctex-filename "')\"")))
(message "synctex string: %s" patchDVI-command-string)
(message "Running LaTeX on '%s' ..." latex-filename)
(switch-to-buffer tex-buf)
(call-process "latex" nil tex-buf 1 "-synctex=1 " latex-filename)
(switch-to-buffer (buffer-name))
(display-buffer tex-buf)
(message "Finished running LaTeX")
(message "Running patchDVI...")
(shell-command patchDVI-command-string))))
(define-key noweb-minor-mode-map "\M-nq" 'ess-swv-latex-rnw-sync)
을 생각으로는하지만 부족의 DVI를 패치하고 그것을 동기화를 ...라고! 위와 같이 Command-Shift-Click과 동일한 동작을 반복합니다. 해킹 업으로 돌아갑니다. 나는 ESS-makePDFandView 기능을 제거하고 대신 내 이맥스에 다음과 같은 추가 :
(defun ess-swv-PDF-rnw-sync (&optional pdflatex-cmd)
"From LaTeX file, create a PDF (via 'texi2pdf' or 'pdflatex', ...), by
default using the first entry of `ess-swv-pdflatex-commands' and display it."
(interactive
(list
(let ((def (elt ess-swv-pdflatex-commands 0)))
(completing-read (format "pdf latex command (%s): " def)
ess-swv-pdflatex-commands ; <- collection to choose from
nil 'confirm ; or 'confirm-after-completion
nil nil def))))
(let* ((buf (buffer-name))
(namestem (file-name-sans-extension (buffer-file-name)))
(latex-filename (concat namestem ".tex"))
(tex-buf (get-buffer-create " *ESS-tex-output*"))
(pdfviewer (ess-get-pdf-viewer))
(pdf-status)
(cmdstr-win (format "start \"%s\" \"%s.pdf\""
pdfviewer namestem))
(cmdstr (format "\"%s\" \"%s.pdf\" &" pdfviewer namestem)))
;;(shell-command (concat "pdflatex " latex-filename))
(message "Running '%s' on '%s' ..." pdflatex-cmd latex-filename)
(switch-to-buffer tex-buf)
(setq pdf-status
(call-process pdflatex-cmd nil tex-buf 1 "-synctex=1 "
(if (string= "texi2" (substring pdflatex-cmd 0 5))
;; workaround (bug?): texi2pdf or texi2dvi *fail* to work with full path:
(file-name-nondirectory latex-filename)
latex-filename)))
(if (not (= 0 pdf-status))
(message "** OOPS: error in '%s' (%d)!" pdflatex-cmd pdf-status)
;; else: pdflatex probably ok
(shell-command
(concat (if (and ess-microsoft-p (w32-shell-dos-semantics))
cmdstr-win
cmdstr))))
(switch-to-buffer buf)
(display-buffer tex-buf)))
(define-key noweb-minor-mode-map "\M-nv" 'ess-swv-PDF-rnw-sync)
가 점점 더 가까이 오기를하지만, 우리는 여전히 탈지 통과는 파일 이름을 무엇 auctex 말할 필요가있다.그래서 나는 총알을 치고 auctex-config.el을 편집했다. I가 툴체인의 키 바인딩을 변경
(defun aquamacs-call-viewer (line source)
"Display current output file as PDF at LINE (as in file SOURCE).
Calls `aquamacs-tex-pdf-viewer' to display the PDF file using the
Skim AppleScript protocol."
(cond
((string= (file-name-extension (TeX-active-master)) "Rnw")
(let* ((full-file-name
(expand-file-name
;; as in TeX-view
;; C-c C-c view uses %o (from TeX-expand-list), which
;; is the same.
(concat (file-name-sans-extension (TeX-active-master)) "." (TeX-output-extension))
default-directory))
(full-source-name
(expand-file-name
(concat (file-name-sans-extension (source)) ".Rnw") ;; this is relative to the master
(file-name-directory (full-file-name)))))
(message "full pdf name: %s" full-file-name)
(message "full rnw sournce name: %s" full-source-name)
(do-applescript
(format
"
set theSink to POSIX file \"%s\"
set theSource to POSIX file \"%s\"
tell application \"%s\"
activate
open theSink
tell front document to go to TeX line %d from theSource%s
end tell
"
full-file-name full-source-name aquamacs-tex-pdf-viewer line
;; do not say "showing reading bar false" so users can override in future
(cond ((eq t aquamacs-skim-show-reading-bar)
" showing reading bar true")
((eq nil aquamacs-skim-show-reading-bar)
" showing reading bar false")
(t ""))))))
(t
(let* ((full-file-name
(expand-file-name
;; as in TeX-view
;; C-c C-c view uses %o (from TeX-expand-list), which
;; is the same.
(TeX-active-master (TeX-output-extension))
default-directory))
(full-source-name
(expand-file-name
source ;; this is relative to the master
(file-name-directory full-file-name))))
(message "IN OTHERWISE!! WAT: %s" (file-name-extension (TeX-active-master)))
(do-applescript
(format
"
set theSink to POSIX file \"%s\"
set theSource to POSIX file \"%s\"
tell application \"%s\"
activate
open theSink
tell front document to go to TeX line %d from theSource%s
end tell
"
full-file-name full-source-name aquamacs-tex-pdf-viewer line
;; do not say "showing reading bar false" so users can override in future
(cond ((eq t aquamacs-skim-show-reading-bar)
" showing reading bar true")
((eq nil aquamacs-skim-show-reading-bar)
" showing reading bar false")
(t ""))))))))
그리고 또 하나 개의 최종 테스트를 (주의 사항 : : 나는 기존의에서 주석 aquamacs - - 전화 뷰어 기능 정의 및 교체를 내 자신과 함께 -> 망간 Q - 망간의> sweave에 대한 순서로 망간 (V)가 -> 라텍스 ->보기 ...) 모든 빌드, 아니 오류를 시작 뷰어 [당신이 pdflatex하지 texi2pdf를 사용할 필요가 마지막 단계에서 그주의]
"Skim" "/Users/myname/text/testing/myfile.pdf": exited abnormally with code 127.
그리고 지금 나는 완전히 다시 잃어 버렸다. Skim에 충분히 익숙한 사람?
편집 2 : 오류 127은 단순히 이진 파일에서 찾을 수없는 파일입니다. 어딘가에 나는 그 길을 막아야했다. 그래서 저는 auctex-config.el 상단에 (setenv "PATH" (concat (getenv "PATH") ":" "/Applications/Skim.app/Contents/MacOS"))
을 추가했습니다. 이제는 모든 것이 컴파일되고 오류없이 시작됩니다 ...하지만 Command-Shift-Click on emacs는 Skim이 응답하도록하지 않습니다 (적어도 오류는 없음). Skim을 Command-Shift-Click하면 여전히 이맥스가 .tex 파일을 열도록 강제합니다.
나는 Aquamacs + Skim의 특별한 질문이되었다고 생각합니다. 나머지 상호 작용은 대부분 appescript에 있습니다. 위에서 지적한 핵심 랭크에서 뭔가 명확한 부분을 놓치지 않았다면 말입니다.
대단히 감사합니다. 당신은 대답의 올바른 길로 나를 시작 시켰습니다 ... 나는 생각합니다! 제 편집 1을 보시고 귀하의 추가 지원과 논평에 감사드립니다! – user1459956