代码之家  ›  专栏  ›  技术社区  ›  Gregor

R: 从bookdown::pdf\u book with documentclass:report中的标题中删除“Chapter”部分

  •  6
  • Gregor  · 技术社区  · 7 年前

    考虑我的标题和第一节

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

    此外,使用另一个documentclass也不起作用,因为我需要在图标题中显示我的章节数(例如图3.1) 我想要的是得到一个头衔 1简介 2种方法 等等 应该不难,但我想不出来。 谢谢 格雷格

    1 回复  |  直到 7 年前
        1
  •  8
  •   Ralf Stubner    5 年前

    您可以使用

    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 (c.f。 https://tex.stackexchange.com/questions/10326/how-to-set-the-chapter-style-in-report-class ). 你必须确保乳胶包装 titlesec 安装在您的TeX系统中。

    在撰写本文时 subparagraph: true 需要,因为使用的pandoc LaTeX模板已重新定义 \paragraph \subparagraph 在某种程度上干扰 标题EC . 从那时起,情况发生了变化。至少有 rmarkdown 不再需要2.1版 分段:真 . 感谢@MarkNeal注意到这一点!