【问题标题】:R: Removing the "Chapter" part from the title in bookdown::pdf_book with documentclass: reportR:使用文档类:报告从 bookdown::pdf_book 中的标题中删除“章节”部分
【发布时间】:2018-01-15 22:40:23
【问题描述】:

考虑一下我的标题和第一部分

---
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

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

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

另外使用另一个文档类也不起作用,因为我需要在图标题中表示我的部分/章节的数量(例如图 3.1) 我想要的是得到一个标题 1 Introduction ,而不是 2 Methods 等等。 应该不难,但我想不通。 谢谢 格雷格

【问题讨论】:

    标签: r knitr r-markdown bookdown


    【解决方案1】:

    你可以使用

    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}
    

    preamble.tex(参见https://tex.stackexchange.com/questions/10326/how-to-set-the-chapter-style-in-report-class)。您必须确保在您的 TeX 系统中安装了 LaTeX 包 titlesec

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

    【讨论】:

    • 感谢您的回答。我仍然收到一条错误消息。但是在标题中包含“subparagraph:true”之后它起作用了!也许您可以更新您的答案,以便我可以将其标记为已接受。我还必须使用 MiKTeX 包管理器下载 titlesec,也许你也可以更新它。
    • 感谢您的回答!但是,我尝试使用此处提供的答案,但收到以下错误消息:错误:YAML 输出格式必须评估为函数此外:警告消息:在 readLines(input, encoding = "UTF-8") 中:不完整的最后一行在 '_output.yml' 上找到 yaml 标头如下所示: subparagraph: true bookdown::pdf_book: includes: in_header: preamble.tex latex_engine: xelatex citation_package: natbib keep_tex: yes bookdown::epub_book: default
    • @Haakonkas YAML 标头在格式化方面非常挑剔,但在评论中会丢失。请创建一个新问题。
    • @MarkNeal 谢谢!随着时间的推移,使用的 LaTeX 模板似乎有所改进!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-25
    相关资源
    最近更新 更多