校对源自大型多文件 Sweave 项目的书籍、论文或报告的 PDF

发布于 2024-10-24 06:00:32 字数 374 浏览 3 评论 0原文

我是可重复研究的忠实粉丝。 我经常使用 make、Sweave、LaTeX 和 R 来生成大型研究报告(即大量 Sexpr() 命令以及大量图表和表格)。

显然,R CMD Sweave 在编译时识别出 R 代码块中的某些错误。 但生成的 PDF 仍然可能包含不良结果。 我有一些校对此类文档的策略,但我有兴趣向其他人学习。

问题:

  1. 在基于大型多文件 Sweave 项目生成 PDF 时,是否有人有任何与校对和质量控制相关的提示或技巧?
  2. 您在生成 PDF 时遇到的最常见错误是什么?
  3. 如何有效地识别生成的 PDF 中的错误?
  4. 如何在 PDF 和 Rnw 源代码之间有效地移动?

I'm a big fan of reproducible research.
I often use make, Sweave, LaTeX, and R to produce large research reports (i.e., lots of Sexpr() commands and heaps of graphs and tables).

Obviously, R CMD Sweave identifies certain errors in the R code chunks at compilation.
But the resulting PDF can still contain undesirable results.
I have a few strategies for proofreading such documents, but I was interested in learning from others on SO.

Questions:

  1. Does anyone have any tips or tricks related to proofreading and quality control when it comes to producing PDFs based on large multi-file Sweave projects?
  2. What are the most common errors that you encounter in resulting PDFs?
  3. How do you efficiently identify errors in the resulting PDF?
  4. How do you efficiently move between PDF and Rnw source?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一生独一 2024-10-31 06:00:32

我不确定这是否是您正在寻找的,但如果您使用 emacs、auctex 和 emacs 讲统计,大多数这些问题都可以变得不那么重要。它们都可以在 Linux 存储库中找到,并且有一个适用于 Windows 的预编译二进制文件 http:// /vgoulet.act.ulaval.ca/en/emacs/windows/

Emacs 的主要优点是,您可以在一个窗口中显示 R 控制台,在另一个窗口中显示 tex 源,并且 Emacs 会同时突出显示 LaTeX 和 R正确地放在 .Rnw 文件中,这确实帮助我发现了错误。您还可以评估 R 代码的小区域,并预览 TeX 中的表格和其他对象。这绝对是一个学习曲线,但我已经使用它大约一个月了,它已经使我的可重复研究效率提高了 50% 左右。一旦您了解了一些键绑定,它就会很直观,另一个优点是 Emacs 为几乎所有编程语言提供了模式,这意味着花在学习如何使用它上的时间会一次又一次地得到回报。
更具体地说
1) Emacs 在此提供语法突出显示和预览区域的帮助,以确保特定表的格式符合您的要求,不会丢失行或标签。
2)我通常会犯拼写错误和包丢失错误,因为我倾向于在多次遍历文档时进行统计分析。
3)Emacs会发现任何编译错误,并且可以在编译整个文档之前单独测试R代码。
4) 如果你使用命令 sweave (Alt+m, s),然后编译到 LateX ctrl c,(通常两次以获得标签和 Bibtex 正确)另一个 ctrl c 将打开 PDF 进行查看(遗憾的是,它打不开)默认情况下在 emacs 中,但我想有人已经做了一个包或脚本来启用此功能)。

我确信其他人可以举更多例子来说明 emacs 对于此类工作的有用性,正如我所说,我刚刚开始使用它(但它比我使用过的所有其他 tex 和 R 程序要好得多 - Technix 中心,基尔,纺织制造商)。

我不会向那些不懂 R 和 LaTeX 的人推荐它,但如果你会的话,它会让你的效率提高几个数量级。

I'm not sure if this is what you are looking for, but most of these problems can be made less of an issue if you use emacs, auctex and emacs speaks statistics. They are all available in linux repositories, and there is a precompiled binary available for Windows http://vgoulet.act.ulaval.ca/en/emacs/windows/

The major advantage of Emacs is that you can have your R console in one window, your tex source in another, and Emacs will highlight both LaTeX and R appropriately in an .Rnw file, which is something that really helped me to spot mistakes. You can also evaluate small regions of the R code, and preview tables and other objects in TeX. Its definitely a learning curve, but i have been using it for about a month and it has already made me about 50% more productive in my reproducible research. The keybindings are intuitive once you know some, and another advantage is that Emacs provides modes for almost every programming lanaguage under the sun, which means that the time spent in learning how to use it will repay itself over and over.
More specifically
1) Emacs helps here with syntax highlighting and preview regions to ensure that particular tables are formatted as you want, with no missing rows or labels.
2) I normally end up making spelling mistakes and package missing errors as i tend to develop my statistical analyses in a number of passes over the document.
3) Emacs will spot any compilation errors, and the R code can all be tested individually before the whole document is compiled.
4) If you use the command to sweave (Alt+m, s), then compile to LateX ctrl c, (normally twice to get labels and Bibtex right) another ctrl c will open up the PDF for viewing (sadly, it doesnt open in emacs by default, but i imagine that there is a package or script that someone has done to enable this).

