回复 第8楼 的 bayeswhu:
解决思路是使用lyx的column函数在Rstudio中使用knitr对一个Rnw文件所编写的beamer中的plot进行布局控制,即把column作为一个容器,从而形成一个约束框架,通过调整这个容器达到控制的目的。复制以下代码到一个rnw文件中,并使用Rstudio中的knitr进行编译即可。具体方法见代码,
<br />
%%----------introduction part-----------------<br />
\documentclass[xcolor=dvipsnames,10pt]{beamer}<br />
\usepackage[UTF8,noindent]{ctexcap}<br />
\usecolortheme[named=Brown]{structure}<br />
\usetheme{Warsaw}<br />
\usepackage{colortbl,xcolor}<br />
\setbeamertemplate{caption}[numbered] %插图自动编号<br />
\setbeamertemplate{footline}[frame number] %页码</p>
<p>%%----------document part-----------------<br />
\begin{document}<br />
\title{beamer function test}<br />
\author{chinese 中文}<br />
\institute{ABC}<br />
\maketitle</p>
<p><<setup, include=FALSE>>=<br />
options(device = function(file, width = 2, height = 2, ...) {<br />
cairo_pdf(tempfile(), width = width, height = height, ...)<br />
})<br />
pdf.options(family = "GB1")<br />
@</p>
<p>%%----------slide 1-----------------<br />
\begin{frame}[fragile]<br />
\begin{columns}[t]<br />
\begin{column}{6cm}<br />
<<boring-random,include=TRUE,fig.width=4,highlight=TRUE,results='markup',size='scriptsize',fig.height=3,tidy=TRUE, fig.align="center">>=<br />
x<-c(1:10)<br />
y <- c(1:10)<br />
plot(x,y,type='l')<br />
@<br />
\end{column}<br />
\end{columns}<br />
this is test text<br />
\end{frame}</p>
<p>%%----------slide 2-----------------<br />
\begin{frame}<br />
\begin{columns}[t]<br />
\begin{column}{2cm}<br />
this is test text<br />
\end{column}<br />
\begin{column}{6cm}<br />
<<>>=<br />
x<-c(1:10)<br />
y <- c(1:10)<br />
plot(x,y,type='l')<br />
@<br />
\end{column}<br />
\end{columns}<br />
\end{frame}</p>
<p>%%----------slide 3-----------------<br />
\begin{frame}[fragile]<br />
\begin{block}{this is block title}<br />
\begin{columns}[t]<br />
\begin{column}{5cm}<br />
this is used to column application 1\\<br />
\begin{figure}[numbered]<br />
<<fig.width=4, fig.height=3, message=FALSE, tidy=TRUE, fig.align="left",echo=FALSE>>=<br />
library(ggplot2)<br />
p <- ggplot(data=mpg,mapping=aes(x=cty,y=hwy))<br />
p <- p + opts(title="ggplot的中文标题是这样子",plot.title=theme_text(face="bold",size=10,hjust=0.5,vjust=2,colour="black"))<br />
p+ xlab("测试X轴") + ylab("测试Y轴") + geom_point()<br />
@<br />
\caption{This caption is placed below the figure.}<br />
\end{figure}<br />
\end{column}<br />
\begin{column}{5cm}<br />
this is used to column application 2\\<br />
\begin{figure}[numbered]<br />
<<fig.width=4, fig.height=3, message=FALSE, tidy=TRUE, fig.align="left",echo=FALSE>>=<br />
library(ggplot2)<br />
p <- ggplot(data=mpg,mapping=aes(x=cty,y=hwy))<br />
p <- p + opts(title="ggplot的中文标题是这样子",plot.title=theme_text(face="bold",size=10,hjust=0.5,vjust=2,colour="black"))<br />
p+ xlab("测试X轴") + ylab("测试Y轴") + geom_point()<br />
@<br />
\caption{This caption is placed below the figure.}<br />
\end{figure}<br />
\end{column}<br />
\end{columns}<br />
\end{block}<br />
this is buttom text\\<br />
这是中文的说明<br />
\end{frame}</p>
<p>\end{document}<br />
</p>