About the hyperlink in RMARKDOWN

Viewed 230

In rmarkdown, we can create a catalog using 'toc: yes',using the hyperlink, i can link to subtitle.

Now, i want to link subtitle to catalog ? (in the final html, i with to click subtitle,then back to top of the file)

---
title:'my markdown file'
output: 
 html_document:
  toc: yes
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## subtitle 1 :R Markdown



```{r cars}
summary(cars)
```

## subtitle 2:Including Plots



```{r pressure, echo=FALSE}
plot(pressure)
```
1 Answers

You may enclose subheader in an HTML tag <a>.

---
title: 'my markdown file'
output: 
  html_document:
  toc: yes
---
  
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## subtitle 1 :R Markdown

```{r cars}
summary(cars)
as.matrix(rnorm(100))
```

## <a href="#top">subtitle 2:Including Plots</a>

```{r pressure, echo=FALSE}
plot(pressure)
```
Related