如何使用knitr、rstudio和swave将数字和表格放在正确的位置以生成pdf?
我正在尝试使用knitr和RStudio生成pdf。我的问题是:我不能把数字和表格放在正确的地方。请看一个简单的例子:如何使用knitr、rstudio和swave将数字和表格放在正确的位置以生成pdf?,r,pdf,rstudio,knitr,R,Pdf,Rstudio,Knitr,我正在尝试使用knitr和RStudio生成pdf。我的问题是:我不能把数字和表格放在正确的地方。请看一个简单的例子: \documentclass{article} \linespread{1} \usepackage{longtable} \usepackage{caption} \title{\textbf{\large{Reports: }}} \author{\large{***}} \begin{document} \maketitle <<echo= F,mess
\documentclass{article}
\linespread{1}
\usepackage{longtable}
\usepackage{caption}
\title{\textbf{\large{Reports: }}}
\author{\large{***}}
\begin{document}
\maketitle
<<echo= F,message = F,warning = F>>=
# Set the global chunk options
opts_chunk$set(echo = F, # Do NOT repeat code in final document
message = F, # Do NOT print R messages in document
warning = F # Do NOT print warnings
)
library(dplyr)
library(ggplot2)
library(xtable)
library(stringr)
@
\section*{\large{Overview}} %with *, then no number
<<>>=
myWhole <- data.frame(x=c(1,2,3,4),y=c(2,3,4,5))
@
\begin{figure}
<<echo = F, fig.width = 4, fig.height = 1.5, fig.align = 'center'>>=
ggplot(myWhole,aes(x=x,y=y)) +
geom_point()
@
\setlength{\abovecaptionskip}{-1pt}
\captionsetup{justification=centering}
\caption{****}
\end{figure}
\section*{\large{Query 6: ***}}
just try...just try...just try...just try...just try...just try...just try...just try...
\begin{table}
\setlength{\abovecaptionskip}{-10pt}
\captionsetup{justification=centering}
\caption{}
<<echo=FALSE,results='asis',message=FALSE>>=
xt=xtable(myWhole)
print(xt,tabular.environment="longtable",floating=F)
@
\end{table}
\end{document}
但生成的PDF如下所示:
即使这张图片不清楚,你仍然可以看到它们不在正确的位置。桌子在第二页,虽然第一页有足够的空间。有人能帮我一下吗?这是一个乳胶问题,而不是你的标签。简单的答案是:如果你不想让你的数字和表格在LaTeX选择的地方浮动,就不要把它放在浮动中。请参阅了解更多详细信息Hanks,我也找到了这个解决方案。这更像是一个乳胶问题,而不是与您的任何标签有关的问题。简单的答案是:如果你不想让你的数字和表格在LaTeX选择的地方浮动,就不要把它放在浮动中。请参阅了解更多详细信息谢谢,我也找到了这个解决方案。
section title: Overview
words
figure
words
section title: query 6
words
table
words