Sweave中的并排数字

MYa*_*208 3 latex r sweave

我使用这段代码来制作数字 Sweave

<<label=fig1plot, include=FALSE >>=
plot(cars)
@

\begin{figure}
\begin{center}
<<label=fig1, fig=TRUE, echo=FALSE>>=
<<fig1plot>>
@
\end{center}
\caption{Some caption}
\label{fig:fig1plot}
\end{figure}


<<label=fig2plot, include=FALSE >>=
plot(table(rpois(100,5)), type = "h", col = "red", lwd=10, main="rpois(100,lambda=5)")
@

\begin{figure}
\begin{center}
<<label=fig2, fig=TRUE, echo=FALSE>>=
<<fig2plot>>
@
\end{center}
\caption{Some caption}
\label{fig:fig2plot}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

现在我想把这两个数字并排放在一起,并有如图1(a)和图1(b)所示的标题.任何想法,评论和指南都非常感谢.在此先感谢您的时间和帮助.

rcs*_*rcs 10

您可以使用子标题 LaTeX包:

\begin{figure}
  \begin{minipage}[b]{.5\linewidth}
     \centering\large A
     % plot 1
     \subcaption{A subfigure}\label{fig:1a}
  \end{minipage}%
  \begin{minipage}[b]{.5\linewidth}
     \centering\large B
     % plot 2
     \subcaption{Another subfigure}\label{fig:1b}
  \end{minipage}
  \caption{A figure}\label{fig:1}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

另请参阅:如何将图像并排显示并且每个图像都附有数字?