Dont know if SO is the right platform for this question since I dont get an error with what I am doing, more an unexpected behavior...
But what am I doing? I am knitting the default template of the R-Studio markdown file (file > new file > r-markdown). The "code" of the file is at the end of the post since it is rather large... When I knit that file, I get a PDF file.
This file works as expected: When I click one of the two bookmarks ("R-Markdown" or "Including Plots") in the bookmark-pane of the R-Studio internal viewer, pdf.js/firefox or Adobe Acrobat DC both scroll/move to the matching headline.
When I add classoption: landscape
to the YAML header the internal viewer and pdf.js/firefox still work as expected, but clicking the bookmarks in Adobe Acrobat DC has no effect. Well, thats not correct. Clicking any bookmark when you're on the first page has no effect, but if you scroll down to the second page or further, clicking a bookmark moves you up to the first page.
Just by changing the page orientation? What am I doing wrong? Hopefully its not Adobe Acrobat since I cant change the viewer.
---
title: "Untitled"
author: "test"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
EDIT
Since we're able to fix the simplified scenario I've added parts of the real scenario that still contain the problem. As you can see it nearly doesn't contain markdown and more tex because things like headers are not part of markdown. Therefore I've checked which tex output is generated for a level 2 markdown section like
## page 9 3/4
Answer:
\hypertarget{page-9-34}{%
\subsection{page 9 3/4}\label{page-9-34}}
and used that tex code in the header to create bookmarks that redirect to the specific page. But neither markdown bookmarks nor the tex variant works.
test.r
# Should contain a file "logo.png" which is used on title page and in page header
img <- "path/to/image/folder"
path <- "path/to/output/folder"
fname <- "report1.pdf"
infodata <- tribble(~pid, ~person, ~name, ~date, ~m1)
infodata <- infodata %>% add_row(
pid = 4711,
person = "Max Mustermann",
name = "Hotel California",
date = lubridate::ymd('2021-09-30'),
m1 = lubridate::ymd('2021-10-15')
)
rmarkdown::render(input = "test.Rmd",
output_format = "pdf_document",
output_file = fname,
output_dir = path,
params = list(info = infodata, img = img))
test.Rmd
---
title: |
{width=15cm}
`r params$info$name`
subtitle: "1. Report (`r format(params$info$date, '%d.%m.%Y')` - `r format(params$info$m1, '%d.%m.%Y')`)"
author: "Your-Name-Here"
mainfont: Calibri
fontsize: 12pt
papersize: a4
classoption: landscape
geometry: "left=1cm,right=1cm,top=1cm,bottom=1cm"
output:
pdf_document:
latex_engine: xelatex # using fonts from local environment
toc: false
number_sections: false
fig_caption: false
params:
info:
img:
header-includes:
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{80pt}
\rhead{\includegraphics[width=2cm]{`r img`/logo.png}}
\fancypagestyle{plain}{\pagestyle{fancy}}
\usepackage{xcolor}
\usepackage{pagecolor}
\definecolor{color1}{HTML}{e7FFFF}
\pagecolor{color1}
\usepackage{titlesec}
\titlespacing{\section}{0pt}{0pt}{-0.5cm}
\usepackage{hyperref}
\hypersetup{bookmarks=true,bookmarksopen=true,pdfcreator=}
---
```{r, setup, include = FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
\thispagestyle{empty}
\newpage
\lhead{\hypertarget{page-1}{\subsection{Page 1}\label{page-1}}}
\begin{huge}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{huge}
\newpage
\lhead{Page 2}
## Page 2
\begin{huge}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{huge}
\newpage
\lhead{\hypertarget{page-3}{\subsection{Page 3}\label{page-3}}}
\begin{huge}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{huge}
\newpage
\lhead{Page 4}
## Page 4
\begin{huge}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{huge}
\newpage