R:使用 documentclass: report 从 bookdown::pdf_book 中的标题中删除 "Chapter" 部分

R: Removing the "Chapter" part from the title in bookdown::pdf_book with documentclass: report

考虑我的 header 和第一部分

---
title: "asdf"
author: "asdf"
date: "13 Januar 2018"
documentclass: report
output:
  bookdown::pdf_book:
    citation_package: biblatex
    latex_engine: pdflatex
    number_sections: yes
    fig_caption: yes
---

# Introduction
Here begins my introduction

我想删除自动 "Chapter 1" 部分,它位于实际章节标题的前面(在本例中为 简介) 这不起作用

header-includes:
  \renewcommand{\chaptername}{}

同样使用另一个文档类也不起作用,因为我需要我的 sections/chapters 的编号在图形标题中表示(例如图 3.1) 我想要的是以标题 1 简介 结尾,而不是 2 方法 等等。 应该不难,但我无法弄清楚。 谢谢 格雷格

您可以使用

subparagraph: true
output:
  bookdown::pdf_book:
    includes:
      in_header: preamble.tex

连同

\usepackage{titlesec}
\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{\thechapter}{1em}{}
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

in preamble.tex(c.f。https://tex.stackexchange.com/questions/10326/how-to-set-the-chapter-style-in-report-class). You have to make sure that the LaTeX package titlesec 安装在您的 TeX 系统中。

在撰写本文时需要 subparagraph: true,因为使用的 pandoc LaTeX 模板以干扰 titlesec 的方式重新定义了 \paragraph\subparagraph。从那时起,情况发生了变化。至少在 rmarkdown 2.1 版中不再需要 subparagraph: true。感谢@MarkNeal 注意到这一点!