Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render pdf fails #6

Closed
stephenll opened this issue Feb 7, 2014 · 15 comments
Closed

render pdf fails #6

stephenll opened this issue Feb 7, 2014 · 15 comments

Comments

@stephenll
Copy link

@stephenll stephenll commented Feb 7, 2014

Hello,

I was able to use render to create an html document but failed on both windows and osx when trying to create a PDF. I have texlive installed and use it regularly to compile documents using pdflatex.

in R studio I selected new markdown document. Saved it to a local directory. Then ran the following code:

render('test1.Rmd',pdf_document())

On OSX I received an error about needing to install X11. RStudio crashed at that point.

On windows I was able to get an error message in the console.

processing file: test1.Rmd
  |.............                                                    |  20%
  ordinary text without R code

  |..........................                                       |  40%
label: unnamed-chunk-1
  |.......................................                          |  60%
  ordinary text without R code

  |....................................................             |  80%
label: unnamed-chunk-2 (with options) 
List of 2
 $ fig.width : num 7
 $ fig.height: num 6

  |.................................................................| 100%
  ordinary text without R code


output file: test1.knit.md

C:/Users/stephen/AppData/Local/Pandoc/pandoc test1.knit.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-markdown_in_html_blocks --output test1.pdf --filter C:/Users/stephen/AppData/Local/Pandoc/pandoc-citeproc --template C:/Users/stephen/R/win-library/3.0/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable geometry:margin=1in 
pandoc.exe: Error producing PDF from TeX source.
! LaTeX Error: File `article.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Enter file name: 
! Emergency stop.
<read *> 

l.2 \usepackage

Error: pandoc document conversion failed
In addition: Warning message:
running command 'C:/Users/stephen/AppData/Local/Pandoc/pandoc test1.knit.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-markdown_in_html_blocks --output test1.pdf --filter C:/Users/stephen/AppData/Local/Pandoc/pandoc-citeproc --template C:/Users/stephen/R/win-library/3.0/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable geometry:margin=1in' had status 43 
@jjallaire
Copy link
Member

@jjallaire jjallaire commented Feb 7, 2014

I'm not sure about the X11 message. Two things to try:

  1. We use the "cairo_pdf" device by default. Perhaps in your configuration this isn't working as expected. You could try opts_chunk$set(dev = 'pdf') to see if this makes a difference.
  2. We're also calling pdfcrop (perhaps in your config this somehow pulls in X11, no idea how/why though). You could try adding fig_crop = FALSE to your call to pdf_document.

On Windows, that message means that the top level \documentclass{article} directive in the LaTeX template is failing. That's a pretty fundamental error condition indicating that pdflatex can't find assets it should be able to. I don't know how to help debug that other than to make sure that your TeX installation has all the required templates, etc. (was it the basic MikTex or the full install?).

@stephenll
Copy link
Author

@stephenll stephenll commented Feb 7, 2014

Some background that may help:

I am using texlive on both windows and osx. Not miktex on windows.

I regularlly use knitr to produce pdfs in Rstudio and don’t have this problem.

I’ll try to reproduce the error on OSX just using knitr.

From: JJ Allaire [mailto:notifications@github.com]
Sent: Friday, February 7, 2014 4:27 PM
To: rstudio/rmarkdown
Cc: stephenll
Subject: Re: [rmarkdown] render pdf fails (#6)

I'm not sure about the X11 message. Two things to try:

  1.  We use the "cairo_pdf" device by default. Perhaps in your configuration this isn't working as expected. You could try opts_chunk$set(dev = 'pdf') to see if this makes a difference.
    
  2.  We're also calling pdfcrop (perhaps in your config this somehow pulls in X11, no idea how/why though). You could try adding fig_crop = FALSE to your call to pdf_document.
    

On Windows, that message means that the top level \documentclass{article} directive in the LaTeX template is failing. That's a pretty fundamental error condition indicating that pdflatex can't find assets it should be able to. I don't know how to help debug that other than to make sure that your TeX installation has all the required templates, etc. (was it the basic MikTex or the full install?).


Reply to this email directly or view it on GitHub #6 (comment) . https://github.com/notifications/beacon/2936757__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNzM0MTIwMywiZGF0YSI6eyJpZCI6MjUyMTU1MzZ9fQ==--9a53020d2d80d69c576f1d3fe3118d9319553704.gif

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Feb 7, 2014

Mystifying. I would definitely like to sort out what's going on here but we
need more diagnostics. The Mac issue seems like something that's going on
during knitting (since you never see any output). On Windows I have no idea
why you wouldn't be picking up the article.cls -- is there another version
of LaTeX somewhere on the system that pandoc may be trying to use?

On Windows you might also try to run pandoc on a simple test at the command
line. e.g.

pandoc input.md --to latex

On Fri, Feb 7, 2014 at 4:41 PM, stephenll notifications@github.com wrote:

Some background that may help:

I am using texlive on both windows and osx. Not miktex on windows.

I regularlly use knitr to produce pdfs in Rstudio and don't have this
problem.

I'll try to reproduce the error on OSX just using knitr.

From: JJ Allaire [mailto:notifications@github.com]
Sent: Friday, February 7, 2014 4:27 PM
To: rstudio/rmarkdown
Cc: stephenll
Subject: Re: [rmarkdown] render pdf fails (#6)

I'm not sure about the X11 message. Two things to try:

  1. We use the "cairo_pdf" device by default. Perhaps in your configuration
    this isn't working as expected. You could try opts_chunk$set(dev = 'pdf')
    to see if this makes a difference.
  2. We're also calling pdfcrop (perhaps in your config this somehow pulls
    in X11, no idea how/why though). You could try adding fig_crop = FALSE to
    your call to pdf_document.

On Windows, that message means that the top level \documentclass{article}
directive in the LaTeX template is failing. That's a pretty fundamental
error condition indicating that pdflatex can't find assets it should be
able to. I don't know how to help debug that other than to make sure that
your TeX installation has all the required templates, etc. (was it the
basic MikTex or the full install?).

Reply to this email directly or view it on GitHub <
https://github.com/rstudio/rmarkdown/issues/6#issuecomment-34505379> . <
https://github.com/notifications/beacon/2936757__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNzM0MTIwMywiZGF0YSI6eyJpZCI6MjUyMTU1MzZ9fQ==--9a53020d2d80d69c576f1d3fe3118d9319553704.gif>

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-34506694
.

@stephenll
Copy link
Author

@stephenll stephenll commented Feb 8, 2014

Quick updates:

Under windows 8.1 (x64) I uninstalled texlive and installed miktex. On the pandoc website that is the recommended distribution. That worked.

OSX: I was able to get it to render with pdf if I took out the plot(cars). No other plotting in the document. The X11 error message is for wanting to open another RSession after it crashes. I have seen this before when something went wrong with knitr. Knitr does work for me on osx.

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Feb 8, 2014

Hmm...if you change the device to "pdf" instead of "cairo_pdf' and get rid
of pdfcrop does that make a difference on the Mac?

On Fri, Feb 7, 2014 at 7:05 PM, stephenll notifications@github.com wrote:

Quick updates:

Under windows 8.1 (x64) I uninstalled texlive and installed miktex. On the
pandoc website that is the recommended distribution. That worked.

OSX: I was able to get it to render with pdf if I took out the plot(cars).
No other plotting in the document. The X11 error message is for wanting to
open another RSession after it crashes. I have seen this before when
something went wrong with knitr. Knitr does work for me on osx.

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-34520713
.

@stephenll
Copy link
Author

@stephenll stephenll commented Feb 8, 2014

I first needed to require(knitr) before running render otherwise opts_chunk wasn’t recognized.

In my markdown document, as you suggested I had to make the change to dev to pdf and not cairo_pdf.

I tried that earlier today when you first suggested it but I am just learning knitr and didn’t put that option in the correct place. Now that I read more and figured out where to set that it works.

I tried with cairo_pdf and crop set to false and that didn’t work.

Another test...

I took a Rnw document that I have been compiling with knitr directly from inside RStudio, and changed the device to cairo_pdf and while that did not crash RStudio like render did, it did return an error and said to check_dev(i).

The only way knitr and render worked was when the dev is set to pdf.

I also tried CarioPDF, Cario_pdf. None of those worked either.

Stephen

On Feb 7, 2014, at 10:00 PM, JJ Allaire notifications@github.com wrote:

Hmm...if you change the device to "pdf" instead of "cairo_pdf' and get rid
of pdfcrop does that make a difference on the Mac?

On Fri, Feb 7, 2014 at 7:05 PM, stephenll notifications@github.com wrote:

Quick updates:

Under windows 8.1 (x64) I uninstalled texlive and installed miktex. On the
pandoc website that is the recommended distribution. That worked.

OSX: I was able to get it to render with pdf if I took out the plot(cars).
No other plotting in the document. The X11 error message is for wanting to
open another RSession after it crashes. I have seen this before when
something went wrong with knitr. Knitr does work for me on osx.

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-34520713
.


Reply to this email directly or view it on GitHub.

@stephenll
Copy link
Author

@stephenll stephenll commented Feb 8, 2014

Some more info that may help …

I tried to install the package Rgtk2 package. It installed but when I loaded the package RStudio crashed.

I was searching the internet for cariopdf and I came across a webpage about RGtk2 so I tried to install it.

Just messing around. I have never heard of cario or gtk before.

On Feb 7, 2014, at 10:00 PM, JJ Allaire notifications@github.com wrote:

Hmm...if you change the device to "pdf" instead of "cairo_pdf' and get rid
of pdfcrop does that make a difference on the Mac?

On Fri, Feb 7, 2014 at 7:05 PM, stephenll notifications@github.com wrote:

Quick updates:

Under windows 8.1 (x64) I uninstalled texlive and installed miktex. On the
pandoc website that is the recommended distribution. That worked.

OSX: I was able to get it to render with pdf if I took out the plot(cars).
No other plotting in the document. The X11 error message is for wanting to
open another RSession after it crashes. I have seen this before when
something went wrong with knitr. Knitr does work for me on osx.

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-34520713
.


Reply to this email directly or view it on GitHub.

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Feb 8, 2014

Okay, I've switched the default device to "pdf" rather than "cairo_pdf" -- this should mean that everything will work without you doing anything special in your document. I believe that the crash was occurring during the check for "cairo" capabilities (which was also checking for X11 capabilities as a side-effect). Thanks very much for the detailed diagnostics and I'm glad we got to the bottom of this!

@jjallaire jjallaire closed this Feb 8, 2014
@stephenll
Copy link
Author

@stephenll stephenll commented Mar 5, 2014

FYI

It is confirmed there is an issue with pandoc and texlive on windows. There is an outstanding issue being worked on at the pandoc project.

It may be worth mentioning/documenting that if someone wants to generate a pdf using rmakrdown on windows for the time being they should use miktex rather then texlive.

Stephen

On Feb 8, 2014, at 5:31 AM, JJ Allaire notifications@github.com wrote:

Closed #6.


Reply to this email directly or view it on GitHub.

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Mar 5, 2014

Thanks, I just updated the repo README.md and the documentation to include a note on using MiKTeX on Windows.

@cmbarton
Copy link

@cmbarton cmbarton commented May 3, 2015

This is a misdiagnosis on the Mac (I don't know about Windows, but possibly the same). The problem is that RStudio does not have all the programs you need to convert RMarkdown script to PDF. This really needs to be updated in the docs.

So here is what you need:

  1. Pandoc (this may come with RStudio now, but I installed a new version from http://pandoc.org/installing.html
  2. LaTex. This does not come on a Mac nor does it come with RStudio. But you must have it to convert to PDF. The standard MacTex download is enormous (over 2 GB), but you don't need that for making PDF's (or for a lot of other things using LaTex). So get BasicTex which weighs in at a featherweight 100 MB. You can get it at: https://tug.org/mactex/morepackages.html
  3. You are not done yet. You now must install special "Titling" fonts or the conversion will still bomb. The easiest way to get those is through a command line utility for TexLive. But you have to install these as a system administrator. So open a terminal window and type the following and press return (you must be connected to the internet).

sudo tlmgr install titling

  1. Then restart RStudio and you can now get very nice PDF's
@BusyStas
Copy link

@BusyStas BusyStas commented Jun 24, 2015

is there a way to check whether pandoc is installed or not?

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Jun 24, 2015

Try the pandoc_available function

On Wed, Jun 24, 2015 at 4:52 PM STANISLAV PRIKHODKO <
notifications@github.com> wrote:

is there a way to check whether pandoc is installed or not?


Reply to this email directly or view it on GitHub
#6 (comment).

@ablazko
Copy link

@ablazko ablazko commented Oct 7, 2016

@cmbarton Hi Michael, I executed the procedures that you provided and everything was fine during installation (steps 1, 2 and 3), but still getting the error message in rstudio after restarting! I'm just trying to create a .pdf from default version of RStudio (new file > r markdon > pdf).

! LaTeX Error: File `framed.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

l.39 \definecolor

pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted

These are my session infos:

> R.version
               _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          2.3                         
year           2015                        
month          12                          
day            10                          
svn rev        69752                       
language       R                           
version.string R version 3.2.3 (2015-12-10)
nickname       Wooden Christmas-Tree  

@Edited 2016-10-07
I finally solved this issue after executing the following command after @cmbarton steps:

sudo tlmgr install framed

PDFs are ok now! :)

@cmbarton
Copy link

@cmbarton cmbarton commented Oct 13, 2016

Glad you solved it. I'm traveling with intermittent email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.