Code chunk font size in Beamer with knitr and latex

前端 未结 1 1591
闹比i
闹比i 2021-02-13 12:55

I am trying get some R code to fit on my beamer slides. It does not seem possible to change the font size via the size argument for the code chunk as you might do f

1条回答
  •  攒了一身酷
    2021-02-13 13:30

    Drawing on this tex.SE answer, we could redefine the Shaded environment that surrounds R code to make it footnotesize (and the verbatim environment for output). Add this to your header.txt:

    %% change fontsize of R code
    \let\oldShaded\Shaded
    \let\endoldShaded\endShaded
    \renewenvironment{Shaded}{\footnotesize\oldShaded}{\endoldShaded}
    
    %% change fontsize of output
    \let\oldverbatim\verbatim
    \let\endoldverbatim\endverbatim
    \renewenvironment{verbatim}{\footnotesize\oldverbatim}{\endoldverbatim}
    

    0 讨论(0)
提交回复
热议问题