1

I want to change the default font size for specifically heading, footnote and table and figure descriptions for all the chapters in advance (e.g. by specifying the desired size in the index.Rmd yaml). For example, when I do fontsize=10pt in the yaml it nicely changes main body text sizes to 10pt. Is there a way that I can similarly manipulate font size of heading, footnote and table and figure descriptions in my book?

Here is an example how the yaml of the index.Rmd file looks like.

--- 
title: "Looking for some help to change font size of headings in my book."
author: "Bird"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
mainfont: Times New Roman
fontsize: 10pt
geometry: "left=2.5cm, right=2cm, top=2.5cm, bottom=2.5cm"
linestretch: 1.5
toc-depth: 1
secnumdepth: 1
lof: True
lot: True
---
bird
  • 2,938
  • 1
  • 6
  • 27
  • 3
    Does this answer your question? [CSS Customization in a Bookdown Document](https://stackoverflow.com/questions/40982137/css-customization-in-a-bookdown-document) – M.H. Tajaddini Apr 26 '21 at 10:31
  • 1
    @M.H.Tajaddini would you please explain why these questions are similar? I am not an expert on css customizations, but as far as I know it is not for PDF books. My question is about pdf latex which has nothing to do with css (in my opinion). – bird Apr 27 '21 at 06:56

1 Answers1

2

Here is a solution to change the default font size locally.

---
title: "Untitled"
author: "bttomio"
date: "4/26/2021"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## \scriptsize Use one slash for headings (\\scriptsize)

For the footnote, it works similarly. Check here^[\tiny Using \\tiny.]

## \huge Table description with {kableExtra} (\\huge)

For example:

```{r pressure, echo=FALSE}
library(kableExtra)
kbl(mtcars[1:2, 1:4], booktabs = T, linesep = "", caption = "\\huge Test with huge", escape = F) %>%
  kable_styling(latex_options = "hold_position")
```

More styles, following LaTeX code: https://i2.wp.com/texblog.org/Wordpress/wp-content/uploads/2012/08/font-size21.png (Source).

-output

enter image description here

bttomio
  • 2,206
  • 1
  • 6
  • 17
  • would you please show how to change the font to a specific heading size of say, 12pt? – bird Apr 26 '21 at 11:46
  • @bird, with `fontsize: 10pt` in the yaml, I'd say `\large`. More information [here](https://tex.stackexchange.com/a/24600/235920). – bttomio Apr 26 '21 at 12:26
  • @bird, If the answer helped feel free to accept the answer by clicking on the check mark to the left. You can accept only one answer per post. Refer - https://stackoverflow.com/help/someone-answers. Thanks – bttomio Apr 26 '21 at 13:10