Error with tex2docx function from reports R package

docx, r, report, tex

Solution

As described in the above comments, the error is caused by passing a filename/path including some spaces that are nor escaped, nor quoted. A workaround could be wrapping all file paths and names inside of `shQuote` before passing to the command line with `system`.

Code: https://github.com/trinker/reports/pull/31

Demo:

Loading package

library(reports)

Creating a dummy dir with a space in the name that would hold the `bib` file

dir.create('foo bar')
file.copy(system.file("extdata/docs/example.bib", package = "reports"), 'foo bar/example.bib')

Specifying the source and the copied `bib` file:

DOC <- system.file("extdata/doc_library/apa6.qual_tex/doc.tex", package = "reports")
BIB <- 'foo bar/example.bib'

Running the test:

tex2docx(DOC, file.path(getwd(), "test2.docx"), path = NULL, bib.loc = BIB)

Disclaimer: I tried to test this pull request, but I could not setup an environment with all the needed tools to run `R CMD check` with vignettes and everything else after all in 5 mins (sorry but being on vacation right now and just enjoying the siesta after lunch), so please consider this pull request as "untested" -- although it should work.

Problem

I'm trying to reproduce the example for `tex2docx` function in `reports` `R` package and getting the following error. ``` DOC <- system.file("extdata/doc_library/apa6.qual_tex/doc.tex", package = "reports") BIB <- system.file("extdata/docs/example.bib", package = "reports") tex2docx(DOC, file.path(getwd(), "test.docx"), path = NULL, bib.loc = BIB) ``` Error Message ``` pandoc.exe: Error reading bibliography `C:/Users/Muhammad' citeproc: the format of the bibliographic database could not be recognized using the file extension. docx file generated! Warning message: running command 'C:\Users\MUHAMM~1\AppData\Local\Pandoc\pandoc.exe -s C:/Users/Muhammad Yaseen/R/win-library/3.0/reports/extdata/doc_library/apa6.qual_tex/doc.tex -o C:/Users/Muhammad Yaseen/Documents/test.docx --bibliography=C:/Users/Muhammad Yaseen/R/win-library/3.0/reports/extdata/docs/example.bib' had status 23 ``` I wonder how to get `tex2docx` function in `reports` `R` package working properly.

Original source