2

设置:这里是 sessionInfo() :

R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] patchDVI_1.9 knitr_1.5   

loaded via a namespace (and not attached):
[1] compiler_3.0.2 evaluate_0.5.1 formatR_0.9    highr_0.2.1    stringr_0.6.2 
[6] tcltk_3.0.2    tools_3.0.2   

我正在尝试让 emacs 和 AucTeX 将我的 .Rnw 源文件与 evince 同步,以便从源代码和返回的编译文本。

我已经检查了 .tex 源和 PDF 之间的同步是否正常。

我的 .Rnw 文件以:

\documentclass[a4paper,twoside,12pt]{article}
\synctex=1 %% Should force concordance generation
\pdfcompresslevel=0 %% Should force avoidance of PDF compression, which patchDVI does
\pdfobjcompresslevel=0 %% not handle
<<include=FALSE>>= %% Modificaton of what Sweave2kinitr does
## opts_chunk$set(concordance=TRUE, self.contained=TRUE) ## No possible effect
opts_knit$set(concordance=TRUE, self.contained=TRUE) ## Seems reasonable
@
%% \SweaveOpts{concordance=TRUE} %% That's where inspiration came from

考虑以下日志(已编辑不相关部分):

> options("knitr.concordance")
$knitr.concordance
[1] TRUE

> opts_knit$get("concordance")
[1] TRUE
> knit("IntroStat.Rnw")


processing file: IntroStat.Rnw
  |......................                                           |  33%
  ordinary text without R code

  |...........................................                      |  67%
label: unnamed-chunk-1 (with options) 
List of 1
 $ include: logi FALSE

  |.................................................................| 100%
  ordinary text without R code


output file: IntroStat.tex

[1] "IntroStat.tex"
> system("pdflatex -synctex=1 IntroStat.tex")

[编辑无关紧要]

SyncTeX written on IntroStat.synctex.gz.

注意:已经*生成了一个索引!!!!**

Transcript written on IntroStat.log.

让我们再次这样做来修复引用:

> system("pdflatex -synctex=1 IntroStat.tex")

[编辑无关紧要]

Output written on IntroStat.pdf (1 page, 136907 bytes).
SyncTeX written on IntroStat.synctex.gz.

注意:索引已经*生成*再次*!**

Transcript written on IntroStat.log.
> patchDVI("IntroStat.pdf")
[1] "0 patches made. Did you set \\SweaveOpts{concordance=TRUE}?"

* 这个我不明白 *

> patchSynctex("IntroStat.synctex.gz")
[1] "0 patches made. Did you set \\SweaveOpts{concordance=TRUE}?"

* 同上 *

似乎该工具集中的某些东西不能像广告宣传的那样工作:dviPatch 不能识别法律一致性 \specials 或 pdflatex dfoes 不能生成它们。它确实产生了一些东西,但是......

我检查了生成的 PDF 是否使 evince 能够与 .tex 文件同步,但不能在 .Rnw 文件中同步。此外,当在 emacs 中打开 .Rnw 文件时,在 AucTeX 中使用“Cc Cv View”启动查看器确实会启动查看器(在请求打开我授权的服务器之后),但是查看器是空的,我明白了:“TeX-evince-sync-view:在“消息”中找不到 file:///home/charpent/Boulot/Cours/ODF/Chapitres/Ch3-StatMath/IntroStat.Rnw.pdf 的 Evince 实例缓冲。

所以我们这里有第二个问题。

第三种方法是将所有这些透明地集成到 AucTeX 生产链中,但这是另一回事了……

我真的很想将 emacs 作为我用于 R/\LaTeX/Sage 工作的主要工具,而不是切换到 RStudio,它可能不太喜欢 SageTeX 和我每天/每周需要的其他各种工具......

有什么想法吗 ?

4

1 回答 1

2

也许这个https://github.com/jan-glx/patchKnitrSynctex会有所帮助。我在一个简单的文件上尝试过,它确实有效。

至于第二个和第三个问题,我有这个脚本(请注意,我从 jan-glx 获取上述代码;相应地修改路径):

#!/bin/bash
FILE=$1
BASENAME=$(basename $FILE .Rnw)
Rscript -e 'library(knitr); opts_knit$set("concordance" = TRUE); knit("'$1'")'
pdflatex --synctex=1 --file-line-error --shell-escape "${1%.*}"
Rscript -e "source('~/Sources/patchKnitrSynctex.R'); patchKnitrSynctex('${1%.*}.tex')"
ln -s $BASENAME.synctex.gz $BASENAME.Rnw.synctex.gz
ln -s $BASENAME.pdf $BASENAME.Rnw.pdf

这些链接是我绕过“找不到实例(...)”的笨拙方式。

如果您的 .Rnw 在 Emacs 缓冲区中,请转到 shell 缓冲区并调用该脚本。完成后,来自 Emacs 的 Cc Cv 将打开您配置的 PDF 查看器(在我的例子中是正常的)。在 PDF 中,shift + 鼠标左键单击(至少正常)会将您带到 Emacs .Rnw 缓冲区中的正确位置。

这并不理想:如果您跳转到错误,它会转到 .tex,而不是 .Rnw。而且我希望能够通过 Cc Cc 或类似方式调用它(但我不知道如何---elisp ignorance)。

于 2014-05-23T23:33:18.710 回答