【问题标题】:How to link the contents to the actual page in Rmarkdown pdf output如何将内容链接到 Rmarkdown pdf 输出中的实际页面
【发布时间】:2016-06-07 10:48:46
【问题描述】:

我正在通过从 r 调用降价文件来创建几个以 pdf 文件输出的报告。创建 pdf 文件后,我想点击内容并转到实际页面。

我现在使用的代码是:

---
title : "My report"
author: "Myself"
output:   pdf_document: 
         fig_caption: yes
         number_section: yes
header-includes:
       - \usepackage{wallpaper}
       - \usepackage{\wpXoffset}{7.0cm}
       - \usepackage{\wpYoffset}{12.5cm}
       - \usepackage{longtable}
       - \usepackage{hyperref}        
---

some text
\newpage

# Introduction 

\newpage

# Mytables


```{r, tables,echo = FALSE, results= "asis"}

y= 1;
for (current_table in table$tablename)
{
  cat("##",current_schema);

   for (current_subtable in subtable$field_name)
      name_subtable = paste("###",subtable$field_name[y],"",sep = "");
      cat(name_subtable,"\n","&nbsp",fill = TRUE);
     y = y + 1
}
```

即当我点击时:

简介..................................................6

我想转到第 6 页。

感谢您的帮助。

【问题讨论】:

  • 尝试将toc: yes 添加到标题的pdf_document: 部分。这应该就是你所需要的。
  • 嗨@Benjamin,我已经尝试过了,但是对我不起作用。使用 toc = yes 我的内容有 2 层而不是 3 层,即 1 2 2.1 而不是 1 2 2.1 2.1.1 2.1.2 并且 Iinks 不起作用。我正在使用 Foxit Reader 打开文件。
  • 找到解决方案了吗?

标签: r r-markdown


【解决方案1】:

试试下面的代码。

---
title : "My report"
author: "Myself"
output:
  pdf_document: 
    fig_caption: yes
    number_section: yes
    toc: true
header-includes:
  - \hypersetup{colorlinks=true, linkcolor=blue}
---

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-28
    • 2016-12-31
    • 1970-01-01
    • 2021-11-21
    • 2021-10-03
    • 2021-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多