STAT547-UBC-2019-20 / group05

Repository for our team project (group 05)
0 stars 3 forks source link

Knitting PDF #29

Closed iciarfernandez closed 4 years ago

iciarfernandez commented 4 years ago

Hi @yuliaUU @firasm,

I'm running the knit.R script to knit my final report R Markdown into an HTML file and a PDF, but I'm having issues with LaTEX, I remember I never figured it out in STAT545 either.

I was googling a solution & found that I should run these lines in my console install.packages('tinytex') tinytex::install_tinytex()

It took a long time but then I started getting an error and now I have a window popping up constantly on my laptop that says "cmd.exe - Application Error
The application was unable to start correctly(0xc0000142). Click OK to close the application" - but regardless of whether I click OK or close the window, it keeps popping up.

Meanwhile, RStudio error when knitting is "no LaTEX installation detected", but the HTML file is knitted just fine.

Please let me know what I should do.

Thank you, Iciar

yuliaUU commented 4 years ago

@sciclic Do you have MiKTex installed? I think i solved this issue by setting the path to the .exe file in environmental variables: the path should look smth like that if you are on windows: C:\Users\egoro\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64

iciarfernandez commented 4 years ago

@yuliaUU I installed it and kept it in that same directory in my computer, but this is the error that is showing now:

Screenshot (73)

And this is what I see in the path: Screenshot (75)

yuliaUU commented 4 years ago

After setting a path, have you restarted rstudio?

yuliaUU commented 4 years ago

You dont have \bin\x64 in your folder for miktext you need to change the path then

iciarfernandez commented 4 years ago

Where do I get that \bin\x64 though? That's all that showed up after finishing installation

yuliaUU commented 4 years ago

Yes, very weird. Trying to figure out!

yuliaUU commented 4 years ago

@sciclic is there a sub-folder "bin" anywhere in MiKTeX folder?

iciarfernandez commented 4 years ago

No, I've opened all the folders and nothing :( @yuliaUU

iciarfernandez commented 4 years ago

Does it have to do anything with me running these lines of code yesterday since that's the solution I found online?

install.packages('tinytex')
tinytex::install_tinytex()
yuliaUU commented 4 years ago

I think tinytex is alternative, should not interfeere with the otehr program

what about this path?MiKTeX\2.9\bin\ do you have it?

yuliaUU commented 4 years ago

You can try using tinytex and set up a path to the tiny text files

iciarfernandez commented 4 years ago

Screenshot (77)

@yuliaUU This is what MikTeX\2.9\ looks like.

The issue is that I don't know what went wrong with my TinyTeX installation but I tried like 3 times and it just showed up errors with those two lines above. Is there other way to install tinytex or any others?

yuliaUU commented 4 years ago

try from r studio: packages => install => tinytex

will it help? also quit /restart r session

yuliaUU commented 4 years ago

also, did you followed instructionshere? I wonder if you type in window search Mixtext console? will you see it? and maybe through there install updates, see steps here

iciarfernandez commented 4 years ago

@yuliaUU Still trying. I was having issues with installing dash as well so I followed Firas recommendation to update RStudio and my R version. I will let you know once I figure it out & thank you so much for all the help, it's been really frustrating haha.

yuliaUU commented 4 years ago

yep: updating should solve it!

iciarfernandez commented 4 years ago

Okay, there's been progress - it seems to run until the very end and then I get this different error:

!LaTeX Error: Unknown graphics extension: .png)

@yuliaUU

yuliaUU commented 4 years ago

I am not sure what you are trying to dunno but It looks like the issues is when you inserting images like ![pic name](path to the file)

Two ways I found to solve it:

  1. Pit you your PNG file is under the same directory as the Rmd file, you can just use

![test caption](Maps_are_hard.png)

  1. If you use the here package, you have to include it as an inline R expression):

![test caption](r here::here("Maps_are_hard.png")) Not visible because of editing, but you need ` before r and after .png") Without the inline R expression, you meant the character string here::here("Maps_are_hard.png")was literally the file path, but there isn't such a file.

Also, may be this will work? {r, echo=FALSE} knitr::include_graphics("./Maps_are_hard.png")

iciarfernandez commented 4 years ago

Thank you @yuliaUU!

So, I was using knitr::include_graphics(here::here("images", "nameofimage.png"), auto_pdf = getOption("knitr.graphics.auto_pdf", FALSE))

For some reason when I write![test caption](path/nameofimage.png) it says 'no image found' although I am specifying the same path that I specify when I use knitr.

I don't quite understand how to write the inline R expression for the second one, could you attach a screenshot? I'm trying to run it like this:

![]`r here::here("images", "logisticregression2.png")`

But it's still not working.

yuliaUU commented 4 years ago

What about knitr::include_graphics("./images/picname.png")?

yuliaUU commented 4 years ago

I may be wrong but

test `caption`

only can work if images are put in the same place where rmd file is

iciarfernandez commented 4 years ago

@yuliaUU When I try that knitr:: with the path instead, it gives me this error.

Error in knitr::include_graphics("./images/logisticregression.png") : Cannot find the file(s): "./images/logisticregression.png"

I don't understand it because why can it find it with here::here but not with the path?

iciarfernandez commented 4 years ago

Yeah I can see that! That's why I wanted to avoid the ![test caption] because in my repo I've been saving all plots generated from all scripts to the images folder, so I would have to move them all.

yuliaUU commented 4 years ago

Or, remove quotations for the picture path knitr::include_graphics(./images/ logisticregression.png) 

iciarfernandez commented 4 years ago

Nope, error now is Error in Encoding(x) : object '.' not found, and if I add ../ instead of ./ it gives me the same, if I remove . it says Error: unexpected '/' in "knitr::include_graphics(/", and if I remove ./ it says Error in Encoding(x) : object 'images' not found

yuliaUU commented 4 years ago

Pfaff...knitr::include_graphics("images/ logisticregression.png") This one?

iciarfernandez commented 4 years ago

No, I restarted RStudio and finally got it to knit using this ![](r here::here("images", "logisticregression2.png")) syntax. Thank you so much for your help!

yuliaUU commented 4 years ago

Found interesting article here:

knitr::include_graphics(rep('images/ logisticregression.png'))

Sorry for spamming you, this issue is so annoying!