我正在使用rmarkdown和LaTeX/Beamer构建一个演示文稿。我想减少显示的R命令和R输出之间的间距。我相信这与LaTeX/Beamer中的段落间距选项有关。
这是我应该在rmarkdown (分块选项,knit_hooks,还是其他什么?),在pandoc Yaml头文件(一些pandoc选项?),还是在LaTeX beamer模板文件中做的事情?我觉得它应该在LaTeX模板文件中。
下面是一个最小的标记文件和一个.tex模板文件的工作示例,我正在用它来控制一些波束设置。
example.Rmd
---
title: "Untitled"
author: "Ryan"
date: "March 1, 2016"
output:
beamer_presentation:
pandoc_args: '--latex-engine=xelatex'
includes:
in_header: latex-topmatter.tex
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo =真)
## Vertical Spacing is too much
Here is a working example.
- some
- bullets
Example code:
```{r, echo = TRUE}A <- 1
一个
a+a
latex-topmatter.tex
% declare overall beamer theme to use as baseline
\usetheme{default}
% make code-output smaller
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{fontsize=\tiny,commandchars=\\\{\}}
% make console-output smaller:
\makeatletter
\def\verbatim{\tiny\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}
\makeatother
% set vertical spacing between paragraphs:
% \parskip{0pt}
% \addtobeamertemplate{blocks}{}{\setlength{\parskip}{0pt}}
% \addtobeamertemplate{block begin}{}{\setlength{\parskip}{0pt}}
% \addtobeamertemplate{block end}{}{\setlength{\parskip}{0pt}}
% % \setlength{\emergencystretch}{0em}
\setlength{\parskip}{0pt}我已经尝试将R命令或R输出的字体变小,这似乎不会影响段落间距。
我试着使用这个例子中的knit_hooks():https://github.com/ramnathv/slidify/issues/189,它基本上是有效的-但是我似乎不能减少代码和输出的字体大小。
我还尝试使用\parskip{0pt}和其他几个beamer选项或parskip选项,上面的latex-topmatter.tex部分对它们进行了注释。它们似乎都不会改变文本块、R代码或R输出之间的间距。我找对地方了吗?

发布于 2017-01-04 23:56:08
下面是一个有效的示例。请注意头文件末尾的定义:
Shaded环境中,而该环境又使用\OuterFrameSep作为其间距。因此,我们需要重新定义。\preto时,我们在每个逐字环境中预先加上命令\topsep=-10pt \partopsep=-10pt。这会影响输出区块的间距。example.Rmd
---
title: "Untitled"
author: "Martin"
date: "January 4, 2017"
output:
beamer_presentation:
keep_tex: yes
pandoc_args: --latex-engine=xelatex
includes:
in_header: latex-topmatter.tex
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo =真)
## Vertical Spacing is just right
Here is a working example.
- some
- bullets
Example code:
```{r, echo = TRUE}A <- 1
一个
a+a
latex_topmatter.tex
% declare overall beamer theme to use as baseline
\usetheme{default}
% make code-output smaller
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{fontsize=\tiny,commandchars=\\\{\}}
% make console-output smaller:
\makeatletter
\def\verbatim{\tiny\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}
\makeatother
\setlength{\parskip}{0pt}
\setlength{\OuterFrameSep}{-4pt}
\makeatletter
\preto{\@verbatim}{\topsep=-10pt \partopsep=-10pt }
\makeatother

https://stackoverflow.com/questions/35734525
复制相似问题