首页 > 解决方案 > 附录部分表格乱码(R-markdown)

问题描述

我正在用 R markdown 写我的 Ms 论文,但附录部分有问题。我需要在附录部分放置一些表格,但是当我渲染它时,该小节的标题出现在表格下方。像这样:

在此处输入图像描述

我想知道是否有办法解决这个问题。

我编写代码的方式是:


# Appendix {-}

## Subsection title

chunk with table 

R-markdown 块:

title: "Title of my thesis"
subtitle: 
author: 
 - "Student :"
 - "Director: "
output: 
 pdf_document:
  number_sections: true
 latex_engine: xelatex
 template: NULL
 word_document: default
degree: Ms Biology
field: Experimental biology
year: 2021
geometry: left=2cm,right= 2 cm,top=2 cm, bottom=2 cm
papersize: a4
header-includes: 
 - \usepackage{amsmath} 
 - \usepackage{booktabs}
 - \usepackage{pdflscape}
 - \usepackage[justification=raggedright,labelfont=bf,singlelinecheck=false]{caption}
 - \usepackage{setspace}
bibliography: library.bib
csl: apa7.csl
fontsize: 11 pt
indent: true
spacing: 1.5

和块选项

knitr::opts_chunk$set(
      echo = FALSE, 
      warning = FALSE, 
      message = FALSE,
      error =FALSE)

标签: rr-markdown

解决方案


好吧,为了停止将表格放在字幕下,我必须添加

 - \usepackage{flafter}

然后表格出现在下一页中,为了避免这种情况,我添加了

kbl(data)%>%
kable_styling(latex_options = "hold_position")

就这样。


推荐阅读