I'm sure others can give more examples of the usefulness of emacs for this kind of work, as i said, i am just beginning with it (but its far better than all the other tex and R programs i have used - Technix center, kile, texmaker).

I wouldn't recommend it for someone who didnt know both R and LaTeX, but if you do, it makes you orders of magnitude more efficient.

以可爱出名 2024-10-31 06:00:32

好问题。一个人看到的问题在很大程度上取决于他正在做的工作。对我来说,最常见的非 R 问题是拼写错误、不正常的数字、有错误的方程等等。

我发现的最可靠、独立于平台且最有效的错误捕获策略是经常导出为 PDF。稍微工作一下;查看。多做一点工作,再检查一次。是的,这对于一个大型项目来说很糟糕。不过,像cacheSweave这样的工具可以提供帮助。底线是:如果您在各处工作了 2 个小时并遇到错误,那么尝试追踪它就没有什么乐趣了。

对于大型项目,当我在块 287(或其他内容)中遇到错误时,花点时间整理 R 代码会有所帮助。从上下文中我通常可以找出错误所在并快速导航到那里。另一种选择是为代码块命名,但谁愿意想出 591 个名称呢?

对于方程/数学问题,具有内联预览的编辑器会很有帮助。 LyX 有这个,AUCTeX 也有。这样,如果您在某处错过了斜杠或逗号,那么您会立即知道,因为预览被搞乱了。这节省了我无数的时间。

LyX 不存在图像内联预览(由 Sweave 生成​​),但 Org 模式存在。出于同样的原因,这是一个非常非常强大的优势。

这些天我真的没有遇到任何其他 LaTeX 错误,因为 LyX 是所见即所得的;它无需我就可以生成 LaTeX。组织模式在这方面也很好。 AUCTeX 和 ESS 有工具可以提供帮助并且还可以(Rstudio 看起来很相似)。我还没玩过 Eclipse 等。非常。

有些问题如果不研究日志就很难注意到,比如脱离页面的 URL(或表格等)。经常使用 PDF。工作并检查。这是最好的方法,除非接受另一双眼睛的同行评审。

顺便说一句,LyX 使用 aspell 对非 LaTeX 标记进行拼写检查。

Good question. The problems a person sees depends heavily on the work (s)he's doing. For me, the most common non-R problems are misspellings, figures out of whack, an equation with a mistake in it, and so forth.

The most reliable, platform-independent, and efficient error-catching strategy I have found is to export to PDF frequently. Work a little bit; check. Work a little bit more, check again. Yes, this sucks for a large project. Tools like cacheSweave can help, though. The bottom line - if you work for 2 hours all over the place and get an error, it's no fun trying to track it down.

With a large project, when I get an error in chunk 287 (or something) it helps to take a moment and tangle the R code. From context I can usually figure out where the error is and navigate there quickly. Another option would be to name the code chunks, but who wants to come up with 591 names?

For the equation/math problems an editor with in-line preview is helpful. LyX has this, and AUCTeX does too. That way, if you miss a slash or comma somewhere then you know instantly because the preview is messed up. This has saved me countless hours.

The inline-preview of images (generated by Sweave) doesn't exist for LyX, but it does for Org-mode. This is a very, very strong plus for the same reason.

I don't really have any other LaTeX errors these days because LyX is WYSIWYM; it generates the LaTeX without me. Org-mode is good in this regard, as well. AUCTeX and ESS have tools to help and are OK (Rstudio looks similar). I haven't played with Eclipse et al. very much.

Some problems are really hard to notice without studying the logs, like a URL (or table, etc.) running off the page. PDF frequently. Work and check. It's the best way, barring peer review by another set of eyes.

By the way, LyX spell-checks the non-LaTeX markup with aspell.

谁与争疯 2024-10-31 06:00:32

当您指的是“校对”时,我不确定您到底在寻找什么,但我发现在 LaTeX 中,通常使用大量 \marginpar 语句来记录任何问题,以便将来修复,效果很好。另一种方法是使用优秀的 PDF 阅读器在最终的 PDF 中添加注释,但如果重新编译,注释就会消失。

对于我们这些因使用 Emacs 而遇到永久性手部问题的人来说(不是开玩笑!),Sweave 的基于 GUI 的选项是 Eclipse。它可以设置为一键编译 Sweave,进行适当的代码突出显示,并具有常见的 IDE 功能。 Eclipse 还通过包提供拼写检查,这有助于校对。不确定是否可以将拼写检查器设置为仅校对 LaTeX 部分,这将是理想的选择。

RStudio 也是一个新的但有趣的选项。

I'm not sure exactly what you're looking for when you mean "proofreading," but I find that in LaTeX in general using lots of \marginpar statements to note any problems for future fixing works well. The other way to do it would be to put notes in the final PDF using a good PDF reader, but then they go away if you re-compile.

For those of us who have permanent hand troubles from using Emacs (not kidding!), the GUI-based option for Sweave is Eclipse. It can be set up for one-click compiling of Sweave, does proper code highlighting, and has the usual IDE features. Eclipse also offers spell check via a package, which helps with proofreading. Not sure if you can set the spell checker to only proof the LaTeX portions, which would be the ideal.

RStudio is a new but interesting option as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文