Giter Club home page Giter Club logo

Comments (2)

stinco avatar stinco commented on July 24, 2024

Hi, this is an issue due to how Windows represents directories paths.
While Operating Systems based on Unix (such as Linux and Max OS) uses the slash (/) to separate the parts of a path, Windows uses the backslash (\).

So, the file you want to open, in a Unix based OS is represented as docs/_main.pdf, while in Windows it is represented as docs\_main.pdf.

Given that in R \ is used as an escape character (for representing special characters like \n or \t), you have to write your path as docs\\_main.pdf. This way, \\ is used to represent the single backslash in the path.

I fixed this issue modifying the Makefile replacing Rscript -e 'browseURL("docs/_main.pdf")' at line 4 with Rscript -e 'browseURL(ifelse(.Platform[["OS.type"]] == "windows", "docs\\_main.pdf", "docs/_main.pdf"))'
On R, .Platform[["OS.type"]] will return "windows" if R is running on Windows and "unix" if R is running on Linux or Mac OS.

This is the whole Makefile with the fix on pdf, gitbook and word:

pdf:
	Rscript -e 'options(bookdown.render.file_scope = FALSE); bookdown::render_book("index.Rmd", output_format = "bookdown::pdf_book")'
	rm -f *.log *.mtc* *.maf *.aux *.bcf *.lof *.lot *.out *.toc front-and-back-matter/abbreviations.aux
	Rscript -e 'browseURL(ifelse(.Platform[["OS.type"]] == "windows", "docs\\_main.pdf", "docs/_main.pdf"))'

gitbook:
	Rscript -e 'options(bookdown.render.file_scope = FALSE); bookdown::render_book("index.Rmd", output_format = "bookdown::gitbook")'
	Rscript -e 'browseURL(ifelse(.Platform[["OS.type"]] == "windows", "docs\\index.html", "docs/index.html"))'

word:
	Rscript -e 'options(bookdown.render.file_scope = FALSE); bookdown::render_book("index.Rmd", output_format = "bookdown::word_document2")'
	Rscript -e 'browseURL(ifelse(.Platform[["OS.type"]] == "windows", "docs\\_main.docx", "docs/_main.docx"))'

clean:
	rm -f *.log *.mtc* *.maf *.aux *.bbl *.blg *.xml
	
clean-knits:
	rm -f *.docx *.html *.pdf *.log *.maf *.mtc* *.tex *.toc *.out *.lof *.lot *.bcf *.aux
	rm -R *_files
	rm -R *_cache

from oxforddown.

ulyngs avatar ulyngs commented on July 24, 2024

Thanks for flagging this issue!

I've just pushed a fix - the Makefile now uses the here package to build the filepath, which should ensure cross-platform compatibility (I tested it on Mac OS and Windows 10).

Can you try downloading the latest version from GitHub and checking it it works?

from oxforddown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.