How to render citation within a beamer subtitle in Rmarkdown - latex

I'm trying to combine both adding subtitles to beamer frames and rendering citations inside them in Rmarkdown. In LaTeX I've been able to do this with the following code:
\begin{frame}{Kontrastive Analyse: Russisch-Deutsch}
\framesubtitle{Phonetik und Phonologie kontrastiv: Russisch und Deutsch \parencite{kuemmelPhonetikundPhonologieRussischundDeutsch2017}}
...
\end{frame}
However, I'm having a hard time doing the same in Rmarkdown, where I have the bibliography defined in the YAML on the one hand and on the other hand also defined in the custom tex header.
So far, I've explicitly written the frame subtitle as LaTeX code (because I currently don't know how subtitles can be made in Rmarkdown beamer format; pipe character doesn't seem to work) and within the subtitle code use biblatex's \parencite{}, as follows
\framesubtitle{with a subtitle \parencite{kuemmelPhonetikundPhonologieRussischundDeutsch2017}}
So while the rest of citations written in markdown format (i.e. [#citekey]) are rendered without problem, citations within subtitles aren't. How can I solve this?
Here's the code so far:
---
title: "Presentation Title"
subtitle: "Subtitle"
author: |
| [Name]
| \scriptsize [Email]
institute: |
| [Institution]
| [Faculty]
| [Institute/Department]
| [Seminar]
| [Professor]
| [Semester]
date: \today
output:
beamer_presentation:
latex_engine: xelatex
keep_tex: TRUE
slide_level: 3
includes:
in_header: "myacademic-preamble.tex"
classoption: aspectratio=169
link-citations: true
bibliography: '/Users/marco-andres/Documents/Zotero+Pandoc/MyLibrary.bib'
csl: '/Users/marco-andres/Documents/Zotero+Pandoc/institut-slawistik-hu-berlin.csl'
---
\frametitle{Table of Contents}
\tableofcontents
# This is a dividing slide
## This is another dividing slide (subsection shown in TOC)
### Here's an individual slide
\framesubtitle{with a subtitle (Kümmel 2017)}
# Bibliography
\printbibliography
The custom .tex relevant for LaTeX-style bibliography is:
%Bibliography and language
\usepackage[english]{babel} %section and bibliography langauge
\usepackage{csquotes}
\usepackage[style=authoryear, sorting=nyt]{biblatex} %bibliography style
\addbibresource{MyLibrary.bib} %bib file

Related

position of table of contens and searchable files with Quarto (PDF output)

is there a Quarto way to
place the table of contens (TOC) where I like it. Like for references (Bibliography Generation)
::: {#refs}
:::
(for LaTeX please see answer in comment from #shafee for further information)
toc: false
```{=latex}
\tableofcontents
```
create Copy-paste-able/searchable PDF files TeX FAQ
header-includes:
- \usepackage{mmap}
replace default title page, is there something like toc: false? https://en.wikibooks.org/wiki/LaTeX/Title_Creation
\begin{titlepage}
\end{titlepage}

Rmarkdown Latex citation (Harvard style) within footnote

I am writing my thesis in Rmarkdown and Latex with a seperate literature.bib file that contains the bibtex sources. I now have a footnote and I would like to have a citation like in the normal text, but within the footnote. Is there any package to achieve that? When i just try it, like I would have a citation in the normal text, the footnote stops beeing a footnote when i render to pdf. The citation style I use is the Harvard citation style, so only something like this appears and should appear in the footnote:
The rest of information is than provided under the heading References at the end of the document. Thanks in advance! I appreciate any help...!
Here a minimal reproducable example:
--> This is the code for the main .rmd file
---
output:
bookdown::pdf_document2:
toc: no
papersize: a4
geometry: margin = 1in
fontsize: 11pt
bibliography: literatur.bib
---
#TEST
This is just an example #test.\footnote{I would also like to have a citation here in this footnote!!}
\newpage
# References
<div id="refs"></div>
-->This is the code for the literatur.bib file
#online{test,
author = {PACER},
title = {Service Center},
url = {https://pcl.uscourts.gov},
urldate = {2021-09-10}
}
Hope that is helpful?!
If you use markdown syntax for the footnote, you can also insert the citation via markdown syntax:
---
output:
bookdown::pdf_document2:
toc: no
papersize: a4
geometry: margin = 1in
fontsize: 11pt
bibliography: literatur.bib
---
#TEST
This is just an example #test.^[I would also like to have a citation here in this footnote!! See [#test]]
\newpage
# References
<div id="refs"></div>

Equivalent of \usepackage[round]{natbib} in Rmarkdown yaml

This question is related to Is there a way to keep LaTeX citation keys in .tex file when knitting r-markdown to PDF. Using natbib and xelatex resulted in in-text citations with square parentheses, such as [First et al., 2020] but I need round parentheses: (First et al., 2020). Switching around different latex engines or pdf_document or pdf_document2 does not change this behavior.
I prefer pdf_document2 to accommodate some of my tables better than what pdf_document does. Here is my yaml
title: "abc"
output:
bookdown::pdf_document2:
keep_tex: true
toc: false
latex_engine: lualatex
citation_package: natbib
bibliography: ref.bib
csl: apa-no-ampersand.csl
As stated here https://tex.stackexchange.com/questions/466819/use-round-brackets-instead-of-square-brackets-in-natbib-citations, I can edit my .tex file to set the parenthesis style, upload it to a tex processing program, then download the pdf, but that's quite inefficient.
Any leads to how to render in-text citations in round parentheses straight from R are much appreciated.
Just specify your natbiboptions. If you use BibLaTeX, then you can set biblatexoptions. If you want to specify multiple options, use a list notation with - (two-space indent and hyphen). If you want to comment out an option, use #.
title: "abc"
output:
bookdown::pdf_document2:
keep_tex: true
toc: false
latex_engine: lualatex
citation_package: natbib
bibliography: ref.bib
natbiboptions: round
biblatexoptions:
- sortcites = true
- sorting = nyt
- backend = biber
# - maxcitenames = 2

Fancyhead for unnumbered appendix in R Markdown knit to pdf

A question about fancyhdr in R Markdown knitting to pdf.
Can anyone help me to fix the header for the appendix? I have numbered sections in the document, and the fancyhead for pages with the numbered sections is oke. But for the unnumbered appendix, it keeps showing the last numbered section, where I just want the title of the current unnumbered appendix to be shown. Code example below. Thanks!
---
title: "Example"
output:
pdf_document:
number_sections: true
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
---
\newpage
# Chapter
\newpage
# Appendix {-}
You can adjust the header like this:
---
title: "Example"
output:
pdf_document:
number_sections: true
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
---
\newpage
# Chapter
\newpage
# Appendix {-}
\markboth{something here}{something there}

pandoc "titleformat" ruler

I have an issue with YAML datablock. Given the following pandoc document:
---
papersize: a4
geometry: "left=1.5cm,right=1.5cm,top=3cm,bottom=3cm"
fontsize: 12pt
# https://stackoverflow.com/a/43659664/2069099
subparagraph: yes
#documentclass: extarticle
header-includes:
- \usepackage[explicit]{titlesec}
- \titleformat{\section}[hang] {\filleft\huge\sc} {label}{20pt}{#1}
---
Hello World
===========
Lorem ipsum
I correctly get my title aligned on the right. Now, suppose I need a full-width ruler below the title, as stated in https://tex.stackexchange.com/a/84062, one need to modify \titleformat statement as:
---
papersize: a4
geometry: "left=1.5cm,right=1.5cm,top=3cm,bottom=3cm"
fontsize: 12pt
# https://stackoverflow.com/a/43659664/2069099
subparagraph: yes
#documentclass: extarticle
header-includes:
- \usepackage[explicit]{titlesec}
- \titleformat{\section}[hang] {\filleft\huge\sc} {label}{20pt}{#1}[\titlerule\vspace*{4pt}]
---
Hello World
===========
Lorem ipsum
but this leads to the following error:
Error producing PDF.
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.49 {[
and, indeed, the tex file shows weird code:
...
\usepackage[explicit]{titlesec}
\titleformat{\section}[hang] {\filleft\huge\sc} {label}{20pt}{#1}
{[}\titlerule\vspace*{4pt}{]}
\date{}
\begin{document}
...
OK, passing plain Latex in YAML block solved the issue:
--
papersize: a4
geometry: "left=1.5cm,right=1.5cm,top=3cm,bottom=3cm"
fontsize: 12pt
# https://stackoverflow.com/a/43659664/2069099
subparagraph: yes
#documentclass: extarticle
header-includes:
- \usepackage[explicit]{titlesec}
- |
```{=latex}
\titleformat{\section}[hang] {\filleft\huge\sc} {label}{20pt}{#1}[\titlerule\vspace*{4pt}]
```
---
Hello World
===========
Lorem ipsum
Pandoc parses part of that line as Markdown. So when the line is written as LaTeX, special characters are escaped to ensure that is produces the same text as the input. This is undesired here, and the best solution is to explicitly mark the line as LaTeX:
header-includes:
- \usepackage[explicit]{titlesec}
- `\titleformat{\section}[hang] {\filleft\huge\sc} {label}{20pt}{#1}`{=latex}
One could also mark the whole header includes like so:
header-includes: |
```{=latex}
\usepackage[explicit]{titlesec}
\titleformat{\section}[hang] {\filleft\huge\sc} {label}{20pt}{#1}
```

Resources