2016-04-18 10 views
1

RStudioによって生成されたlatexファイルを編集しようとしていますが、RStudioで生成されたファイルはそのままコンパイルされません。ここで RStudioで生成されたlatexファイルをコンパイルする

はテンプレート

--- 
title: "Untitled" 
author: "SN248" 
date: "April 17, 2016" 
output: 
    beamer_presentation: 
    keep_tex: true 
    theme: "CambridgeUS" 
--- 

```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = TRUE) 
``` 

## R Markdown 

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. 

Some code 
```{r eval=FALSE, echo=TRUE} 
install.packages("mypackage") 
library(mypackage) 
``` 

## Including Plots 

You can also embed plots, for example: 

```{r pressure, echo=TRUE} 
plot(pressure) 
``` 

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. 

注意を私は中間texファイルを取得するためにkeep_tex: trueを追加したこと、(私は私のスライドのコードを表示したいと少し編集した)で、生成されたtexファイルは以下に貼り付けられます:

\begin{frame}[fragile]{R Markdown} 

This is an R Markdown document. Markdown is a simple formatting syntax 
for authoring HTML, PDF, and MS Word documents. For more details on 
using R Markdown see \url{http://rmarkdown.rstudio.com}. 

Some code 

\begin{Shaded} 
\begin{Highlighting}[] 
\KeywordTok{install.packages}\NormalTok{(}\StringTok{"mypackage"}\NormalTok{)} 
\KeywordTok{library}\NormalTok{(mypackage)} 
\end{Highlighting} 
\end{Shaded} 

\end{frame} 

\begin{frame}[fragile]{Including Plots} 

You can also embed plots, for example: 

\begin{Shaded} 
\begin{Highlighting}[] 
\KeywordTok{plot}\NormalTok{(pressure)} 
\end{Highlighting} 
\end{Shaded} 

\includegraphics{Untitled_files/figure-beamer/pressure-1.pdf} 

Note that the \texttt{echo\ =\ FALSE} parameter was added to the code 
chunk to prevent printing of the R code that generated the plot. 

\end{frame} 

私は、生成さtexファイルは、箱から出してコンパイルされないことに気づきました。それは

\documentclass[hyperref={pdfpagelabels=false}]{beamer} 
\usepackage{lmodern} 
\usepackage{listings} 
\usetheme{CambridgeUS} 
\begin{document} 
... 
\end{document} 

をコンパイルするようので、私はコンパイルされません、私はまだ少しbegin{Shaded}としてこのtexファイルをコンパイルすることはできませんよ必要​​なビット(コードハイライトするためのすなわち、パッケージlistings)を加え、私は次のエラーを取得します:

LaTeX Error: Environment Shaded undefined

私の質問は、箱から出してコンパイルRStudioからtexファイルを生成する方法、です。そうでない場合は、パッケージには、私はただ、いくつかのコンテキストを与えること

\begin{Shaded} 
\begin{Highlighting}[] 
\KeywordTok{install.packages}\NormalTok{(}\StringTok{"mypackage"}\NormalTok{)} 
\KeywordTok{library}\NormalTok{(mypackage)} 
\end{Highlighting} 
\end{Shaded} 

の下に示す(特にハイライトとコードを表示するように)texコードをコンパイルするために使用すべき、私はセクションを追加できるようにtexファイルをコンパイルしようとしていますとtexコードのサブセクション、私はファイルでそれを行う方法がわかりません。

ありがとうございました。

SN248

答えて

1

私はあなたがRMarkdownを使用してknitrせずにコンパイルすることができ、スタンドアローン.texファイルを生成したいされていることがわかります。 私はSWeaveでも同じことをしています。 SWeaveはRコードのラテックス文書なので、SWeaveを実行して図形を作成すると簡単にコンパイルできます。

たとえば、このドキュメントをRStudioで作成し、Rstudioでコンパイルしました。

\documentclass{article} 

\title{Best title ever} 
\author{XTriMa, PhD} 

\begin{document} 
\maketitle 
\tableofcontents 
\section{Method} \label{intro} 
Let me make two vectors with random numbers and plot them. 

<<>>= 
x<-runif(100) 
y <- x^(sin(x)) 
plot(x, y) 
@ 
\end{document} 

マイフォルダには、

$pdflatex test.tex 

を実行する場合、今ではあなたが意図したとおりに動作します。この

figure    test.log test.Rnw   test.tex 
test-concordance.tex test.pdf test.synctex.gz test.toc 

のように見えます。しかし、コマンド "latex"は、図のpdfグラフィックスでは動作しないため、動作しません。

利点:私はRとラテックスを非常に効率的に扱い、RStudioやSweavのような中間ソフトウェア/クライアントを取り除くことができます。

関連する問題