2

In my .Rmd file, I refer to position in .bib file as follows: "Let me cite an article: [@SampleTitle2016]"

When I 'knit the current', I would like to have .tex file where citations to articles are provided by \cite, \citep or \citet command.

I noticed that if I omit the line 'citation_package: natbib' in output params, citations are provided as a raw text:

how it looks without natbib

However, If add mentioned line, .tex file looks better, but for some reason, bibliography is unable to properly display / (compile?) - I see "?" instead of proper citations:

how it looks with natbib

My .Rmd looks as follows:

---
title: "Sample document"
abstract: "This is a sample abstract \\newline This is the second line of abstract \\par \\textbf{Keywords:} keywordA, keywordB"
author:
  - name: Mateusz Kędzior
    email: alice@example.com
    affiliation: Some Institute of Technology
    footnote: Corresponding Author
bibliography: bibliography_escaped.bib
output:
  bookdown::pdf_book:
    base_format: rticles::elsevier_article
    keep_tex: true
    citation_package: natbib
---

## Sample Text

Let me cite an article: [@SampleTitle2016].

Without natbib, in .tex file citep  command is not used in output .tex file.

An with natbib, it seems there's problem with bibliography compilation.

## References

My bibliography file looks as follows:

@article{SampleTitle2016,
    title = "This is sample title only \{\k{A}\} \{\L{}\}",
    journal = "Some journal",
    volume = "99",
    number = "",
    pages = "21 - 31",
    year = "2018",
    note = "This is fake",
    url = "http://ImustChangedThatLinkBecauseSOdoNotALLOWletmeG",
    author = "Mateusz K\k{e}dzior and \.{Z}\k{a}\'{c}\l{} \'{Z}\k{e}\'{n}",
    keywords = "keywordC",
    keywords = "Keyword D",
}

@article{OtherTitle2010,
    title = "{{This is different \k{A} title only}}",
    journal = "Some journal",
    volume = "150",
    number = "",
    pages = "21 - 31",
    year = "2020",
    note = "This is fake",
    url = "http://someLink/",
    author = "\.{Z}\k{a}\'{c}\l{} \'{Z}\k{e}\'{n}",
    keywords = "keyword\k{A}",
    keywords = "Keyword \'{Z}",
}
matandked
  • 1,527
  • 4
  • 26
  • 51
  • What is the reason not to use `rticles::elsevier_article` as output? With that output in the YAML header, all works fine. – J_F Feb 22 '17 at 08:59
  • Because I will need to refer to figures \@ref(fig:pressure), tables and subsections \@ref(sub-sub-section-plot) in my document. Correct me if I am wrong, but only 'bookdown' provides any possibilities of cross-referencing? I asked about it on SO: http://stackoverflow.com/questions/42331136/cross-referencing-in-rticles/42366166#42366166 – matandked Feb 22 '17 at 09:10
  • You can refer to figures, see this example:` ```{r plot1, fig.height=5, fig.width=5, fig.cap= "Plot 1 \\label{fig:plot1}"} plot(1:10, 1:10) ``` See for example Figure \ref{fig:plot1}` – J_F Feb 22 '17 at 14:17
  • I think this is rather workaround since you place label within the caption. I mentioned that in following issue: https://github.com/rstudio/rticles/issues/103 – matandked Feb 22 '17 at 14:38
  • But anyway, thank you for help – matandked Feb 22 '17 at 17:21
  • Dealt with the same issue, but found that it was solved by adding `\bibliography{bibfilename}` as the last line of the rmd file – PieterD Aug 24 '21 at 21:17

0 Answers0