My .rmd file fails to compile when including citations as a .bib file.
I attached the code and error message here and very appreciate if someone could help.
The indentation of the YAML options is important. You currently have bibliography within the output section, but it should be placed in as a top-level YAML.
title: "Title"
author: "Author"
output:
pdf_document:
keep_tex: true
bibliography: bib.bib
Edit: Make sure you have moved the bibliography out of the pdf_document options completely, as follows:
author: "Author"
output:
pdf_document:
keep_tex: true
fig_caption: yes
number_sections: yes
bibliography: bib.bib
---
Related
When I use RStudio to Generate PDF File,I Met this Error :
Missing number, treated as zero.
<to be read again>
(
l.349 \begin
{minipage}[b]{\linewidth}\raggedright
错误: LaTeX failed to compile bookdown.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See bookdown.log for more info.
停止执行
When I open the tex file:
\begin{minipage}[b]{\linewidth}\raggedright
独立性和可持续性
\end{minipage}
the Rmd file is
---
CJKmainfont: PingFangSC-Regular
fontsize: "12pt"
indent: true
header-includes:
- \usepackage{xeCJK}
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
toc: yes
toc_depth: 1
template: latex/template.tex
documentclass: ctexbook
link-citations: yes
geometry: [b5paper, tmargin=2.5cm, bmargin=2.5cm, lmargin=3.5cm, rmargin=2.5cm]
colorlinks: yes
---
latex/template.tex:
https://github.com/yihui/bookdown-chinese/blob/master/latex/template.tex
How can I fix it? if I comment the code (#template:latex/template.tex) the Errors would be gone
You will successfully render the following Rmd to a pdf without any error.
Although #Stéphane Laurent commented here that you may need to add a diameter to \linewidth, I do not think that is cause of the problem you faced, since the Rmd below using \linewidth, not 1\linewidth, works fine.
The real problem may lay in other parts of your Rmd file, I suspect. However, you must post a reproducible example like the one I show in this answer, as I commented here, and present the contents of the .log file that is created when you knit your Rmd file.
---
header-includes:
- \usepackage{ctex}
output:
pdf_document: default
---
\begin{minipage}[b]{\linewidth}\raggedright
独立性和可持续性
\end{minipage}
In my Rmarkdown project, I'm having trouble in correctly exporting ligatures in PDF file.
font-config.tex file -
\usepackage{fontspec}
\setmainfont{Noto Sans}
YAML front-matter in Rmd file -
---
title: "test"
author: "author"
date: "22/02/2021"
output:
pdf_document:
latex_engine: xelatex
includes:
in_header: font-config.tex
---
The following text is in hindi language.
गुरु
Output shown in PDF -
Output expected -
The Nakula font is correctly displayed, but it does not have bold-face type font.
The Noto Sans font I'm using works fine in html output, but have problem with ligature in PDF output.
I tried, the pandoc documentation and other similar questions on stackoverflow and tex.stackexchange, but no luck.
I'm new to TeX, and hopefully it has a very simple solution.
This may work for you, following the information given here:
---
title: "Hindi"
author: "bttomio"
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{fontspec}
- \setmainfont{Noto Sans}
- \usepackage{polyglossia}
- \setdefaultlanguage{hindi}
- \setotherlanguage{english}
- \newfontfamily\devanagarifont[Scale=MatchUppercase]{Nakula}
- \newfontfamily\devtransl[Mapping=DevRom]{Times New Roman}
---
The following text is in hindi language.
गुरु
-output
I have a Rmd (see bellow) file and when I execute the file without toc and pandoc I am able to get the title and author, but with them I am not able to see them. How can I get my title and author name to appear with numbered sections and toc?
---
title: "Design"
author: "Jen"
output:
html_document:
toc: true
pandoc_args: [
"--number-sections"
]
---
# plots
You should give rmarkdown full control over the pandoc arguments:
---
title: "Design"
author: "Jen"
output:
html_document:
toc: true
number_sections: true
---
# plots
Source: https://bookdown.org/yihui/rmarkdown/html-document.html#section-numbering
The help file of the pdf_document function of the Rmarkdown CRAN package says that the function is defined with the following options:
pdf_document(toc = FALSE, toc_depth = 2, number_sections = FALSE,
fig_width = 6.5, fig_height = 4.5, fig_crop = TRUE,
fig_caption = TRUE, dev = "pdf", df_print = "default",
highlight = "default", template = "default", keep_tex = FALSE,
latex_engine = "pdflatex", citation_package = c("none", "natbib",
"biblatex"), includes = NULL, md_extensions = NULL,
pandoc_args = NULL, extra_dependencies = NULL)
I am under the impression that I could add any of these arguments as options under pdf_document in the output section of the YAML header in my Rmarkdown document. Is this correct? The document managed to compile when I used the following options/arguments of pdf_document: toc, number_sections, fig_caption, df_print, and keep_tex. However, when I add citation_package to the list, I get an error in compiling. For instance, consider the following template Rmarkdown document.
---
title: "Untitled"
author: "Unknown"
date: "4/18/2019"
output:
pdf_document:
# toc: true
number_sections: true
fig_caption: true
df_print: kable
keep_tex: true
citation_package: biblatex
bibliography: sample_bib.bib
csl: /Users/Shared/Zotero/styles/multidisciplinary-digital-publishing-institute.csl
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
I love R [#rcoreteamLanguageEnvironmentStatistical2018].
The sample_bib.bib mentioned is the bib file that looks like
#software{rcoreteamLanguageEnvironmentStatistical2018,
location = {{Vienna, Austria}},
title = {R: {{A Language}} and {{Environment}} for {{Statistical Computing}}},
url = {https://www.R-project.org/},
version = {3.5.1},
organization = {{R Foundation for Statistical Computing}},
date = {2018},
author = {{R Core Team}}
}
However, I was unable to knit this Rmarkdown document. I got the following error.
/usr/local/bin/pandoc +RTS -K512m -RTS rmarkdown_pdf_document.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output rmarkdown_pdf_document.tex --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --number-sections --highlight-style tango --pdf-engine pdflatex --biblatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes'
output file: rmarkdown_pdf_document.knit.md
INFO - This is Biber 2.7
INFO - Logfile is 'rmarkdown_pdf_document.blg'
INFO - Reading 'rmarkdown_pdf_document.bcf'
INFO - Found 1 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex format file 'sample\_bib.bib' for section 0
ERROR - Cannot find 'sample\_bib.bib'!
INFO - ERRORS: 1
Error: Failed to build the bibliography via biber
Execution halted
Warning message:
LaTeX Warning: Citation 'rcoreteamLanguageEnvironmentStatistical2018' on page 1
undefined on input line 137.
LaTeX Warning: Empty bibliography on input line 169.
Package rerunfilecheck Warning: File `rmarkdown_pdf_document.out' has changed.
(rerunfilecheck) Rerun to get outlines right
(rerunfilecheck) or use package `bookmark'.
LaTeX Warning: There were undefined references.
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex) rmarkdown_pdf_document
(biblatex) and rerun LaTeX afterwards.
Luckily, this problem is easily fixed by moving the "citation_package" from an option under pdf_document to a separate line in the YAML header. Or:
---
title: "Untitled"
author: "Unknown"
date: "4/18/2019"
output:
pdf_document:
# toc: true
number_sections: true
fig_caption: true
df_print: kable
keep_tex: true
citation_package: biblatex
bibliography: sample_bib.bib
csl: /Users/Shared/Zotero/styles/multidisciplinary-digital-publishing-institute.csl
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
I love R [#rcoreteamLanguageEnvironmentStatistical2018].
Upon knitting this adjusted Rmarkdown document, the result is a pdf_document.
So my question is: Was I right that you could add any of the arguments found in the pdf_document help file on CRAN as options under "pdf_document" in the YAML header in a Rmarkdown file? Or, upon using this particular citation_package argument/option, could this be a possible bug in the rmarkdown::pdf_document() function?
ALSO POSTED ON RMARKDOWN's GITHUB; see for additional comments.
I have the following preamble:
---
title: "Luke Klein Dissertation MARKDOWN ROUGH DRAFT"
author: "Luke KLEIN"
date: "`r Sys.Date()`"
output:
pdf_document:
toc: true
---
How do I get my title centered on the cover page?
You probably already finished your dissertation :-) but leaving the solution for future reference as i came here through google.
---
title: |
| \vspace{5cm} \LARGE{Luke Klein Dissertation MARKDOWN ROUGH DRAFT}
author: "Luke KLEIN"
date: "`r Sys.Date()`"
output:
pdf_document:
toc: true
---
Using a combination of vspace and hspace you can put the title anywhere you want.
Other combinations of fonts (both size and type) can be seen here:
https://www.sharelatex.com/learn/Font_sizes,_families,_and_styles?nocdn=true
Late to the party, this worked for me :
---
title: "Luke Klein Dissertation MARKDOWN ROUGH DRAFT"
author: "Luke KLEIN"
date: "`r Sys.Date()`"
output:
pdf_document:
toc: true
header-includes:
- \pretitle{\begin{center} \vspace{5cm}}
---