6

consider my header and first section

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

I want to remove the automatic "Chapter 1" part, thats sits in front of the actual chapter title (in this case Introduction) This does not work

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

Also using another documentclass does not work, because I need the number of my sections/chapters be represented in the figure captions (e.g Figure 3.1) What I would like is to end up with a Title 1 Introduction , than 2 Methods and so on. Should not be to hard, but I can't figure it out. Thanks Greg

Gregor
  • 160
  • 1
  • 6

1 Answers1

8

You can use

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

together with

\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 is installed in your TeX system.

At the time of writing subparagraph: true was needed since the used pandoc LaTeX template redefined \paragraph and \subparagraph in a way interfering with titlesec. This has changed since then. at least with rmarkdown version 2.1 one no longer needs subparagraph: true. thanks @MarkNeal for noticing this!

Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
  • Thank you for your answer. I still got an error message. But after including "subparagraph: true" in the header it worked! Maybe you can update your answer, so I can mark it accepted. I also had to download titlesec with the MiKTeX Package Manager, maybe you can update this too. – Gregor Jan 16 '18 at 00:04
  • Thanks for this answer! However I tried to use the answer presented here, I get the following error message: Error: YAML output format must evaluate to a function In addition: Warning message: In readLines(input, encoding = "UTF-8") : incomplete final line found on '_output.yml' The yaml header looks like this: subparagraph: true bookdown::pdf_book: includes: in_header: preamble.tex latex_engine: xelatex citation_package: natbib keep_tex: yes bookdown::epub_book: default – Haakonkas Nov 04 '18 at 15:52
  • @Haakonkas YAML headers are quite picky when it comes to formatting, but that gets lost in a comment. Please create a new question. – Ralf Stubner Nov 04 '18 at 16:07
  • 1
    @MarkNeal Thanks! It seems like the used LaTeX template has improved over time! – Ralf Stubner Mar 18 '20 at 10:52