I am making a book with bookdown. The HTML version renders exactly as I would expect it to.
For example, the
5. Read Chapter 7 of Myers
[-#myers_2013_qualitativeresearchbusiness p. 73--91] — 60 minutes.
Renders correctly as:
Read Chapter 7 of Myers (2013, pp. 73–91) — 60 minutes.
However, in the PDF version the citation is rendered as the bibtex key; i.e.,
5. Read Chapter 7 of Myers (myers_2013_qualitativeresearchbusiness) — 60 minutes.
My script does the follwing to make the pdf.
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book')"
and my _output.yml looks like this:
bookdown::gitbook:
css: style.css
split_bib: no
config:
toc:
collapse: section
before: |
<li>Qualitative Research Methods</li>
after: |
<li>Published with bookdown</li>
edit: https://github.com/psmith1303/business705/edit/master/%s
download: ["pdf", "epub"]
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: lualatex
citation_package: biblatex
keep_tex: yes
bookdown::epub_book: default
The actual pandoc command that gets run at the end of all this is:
/usr/local/bin/pandoc +RTS -K512m -RTS business705.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output business705.tex --table-of-contents --toc-depth 2 --template /usr/home/psmith/NAS/Programming/R/Libs/rmarkdown/rmd/latex/default-1.17.0.2.tex --number-sections --highlight-style tango --latex-engine lualatex --biblatex --include-in-header preamble.tex --variable graphics=yes --variable 'geometry:margin=1in' --variable tables=yes --standalone --bibliography book.bib
I suspect I need to run the latex 'engine' again to to get the citations right, but I can't figure out how to do that.
So, the fix seems to have been to move from pdflatex to xelatex as the LaTeX engine. I did this by changing _output.yml
bookdown::gitbook:
css: style.css
split_bib: no
config:
toc:
collapse: section
before: |
<li>Qualitative Research Methods</li>
after: |
<li>Published with bookdown</li>
edit: https://github.com/psmith1303/business705/edit/master/%s
download: ["pdf", "epub"]
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: biblatex
keep_tex: yes
bookdown::epub_book: default
(That was a non-trivial exercise for me, I had to throw out my texlive installation, and switch to TinyTex to get biber working correctly).
Related
I want to export the .pdf created using .Rmd. It works if I remove the rmarkdown::render chunk at the yaml header, but
---
title: "LHD_generation"
author: "hcghkgvjv"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
pdf_document:
toc: yes
toc_depth: 3
html_notebook:
toc: yes
toc_depth: 3
toc_float: yes
html_document:
theme: simplex
highlight: kate
fig_caption: yes
fig_height: 4
fig_width: 6
toc: yes
toc_float: yes
toc_depth: 3
# word_document:
# toc: yes
# toc_depth: 3
knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile, encoding = encoding,
output_file = paste0(dirname(inputFile), "/../Results",
'/LHD_generation.pdf'), output_format = "pdf_document")})
---
throws the following error when I include it. I also get LHD_generation.tex in the Results folder but then the process throws error & halts.
output file: LHD_generation.knit.md
/Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/pandoc +RTS -K512m -RTS LHD_generation.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandocd714116efe8f.tex --lua-filter /Users/massisenergy/Library/R/x86_64/4.2/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/massisenergy/Library/R/x86_64/4.2/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --table-of-contents --toc-depth 3 --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in'
Error: LaTeX failed to compile /Users/massisenergy/Library/Mobile Documents/com~apple~CloudDocs/Sync/inSilicoE3DBP_model_MRE/Analysis/../Results/LHD_generation.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
Execution halted
Any ideas on how to make it work?
I came through the following links, but no avail.
R Markdown - variable output name
rendering images in parameterized rmarkdown reports causes pdflatex to fail
Knitr hook to postprocess pdf output?
Rmarkdown custom knit hook to compile a multi part document
I'm trying to create a book with bookdown as pdf. It works well creating an EPUB file.
My YAML is this:
---
title: "Title Here"
subtitle: "Subtitle here"
author: "me"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib]
biblio-style: apalike
link-citations: yes
description: "description goes here."
cover-image: "cover.png"
lang: "es"
always_allow_html: true
output:
pdf_document:
latex_engine: xelatex
pdf_document2:
latex_engine: lualatex
---
At some point in chapter 4 I have a Japanese letter, U+305B.
I've tried creating the pdf book with:
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_document2())
and
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_book())
Both of them complain that:
! Package inputenc Error: Unicode character せ (U+305B)
(inputenc) not set up for use with LaTeX.
and recommend me to check this part of the rmarkdown cookbook. From there is where I took the 4 last lines of the YAML preamble.
I couldn't help but noticing that the call to pandoc is taking pdflatex as the pdf-engine (see third-to-last line):
/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS myFileName.knit.md --to latex
--from markdown+autolink_bare_uris+tex_math_single_backslash
--output herramientasBasicasMejoramiento.tex
--lua-filter /usr/local/lib/R/site-library/bookdown/rmarkdown/lua/custom-environment.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua
--metadata-file /tmp/RtmpAbwGga/file565f3d087e3c --self-contained
--table-of-contents --toc-depth 2 --number-sections
--highlight-style tango --pdf-engine pdflatex --variable graphics
--wrap preserve --variable tables=yes
--standalone -Mhas-frontmatter=false --citeproc
I'm working in Ubuntu and have installed both texlive and tinytex.
whereis xelatex
xelatex: /home/gp/bin/xelatex /usr/local/texlive/2019/bin/x86_64-linux/xelatex
There is an unanswered question with a problem that looks similar.
What am I doing wrong, and what can I do to make it work?
You need to specify the output format in a way that will see your latex_engine argument, e.g.
bookdown::render_book("index.Rmd", output_format = "pdf_document2")
(naming one of the output formats from your YAML), or
bookdown::render_book("index.Rmd",
output_format = bookdown::pdf_document2(latex_engine = "xelatex"))
(specifying it independently).
I am writing a thesis template according to very specific University rules, and RMarkdown won't let me include a page with the bibliography pdflatex + bibtex + pdflatex with a regular .tex file
So far I have this:
output:
pdf_document:
latex_engine: pdflatex
template: formato-uchile.tex
keep_tex: no
citation_package: biblatex
bibliography: bibliografia.bib
---
Here is the full document https://github.com/pachamaltese/template-tesis-uchile/blob/master/tesis-rmarkdown.Rmd
How can I include that bibliography page?
You do not have to indent bibliography line in the YAML section.
---
output:
pdf_document:
latex_engine: pdflatex
template: formato-uchile.tex
keep_tex: no
citation_package: biblatex
bibliography: bibliografia.bib
biblio-style: path/to/your/style-file-without-file-extention
---
As mentioned here, your bibliography will be shown in the end of the section. This is automatic, so you may need TeXing to change the order of the bibliography and appendices. If you want to do so, I highly recommend you to set keep_tex: yes so that you can get .tex file to edit.
I have a beamer rmarkdown file for preparing PDF presentation as teaching material. However, when I click knit with pdf, the output is displayed in html document, instead of beamer_presentation (pdf). my yaml is:
Thanking all in advance.
Earlier it was knitting properly but after some time it started giving this problem I have checked all 'helps' at various forums, but the problem persists. I have even installed tinyverse and installed/removed MikTex and restarted the system to solve the problem.
---
title: "Mathematics for Finance"
author:
- Dr. XXXX
institute:
- YYYY
date: "June-July 2019"
output:
beamer_presentation:
incremental: false
theme: "AnnArbor"
colortheme: "wolverine"
fonttheme: "structuresmallcapsserif"
toc: true
slide_level: 2
fig_width: 5
fig_height: 4
fig_caption: true
highlight: tango
link-citations: yes
urlcolor: red
linkcolor: red
citecolor: blue
---
No error message is displayed, simply HTM document is executed that too blank!
"C:/Users/Kulbirs/ANACON~1/envs/rstudio/Scripts/pandoc" +RTS -K512m -RTS beamertest1.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output beamertest1.html --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\Kulbirs\Documents\R\win-library\3.6\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\Kulbirs\AppData\Local\Temp\RtmpgnjFVR\rmarkdown-str56854a3563d.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --metadata pagetitle=beamertest1.utf8.md
Output created: beamertest1.html
The problem are the lines
link-citations: yes
urlcolor: red
linkcolor: red
citecolor: blue
If you really, really, really want to have coloured links, you could add
header-includes:
- \hypersetup{colorlinks, urlcolor=red, linkcolor=red, citecolor=blue}
to your header, but this is really, really, really a bad idea with beamer, because this breaks all carefully chosen design decisions made by your theme.
[My environment: Win 7 Pro / R 3.2.1 / knitr_1.12.3 / R Studio Version 0.99.892]
I am trying to write an article in .Rmd format using R Studio, Knit -> PDF, and I've been following http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html for details of how to get pandoc and pandoc-citeproc to produce a References section and citations
in the text.
My BibTeX references are in several different .bib files, which, when using
LaTeX in .Rnw files, are all found in my local texmf tree via
\bibliography{statistics, graphics}
I can't seem to make this work with pandoc-citeproc. My YAML header
has the following, that works for one .bib file, as long as it is
in the same directory as the source .Rmd file:
---
title: "Notes on Testing Equality of Covariance Matrices"
author: "Michael Friendly"
date: '`r format(Sys.time(), "%B %d, %Y")`'
output:
pdf_document:
fig_caption: yes
keep_tex: yes
number_sections: yes
csl: apa.csl
bibliography: statistics.bib
---
Following advice in the link given above, I tried:
bibliography: [statistics.bib,graphics.bib]
this gives:
pandoc-citeproc.exe: "stdin" (line 50, column 12):
unexpected ":"
expecting letter, digit, white space or "="
pandoc.exe: Error running filter pandoc-citeproc
Filter returned error status 1
[Edit: For completeness, I show the generated pandoc command, where it looks like both .bib files are passed correctly]:
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS EqCov.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output EqCov.pdf --template "C:\R\R-3.2.1\library\rmarkdown\rmd\latex\default-1.15.2.tex" --number-sections --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --bibliography statistics.bib --bibliography graphics.bib --filter pandoc-citeproc
output file: EqCov.knit.md
So do all the following forms:
bibliography: ["statistics.bib","graphics.bib"]
bibliography:
- "statistics.bib"
- "graphics.bib"
bibliography:
- statistics.bib
- graphics.bib
Ideally, I'd like to be able to use one of the following forms, and not have to copy the .bib files to the document directory.
bibliography: ["C:/Dropbox/localtexmf/bibtex/bib/statistics.bib","C:/Dropbox/localtexmf/bibtex/bib/graphics.bib"]
bibliography:
- "C:/Dropbox/localtexmf/bibtex/bib/statistics.bib"
- "C:/Dropbox/localtexmf/bibtex/bib/graphics.bib"
For the record: I raised this as an issue for pandoc-citeproc at https://github.com/jgm/pandoc-citeproc/issues/220
It turns out that there were problems in how pandoc-citeproc handles some characters in #{string={}} and non-ASCII characters in .bib files, so what I was trying now works, with hard-coded pathnames, in all the forms I tried.
To make it work more like processing of .Rnw files via Latex/bibtex it would be nice to be able to use something like
bibliography:
- `r system(kpsewhich statistics.bib)`
- `r system(kpsewhich graphics.bib)`
Those commands do find the right files in an R session, but not from a YAML header.