alapo / Literate-Programming

This is the repository for the Literate Programming Workshop
39 stars 11 forks source link

Unable to add exported .bib to YAML and insert a figure #18

Closed Danika4321 closed 5 months ago

Danika4321 commented 5 months ago

Hello,

Im trying to add my own exported .bib file to the YAML as shown in the video, so that I can link it to the document, but I get an error when trying to knit. My exported Zotero bibliography is called Test2.bib, I have it on my desktop which I thought might be an issue but when I moved it to my documents I got the same error. Ive looked for solutions online and made sure the directory was the same.

This is my YAML:

date: "`r Sys.Date()`"
author: "Danika Walsh"
title: "My project test 1"
output: 
  officedown::rdocx_document:
    reference_docx: styles/template.docx                  # This is the template that will style my document when its knit
link-citations: yes 
bibliography: styles/Test2.bib
#bibliography: G:/My Drive/ZoteroRPlugin/My Library.bib
zotero: TRUE
csl: styles/Citation Styles/american-physiological-society.csl      # This sets the style of formatting for references in text and bibliography

This is the error I got when pressing knit:

File styles/Test2.bib not found in resource path
Error: pandoc document conversion failed with error 99
Execution halted

When trying to add a figure as well:

{r knit-citations, fig.cap = "Awesome cartoon of knitting citations.", fig.asp=1748/2480, fig.height=6.5} knitr::include_graphics("images/RMarkdown - Citations.png")

I get a similar error, but in the document itself:

Figure [Error! Reference source not found.]

It likely a problem with the directory but I can't seem to figure out what to change. I can see the .bib file il my my files in RStudio Im still learning so I would really appreciate the help.

Thank you so much!

**sessionInfo()**

<img width="976" alt="Screenshot 2024-01-29 at 10 14 02 AM" src="https://github.com/alapo/Literate-Programming/assets/157257679/f8c34bcb-0555-4003-9bfe-0648719fcd7b">
<img width="904" alt="Screenshot 2024-01-29 at 10 14 10 AM" src="https://github.com/alapo/Literate-Programming/assets/157257679/1e404c30-21a7-4e8f-8feb-bcb1d8998788">
alapo commented 5 months ago

Hey Danika,

I need a bit more information, but seems to be a file directory issue. Please see the video below to get started.

IMAGE ALT TEXT HERE

Danika4321 commented 5 months ago

Hi,

I was able to solve the first issue. I tried to get to RStudio from the file like you said and try it from there but I got the same error. The image im trying to use is the one from your example and it is in the images section of MyProjectName file. I find the same thing happens when I try to knit the table I've made with my own data so I think its the same problem. Does this part of the code itself look ok?

{r knit-citations, fig.cap = "Awesome cartoon of knitting citations.", fig.asp=1748/2480, fig.height=6.5} knitr::include_graphics("images/RMarkdown - Citations.png")

This is what I see on the word document:

Screenshot 2024-01-29 at 3 17 35 PM Screenshot 2024-01-29 at 3 18 53 PM Screenshot 2024-01-29 at 1 28 55 PM
alapo commented 5 months ago

What is the name of the Rmd file you are trying to knit?

alapo commented 5 months ago

Also please edit your code chunks when posting. I showed you how to do this in the video :)

Danika4321 commented 5 months ago

Sorry about that, the code should be in the right format now. The rmd file im knitting is the manuscript.rmd and im just trying to add the RMarkdown - citations.png from my images file.

Figure @ref(fig:knit-citations).

{r knit-citations, fig.cap = "Awesome cartoon of knitting citations", fig.asp=1748/2480, fig.height=8} knitr::include_graphics("images/RMarkdown - Citations.png")

alapo commented 5 months ago

Just to confirm, all the other images are working? It's just this one png file that is causing an issue?

Does the manuscript.docx file render? Is there an error message showing up?

IMAGE ALT TEXT HERE

If this still does not fix the issue, I am available over zoom early in the morning.

Danika4321 commented 5 months ago

No, other images or tables that I try to add aren't working either. The manuscript.docx file is rendering and I can make changes to the YAML that appear on the rendered doc. It's just when I try to add figures or tables that it doesn't get added. There's no error in the render box but there is the error on the maniscipt.docx itself which I put a screenshot in the comment above. I followed your video but got the same result. I am at work unfortunately until 4, are you available after then?

Thank you for your help!

alapo commented 5 months ago

Issue was due to looking at the visual editor. Change to the source and document knitted properly