SavedByJESUS
SavedByJESUS

Reputation: 3314

Change size of section titles in R Markdown PDF

Is there a way to change the font size of text of headings in R Markdown?

I know how to number the sections of the article; however, in terms of formatting, the font size of the sections that are numbered 1., 2., 3... is too large. As a workaround, I have been using lower-level headers ### Introduction, but these have the wrong numbering.

Here is a basic example:

---
output: bookdown::pdf_document2
---

# This is too big

### This is the right size but are labelled as 1.0.1

Upvotes: 1

Views: 3206

Answers (2)

Ralf Stubner
Ralf Stubner

Reputation: 26823

You can place

\usepackage[medium]{titlesec} % or small

in preamble.tex (or where ever you have special LaTeX commands) together with

subparagraph: yes

in th e YAML headers (c.f. this question). For a more detailed answer we will need a minimal working example.

Upvotes: 3

SavedByJESUS
SavedByJESUS

Reputation: 3314

One workaround to this is to change the font size of the section title by including a css file. An example is:

h1 { font-size: 16px; }

h2 { font-size: 14px; }

h3 { font-size: 12px; }

The font size specified inside h1{} will change the font size of the header of depth 1 (i.e. # Section). The font size specified inside h2{} will change the font size of the header of depth 2 (i.e. ## Subsection) and so on.

Upvotes: 2

Related Questions