【发布时间】:2020-04-05 19:44:55
【问题描述】:
我正在使用sweave绘制绘图,我想固定R代码的位置而不固定图形的位置,也就是说我想保持代码在文本中的位置但图形浮动,我应该怎么做做?谢谢
感觉不清楚所以我把代码放在那里:
text before the figure
\begin{figure}
<<smokefig, fig.width=3, fig.height=3>>=
tabSmoke<-table(ps$smoke)[2:5]
par(mar = c(2, 4.1, 0.1, 0.1))
with(ps,barplot(100*tabSmoke/sum(tabSmoke),ylim=c(0, 110), las = 2,
cex.axis = 0.75,cex.names = 0.75,col = c("pink","lightblue")))
@
\caption{Pourcentages des fumeurs et non-fumeurs selon les quatre modalités}
\end{figure}
text after the figure
我想要的是让 R 代码出现在行之间,比如
text before the figure
tabSmoke<-table(ps$smoke)[2:5]
par(mar = c(2, 4.1, 0.1, 0.1))
with(ps,barplot(100*tabSmoke/sum(tabSmoke),ylim=c(0, 110), las = 2,
cex.axis = 0.75,cex.names = 0.75,col = c("pink","lightblue")))
text afther the figure
然后这个数字可以出现在任何它想要的地方
但事实证明,代码随数字浮动,它们一起出现在下一页,如下所示:
output of code lines
output of figure
这是我放在标题中的内容,以防它可能有用
\documentclass[10pt]{article}
\usepackage{geometry}
\geometry{a4paper,scale=0.75}
\author{me}
\title{title}
\begin{document}
【问题讨论】:
-
我认为这是正常行为。请发布一个不起作用的自包含示例,我们会让您知道出了什么问题。
-
@user2554330 感谢您的评论,我已经编辑了我的问题