0

For some rason, xaringan is not modifying the size of the font in figures. I created figure p1 which looks like this (for the sake of the example, I am exaggerating the size of the text).

enter image description here

However, when I include it in the xaringan presentation it looks like this. As you can see the font size if super small. I changed the fig.retina option from 3 to 2 to increase a little the size, but it does not change much

.left-column[

- first thing

- secong thing

]

.right-column[
'''{r}
p1 
'''
]

enter image description here

I even tried creating a separate css file (figs.css) for the figure and included it using the theme_xaringan() funciton of the xaringanthemer package. It is supposed to increase the size of the font, but it still does not work. Notice that I increased the --base-font-size to 40px (I don't know if this is the right way to do it). I see that the title of the axis is modified by the theme_xaringan() function but the size of the labels of the axis are not.

this is the figs.css file

:root {
  /* Fonts */
  --base-font-size: 40px;
  --text-font-size: 4rem;
  --code-font-size: 0.9rem;
  --code-inline-font-size: 1em;
  --header-h1-font-size: 2.75rem;
  --header-h2-font-size: 2.25rem;
  --header-h3-font-size: 1.75rem;
}

This is the Rmarkdown code to include it.

.left-column[

- first thing

- secong thing

]

.right-column[
'''{r}
p1 +
  theme_xaringan(css_file = here("figs.css"))
'''
]

enter image description here

I think this should be a very trivial thing to solve but I have not been able to find the problem.

Thank you so much.

  • One option would be to increase the font`size` in `geom_text/label_repel` and the `base_size` of the theme. – stefan May 29 '20 at 09:44
  • Thank you @stefan, but it does not work. As you see in the first image, the font size in `label_repel` is already large enough. It does not matter how large the size is, it does not change in the final graph. – R.Andres Castaneda Jun 02 '20 at 13:59
  • That seems like a ggplot issue not a xaringan one. Try to set chunk options so the chart is actually smaller, try changing `fig.width` values or increase the text size directly in your geom – jpmarindiaz Jun 25 '20 at 04:20

0 Answers0