我想用RMarkdown编织一篇文章,但是图形(表格)没有出现在文档(pdf)中的正确位置。
在这里,我可以在示例数据中向您展示我的问题。该表应出现在附录之后:有人可以告诉我如何解决此问题吗?
这是您的示例代码:
---
title: "title"
subtitle: "subtitle"
author: "me"
date: "`r format(Sys.time(), '%B %d, %Y')`"
keywords: "keywords"
output:
pdf_document:
fig_cap: yes
keep_tex: yes
documentclass: article
capsize: normalsize
fontsize: 11pt
geometry: margin=1in
spacing: doublespacing
footerdate: yes
abstract: 'Insert abstract here'
---
\newcommand*{\keywords}[1]{\textbf{\textit{Keywords---}} #1}
\keywords{keywords}
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.pos= "h", out.extra = '')
##required packages
library(tidyverse)
library(knitr)
library(kableExtra)
```
# Introduction
# Literature review
# Data and Methodology
# Empirical Results
# Conclusions
\newpage
# References {-}
<div id="refs"></div>
\newpage
# Appendix
```{r echo=F, warning=F, message=F}
df1 <- tibble(column1= 1:10, column2=11:20)
df1%>%kable("latex",
booktabs=T,
caption = "Dataframe 1")%>%
kable_styling()
```
答案 0 :(得分:1)
只需在latex_options=c("hold_position")
内添加kable_stylying
:
df1 <- tibble(column1= 1:10, column2=11:20)
df1 %>%
kable("latex", booktabs=T, caption = "Dataframe 1") %>%
kable_styling(latex_options = c("hold_position"))