问题描述
比方说,我编写了以下微型.Rnw文件:
Let's say I have written the following tiny .Rnw file:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{Sweave}
\usepackage{tikz}
\usepackage{pgf}
\begin{document}
<<>>=
sessionInfo()
@
\end{document}
然后我可以转到R并使用sweave将.Rnw文件转换为.tex文件完成此操作后,就可以调用乳胶解释器了,因为我使用了\usepackage{Sweave}
Latex知道如何处理特定于代码的代码标记.当我第一次执行此过程时,我得到了Sweave.sty文件可能会出现的常见错误.找不到.我用谷歌搜索,可以通过键入以下命令来解决问题进入Mac OS终端:
I then can go to R and use sweave to translate the .Rnw file into a .tex fileOnce this is done the latex interpreter can be called and because I used\usepackage{Sweave}
Latex knows how to handle the sweave specific code tags.When I first did this procedure I got the common error that the Sweave.sty file couldnot be found. I googled and could solve the problem by typing the following commandinto the Mac OS Terminal:
mkdir -p ~/Library/texmf/tex/latex
cd ~/Library/texmf/tex/latex
ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave
我现在不了解的是乳胶包装\usepackage{Sweave}
如何知道它必须查看〜/Library/texmf/tex/latex来找到指向Sweave.sty文件的符号链接?如果我更改以下行会发生什么:
What I don't understand now is how does the latex package \usepackage{Sweave}
know that ithas to look at ~/Library/texmf/tex/latex to find the symbolic link to the Sweave.sty file?What happens if I change the following line:
ln -s/Library/Frameworks/R.framework/Resources/share/texmf编织
ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave
到
ln -s/Library/Frameworks/R.framework/Resources/share/texmf Sweave_Link
ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave_Link
在.Rnw文件中,我必须先使用\usepackage{Sweave_Link}
吗?
In the .Rnw file do I have to use then \usepackage{Sweave_Link}
?
推荐答案
安装LaTeX时会自动设置该路径;这是您的个人texmf树,您可以在其中放置希望LaTeX查找的任何样式或类文件.目录名称无关紧要,它在其中递归搜索Sweave.sty.因此,将目录链接更改为Sweave_Link无关紧要.
That path is set automatically when you install LaTeX; it's your personal texmf tree and you can put any style or class files you want LaTeX to find there. The directory names don't matter, it searches recursively in them for Sweave.sty. So changing the directory link to Sweave_Link shouldn't matter.
您可以通过运行kpsewhich Sweave.sty
在所有texmf树中查找所需文件的方式进行测试.
You can test this by running kpsewhich Sweave.sty
which looks in all the texmf trees for the desired file.
此外,您无需在Rnw文件中包含\usepackage{Sweave}
; Sweave会自动添加它.
Also, you don't need to have \usepackage{Sweave}
in the Rnw file; Sweave will add it automatically.
这篇关于试图了解乳胶,sweave和R之间的工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!