- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将工具链从R + TeXShop重构到我希望是更有效的Sweave-> LaTeX-> SyncteX-> pdfview(skim)通过emacs(具体来说是Aquamacs)AUCTeX模式(带有emacs-speaks-统计信息的偏斜次要模式)。从AUCTeX-> pdfview链中的SyncteX,一切都可以很好地工作,从Sweave到.pdf的一切都可以很好地编译。
当我添加Sweave作为第一步时,麻烦就来了。 .Rnw文件现在成为主要的原始文档,并且它生成的.tex文件只是一个中间步骤。当然,SyncteX锁定的是.tex文件。
我对.emacs文件所做的唯一更改是,注册了两个新命令以从.Rnw构建.pdf。
谁能提供有关如何使emacs使用SyncteX将输出的.pdf同步到.Rnw而不是.tex的建议?
谢谢!
编辑1: 警告:这最终是我整个下午的困惑总结。我与解决方案非常接近,但是最后却被错误挫败了,而我找不到相关的文档。 警告2:今天是我第一次看过emacs内部功能这么深的地方。肯定会有错误或效率低下。
VitoshKa的回答使我大部分都走到了那里。将他的建议添加到我的.emacs文件中(好吧,Preferences.el,但在功能上相同),导致启动时出现Symbol’s value as variable is void: noweb-minor-mode-map
错误,因为Aquamacs似乎先加载了.emacs文件,然后再加载其余的init文件。
我通过在VitoshKa的(require 'ess-site) (require 'ess-eldoc)
之前立即添加(define-key noweb-minor-mode-map (kbd "\C-c \C-c") 'Rnw-command-master)
来解决此问题。不幸的是,Aquamacs附带了已经是二进制文件的ess-swv.elc文件,并强制对M-n P阅读器进行acroread。因此,我在自己的.emacs底部添加了对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)
(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)
(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)
(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 ""))))))))
"Skim" "/Users/myname/text/testing/myfile.pdf": exited abnormally with code 127.
(setenv "PATH" (concat (getenv "PATH") ":" "/Applications/Skim.app/Contents/MacOS"))
。现在,所有内容都可以编译并且没有错误地启动了……但是emacs上的Command-Shift-Click并没有让Skim做出响应(至少它没有给出错误)。 Command-Shift-单击“略读”仍会强制emacs打开.tex文件。
最佳答案
澄清。您希望Rnw文件中的C-c C-c在Sweave(M-n s)的输出上运行AUCTeX命令。
问题在于Auctex不知道它必须对其他文件起作用。这是使它意识到这一点的方法:
(defun Rnw-command-master (&optional override-confirm)
"Run command on the current document.
If a prefix argument OVERRIDE-CONFIRM is given, confirmation will
depend on it being positive instead of the entry in `TeX-command-list'."
(interactive "P")
(let ((TeX-transient-master (concat
(file-name-sans-extension (buffer-file-name))
".tex"))
(TeX-master nil))
(TeX-command (TeX-command-query (TeX-master-file)) 'TeX-master-file
override-confirm)))
(define-key noweb-minor-mode-map (kbd "\C-c \C-c") 'Rnw-command-master)
关于emacs - ESS + AUCTeX +编织。来自.Rnw <-> pdfviewer的SyncteX集成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11060023/
背景 与 SyncTeX您可以在源文档和排版 Material 之间进行向前和向后搜索。更具体地说: 正向搜索是从源文档中的特定位置跳转,例如LaTeX 文件,到排版 Material 中的相应位置,
我正在Mac OS X 10.7.2上使用GNU Emacs 23.3(9.0)。我想使用synctex在.tex和.pdf文件之间跳转。尽管网络上有许多不同的方法,但没有一种能正常工作(我尝试了8种
我有一个用于 tex 编译和 pdf 输出的 angular 6 应用程序。 Ace 编辑器用于创建 tex 文件。它可以使用 pdflatex 实时编译。使用 ng2-pdf-viewer 显示输出
我对 LaTeX 及其发行版非常陌生,所以这可能是一个非常新手的问题。 我正在关注这个tutorial我无法编译该文档。到目前为止的代码非常简单,我认为没有任何拼写错误,而且我在论坛中没有找到类似的问
我只想拥有一个 .tex我用 pdflatex 编译的文件并以 .pdf 结束文件。我不想要所有其他的 .aux , .log和 .synctex.gz文件。 pdflatex对此似乎没有任何论据。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 9 年前。 Improve
我是一名优秀的程序员,十分优秀!