Issue with bibliography in yaml header


#1

I try to create a report template, which works fine as long as I specify the bibliography in the LaTex-Template. If I try to do the same in the yaml header and access it $bibliography$ I receive an error:

! Undefined control sequence.
l.312   \bibliograpgy
                     {F:/Bibliography/Bibliography.bib} 

The header of my document looks like this:

---
title: "Markdown Template"
author: Its Me
date: "`r format(Sys.time(), '%d.%B %Y')`"
output:
  pdf_document:
    citation_package: natbib
    keep_tex: true
    number_sections: true
    template: G:/Work/MarkDown/Templates/ReportTemplate.tex
bibliography: F:/Bibliography/Bibliography.bib
biblio-style: gerplain
natbiboptions: "numbers,super,colon,square"
---

And here my Latex Template:

\documentclass[a4paper,$fontsize$,oneside]{article}

\usepackage[german,ngerman, english]{babel}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}


\usepackage[pdftex]{graphicx}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{upgreek}
\usepackage{hyperref}

\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}


\DeclareGraphicsExtensions{.pdf,.jpg,.png}

$if(natbib)$
  \usepackage{bibgerm}
  \usepackage[$natbiboptions$]{natbib}
$endif$

\begin{document}

\begin{titlepage}
  \begin{center}
  \LARGE
  \textrm{$title$}
  \end{center}
  \vspace{10pt}
  \textrm{$author$,  $date$}\\
\end{titlepage}

$body$

\clearpage
\newpage

$if(natbib)$
  \bibliography{F:/Bibliography/Bibliography.bib}
  %\bibliograpgy{$bibliography$}
  \bibliographystyle{$biblio-style$}
$endif$


\end{document}

#2

I'm not sure what the best approach is for fixing this, but YAML is definitely sensitive to colons (since it's what designates the break between key-value pairs).

This thread has a few different approaches (including just quoting the string):

as does this StackOverflow thread:


#3

Hi Mara,
thanks for the quick reply.
I guess I failed to express my problem properly. It's not the natbiboptions with it's commas in my yaml - this works. I'm just not able to access the bibliography as a variable in my LaTex code by \bibliography{bibliography}.
I've to write in LaTeX \bibliography{F:/Bibliography/Bibliography.bib} to make it work.


#4

Seems to be a typo:

l.312   \bibliograpgy

maybe bibliography instead of bibliograpgy will fix your problem