YAML Header date enumeration issue

I am struggling with an issue in RMarkdown documents where the German date format (inside the YAML Metadata) that starts with 'N. ' gets interpreted as an enumerated item. I know that if I manually write the date I could escape the dot, but I don't know how that would work inside the format function.

This is my Code:

date: "`r format(Sys.time(), '%d. %B, %Y')`"

adding a backslash to escape the dot:

date: "`r format(Sys.time(), '%d\. %B, %Y')`"

yields:

'Scanner error: while parsing a quoted scalar at line 3, column 7 found unknown escape character at line 3, column 49'

and adding two backslashes:

date: "`r format(Sys.time(), '%d\\. %B, %Y')`"

yields:

'[pandoc warning] Could not parse YAML header: found unknown escape character "source" (line 5, column 26)'

Thank you in advance!

Could you please elaborate on what you mean by "gets interpreted as an enumerated item"? When I knit an R Markdown document with the following YAML header:

---
title: "German date"
date: "`r format(Sys.time(), '%d. %B, %Y')`"
output: html_document
---

The HTML results look like this:

image

Do you want the date to display as "29. August, 2019"? If not, what is your desired result?

Sorry, I forgot to mention that I am generating a PDF document. It must be the LaTeX Compiler that treats the date as an enumerated item.

In the minimal example I got the following error:

! Incomplete \iffalse; all text was ignored after line 129.
<inserted text> 
                \fi 
<*> test3.tex

To be precise, this is what happens in the .tex file:

% Create subtitle command for use in maketitle
\providecommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}

  \title{example}
    \pretitle{\vspace{\droptitle}\centering\huge}
  \posttitle{\par}
    \author{}
    \preauthor{}\postauthor{}
      \predate{\centering\large\emph}
  \postdate{\par}
    \date{\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{29}
\tightlist
\item
  August, 2019
\end{enumerate}}

\begin{document}
\maketitle

Thanks for the additional information. I updated the YAML header to the following:

---
title: "German date"
date: "`r format(Sys.time(), '%d. %B, %Y')`"
output:
  pdf_document:
    keep_tex: true
---

The resulting PDF displays the date as "30. August, 2019":

image

And the TeX file contains the following:

% Create subtitle command for use in maketitle
\providecommand{\subtitle}[1]{
  \posttitle{
    \begin{center}\large#1\end{center}
    }
}

\setlength{\droptitle}{-2em}

  \title{German date}
    \pretitle{\vspace{\droptitle}\centering\huge}
  \posttitle{\par}
    \author{}
    \preauthor{}\postauthor{}
      \predate{\centering\large\emph}
  \postdate{\par}
    \date{30. August, 2019}

Could you please share some additional information on your setup?

  • osVersion
  • R.version.string
  • packageVersion("rmarkdown")
  • rmarkdown::pandoc_version()
  • How did you install LaTeX? TeX Live? MiKTeX?
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.