首页 > 解决方案 > 根据在 RMarkdown 中编织为 pdf 还是 docx 更改标题级别

问题描述

我有一个大型项目,其中包含几个章节(或子章节),我可以成功地将其编成 pdf 或 docx。

这是master.Rmd编织孩子们的chapterOne.Rmd

---
title: Title of My Project
author: "My Name"
csl: G:/My Drive/ZoteroRPlugin/styles-master/spectroscopy-letters.csl
output:
  pdf_document:
    includes:
      in_header: styles/preamble.tex #not relevant to the question
    keep_tex: yes
    latex_engine: xelatex
    number_sections: yes
  word_document:
    fig_caption: yes
    toc: yes
    reference_docx: styles/word-styles-reference_05.docx
link-citations: yes
documentclass: styles/thesis-umich3
bibliography: G:/My Drive/ZoteroRPlugin/Report_references.bib
---

```{r global_options, include=FALSE}
library(knitr)
knitr::opts_chunk$set(fig.align='center')
use_betterbiblatex = TRUE
```

\chapter{Introduction}
<!--# Introduction -->
```{r child = 'chapterOne.Rmd'}
```
\pagebreak

\chapter{Literature Review}
```{r child = 'chapterTwo.Rmd'}
```
\pagebreak

这是其中一个子文件的代码chapterOne.Rmd

---
output: pdf_document
---

```{r chapter1_options, include=FALSE}
library(knitr)
knitr::opts_chunk$set(fig.align='center')
use_betterbiblatex = TRUE
```

## Level 1 Heading

Insert Text Here

### Level 2 Heading

但是为了正确完成标题,我需要在编织到 docx 时增加标题级别(这是由于我需要使用 csl 文件)。由于\chapter{Introduction}无法识别该命令(这很好)。

这是上传时的屏幕截图,docx它为我提供了正确的标题 图像

然而,这会导致pdf不正确地调平。

我意识到我可以Ctrl+H并且 to a to但这并不是每次我必须在编织到 pdf 和 docx 之间切换时做的最佳选择 Find/Replace###图像

有人对解决方法有任何想法吗?

标签: pdfr-markdownknitrdocx

解决方案


推荐阅读