在RMarkdown中调整图表的位置

3
我想在RMarkdown中编写一篇文章,但是图片或表格不能在文档(PDF)中正确地显示。在这里,我可以通过示例数据展示我的问题。表格应该出现在附录后面,有谁能向我展示如何解决这个问题吗?
以下是示例代码:

enter image description here

---
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()
```
1个回答

2
只需在 kable_stylying 中添加 latex_options=c("hold_position") 即可:
df1 <- tibble(column1= 1:10, column2=11:20)

df1 %>%
  kable("latex", booktabs=T, caption = "Dataframe 1") %>%
  kable_styling(latex_options = c("hold_position"))

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接