【问题标题】:R Position of figures in RMarkdownR RMarkdown中数字的位置
【发布时间】:2019-04-26 13:03:59
【问题描述】:

我想在 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()
```

【问题讨论】:

    标签: r r-markdown


    【解决方案1】:

    只需在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"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2021-08-13
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 2021-08-10
      相关资源
      最近更新 更多