由Pandoc从.md转换的投影仪幻灯片中的图非常大 [英] Plots in beamer slides converted from .md by pandoc are extremely large
问题描述
由R chunks
在R markdown文件中生成的法线图在转换为html幻灯片或pdf时完全存在.但是,当它们由pandoc -t beamer ex.md -V theme:Warsaw -o beamer.pdf
转换为投影仪幻灯片时,图变得非常大,尤其是对于par(mfrow=c(n,m))
生成的图而言,在这种情况下,只显示了一小部分图.
Normal plots generated by R chunks
in R markdown files are exactly there when converted to html slides or pdf. However, when they are converted to beamer slides by pandoc -t beamer ex.md -V theme:Warsaw -o beamer.pdf
, the plots become extremely large, especially for those generated by par(mfrow=c(n,m))
, in which case only a little part of the plot is displayed.
我试图通过设置块选项dev='pdf'
进行修复,但无法解决问题.
I tried to fix by setting the chunk option dev='pdf'
, but it doesn't work out.
html中的图是
The plot in html is
Beamer中的情节是
The plot in beamer is
推荐答案
pandoc的开发版本在投影仪模板中包含一些代码,这些代码应将图像缩放到幻灯片的宽度.这可能对您有帮助.
The development version of pandoc includes some code in the beamer template that should scale images to the width of the slide. That may help in your case.
您无需安装开发pandoc即可使用它,因为更改仅是模板.只需使用pandoc -D beamer > my.beamer
生成默认投影仪模板的副本即可.在\usepackage{graphicx}
行之后将以下行插入my.beamer
:
You don't need to install development pandoc to use this, since the change is just to a template. Just generate a copy of the default beamer template using pandoc -D beamer > my.beamer
. Insert the following lines into my.beamer
after the line \usepackage{graphicx}
:
\makeatletter
\def\ScaleIfNeeded{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother
\setkeys{Gin}{width=\ScaleIfNeeded}
然后将pandoc与选项--template=my.beamer
一起使用.
Then use pandoc with the option --template=my.beamer
.
这篇关于由Pandoc从.md转换的投影仪幻灯片中的图非常大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!