Reputation: 61
I'm having a problem with including a Bibtex citation in my RMarkdown file. My RMarkdown file looks like this:
---
title: "Untitled"
author: "Three Authors"
documentclass: article
bibliography: mybib.bib
output:
pdf_document:
number_sections: true
fig_caption: true
citation_package: natbib
fontsize: 12pt
geometry: margin = 1in
---
# Introduction
This is the introduction [@sutton2008].
# References
And, my .bib file includes
@article{sutton2008,
author = {A. J. Sutton and J. P Higgins},
title = {Recent developments in meta‐analysis},
journal = {Statistics in medicine},
year = {2008},
volume = {27},
number = {5},
pages = {625-650}
}
I was expecting to see a citation in my compiled file. However, when I knitted the .Rmd file, it threw an error message
! Package inputenc Error: Unicode char ‐ (U+2010)
(inputenc) not set up for use with LaTeX.
Error: Failed to compile main.tex. See main.log for more info.
Execution halted
The main.log file includes a very long message, but towards the ends it says
Package natbib Warning: Citation `sutton2008' on page 1 undefined on input line
93.
(./main.bbl
! Package inputenc Error: Unicode char ‐ (U+2010)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
I'm using RStudio Version 1.1.383, on Ubuntu 16.04. Thanks in advance for your help.
Upvotes: 3
Views: 4167
Reputation: 61
After several trials, I've managed to insert a citation successfully. One thing that I've noticed I didn't mention in my question was that I started to write this manuscript in Latex and I created the .bib file there. Then, I copied that .bib file to the directory where I work on my R Markdown file. I think that led to a unicode problem (as it was mentioned in the error code). Then, I deleted everything in this .bib file, and entered the citation entry again by typing it. I saved the new form of the .bib file, and when I compiled the R Markdown file, it inserted the citation correctly into the .pdf file. So, I think there was a unicode problem. Maybe there was a more efficient solution by converting the .bib file to the correct unicode form (I think it is UTF-8 to use Bibtex in RMarkdown), but I couldn't find a way to do it.
Upvotes: 3