Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
966 views
in Technique[技术] by (71.8m points)

image - Figure sizes with pandoc conversion from markdown to docx

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

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

An easy way consists in including a scale factor k in the individual chunk options:

{r, fig.width=8*k, fig.height=6*k}

and a variable dpi in the global chunk options:

opts_chunk$set(dpi = dpi)

Then you can set the values of dpi and k before knitting the Rmd file in the global environment:

dpi <<- 96    
k <<- 1

or you can set them in a chunk in the Rmd file (set k in the first chunk for example).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...