0

I am trying to convert a markdown file to docx but the image and tables are not being transferred to the docx. I am doing the following:

require(knitr)
require(markdown)

Knit

knit('test.rmd')
markdownToHTML('test.md', 'test.html', options=c("use_xhml"))

Convert to pdf (The pdf is nicely created)

system("pandoc -s test.html -o test.pdf")

Convert to Word Document (Converts to test.docx but no tables or graphics)

pandoc("test.md",format="docx")

All the tables and images are saved on the same directory inside the 'Figure' folder Do I need to add another argument to pandoc to look for the Figure folder?

Mathias
  • 5,642
  • 2
  • 31
  • 46
Salvador
  • 1,229
  • 1
  • 11
  • 19
  • I don't understand your last command. What about `system("pandoc -s test.md -o test.docx")` ? – Stéphane Laurent Apr 13 '14 at 22:11
  • I would also try to remove `options=c("use_xhml")`. I don't know this option and note that by doing this you remove many default options. – Stéphane Laurent Apr 13 '14 at 22:13
  • I had ```opts_chunk$set(fig.align='center')``` as my global options and it was not displaying any of the figures. I went ahead and removed the fig.align option just to narrow the problem and it worked nicely for pdf's but in docx the figures are displayed really big outside the page margins. I don't know why the fig.align argument would prevent the figures from showing. – Salvador Apr 14 '14 at 02:06
  • I didn't know the `fig.align` argument. About the sizes, they vary from format to format - see http://stackoverflow.com/q/14829791/1100107 – Stéphane Laurent Apr 14 '14 at 06:22
  • I actually wrote a macro in VBA to custom resize all the figures when the word document is opened. Basically, pandoc converts the document and saves it in your working directory. At that point, all the figues are huge but when I double-click on the document to open it, every figure is nicely resized to fit the page and all the figues are of the same size. – Salvador Apr 14 '14 at 15:21

0 Answers0