图形大小与从markdown到docx的pandoc转换 [英] Figure sizes with pandoc conversion from markdown to docx
问题描述
我在Rstudio中使用Rmarkdown键入报告。当使用knitr在 html
中转换它时,knitr还会生成 markdown
文件。我将此文件转换为 pandoc
,如下所示:
I type a report with Rmarkdown in Rstudio. When converting it in html
with knitr, there is also a markdown
file produced by knitr. I convert this file with pandoc
as follows :
pandoc -f markdown -t docx input.md -o output.docx
output.docx
文件很好,除了一个问题:数字的大小被改变,我需要手动调整Word中的数字。有没有什么可做的,可能是 pandoc
的选项,以获得正确的数字尺寸?
The output.docx
file is nice except for one problem: the sizes of the figures are altered, I need to manually resize the figures in Word. Is there something to do, maybe an option with pandoc
, to get the right figures sizes ?
推荐答案
一种简单的方法是在各个块选项中包含比例因子 k
:
An easy way consists in including a scale factor k
in the individual chunk options:
{r, fig.width=8*k, fig.height=6*k}
和全局块选项中的变量 dpi
:
and a variable dpi
in the global chunk options:
opts_chunk$set(dpi = dpi)
然后你可以设置<的值在全局环境中编织 Rmd
文件之前code> dpi 和 k
:
Then you can set the values of dpi
and k
before knitting the Rmd
file in the global environment:
dpi <<- 96
k <<- 1
或者你可以在 Rmd
文件的一个块中设置它们(设置<$例如,在第一个块中c $ c> k 。
or you can set them in a chunk in the Rmd
file (set k
in the first chunk for example).
这篇关于图形大小与从markdown到docx的pandoc转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!