如何在Rmarkdown pdf输出

时间:2016-06-07 10:48:46

标签: r r-markdown

我正在创建几个报告,通过从r调用markdown文件输出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页。

感谢您的帮助。

1 个答案:

答案 0 :(得分:3)

尝试以下代码。

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