Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal links in rmarkdown don't work

I use rmarkdown to render pdf documents. Now I want to add internal links in the texts.

In the helping pages of rmarkdown, it says an internal link is defined as:

See the [Introduction](#introduction). 

When I Use e.g. the next code there should be two internal links: link1 and link2. Both don't link. Is there something obvious that I am doing wrong? Many thanks in advance!

   --- title: "Test" author: "test test" output:   pdf_document:     latex_engine: xelatex     number_sections: yes     toc: yes     toc_depth: 3   html_document:     css: tables.css     number_sections: yes     theme: cerulean     toc: yes     toc_depth: 3 subtitle: test test test mainfont: Calibri Light fontsize: 12pt header-includes: - \usepackage[dutch]{babel} - \usepackage{fancyhdr} - \pagestyle{fancy} - \fancyfoot[LE,RO]{this is a fancy foot} - \usepackage{dcolumn} - \usepackage{here} - \usepackage{longtable} - \usepackage{caption} - \captionsetup{skip=2pt,labelsep=space,justification=justified,singlelinecheck=off} ---  # start  ```{r results="asis",tidy=FALSE,eval=TRUE,echo=FALSE,message=FALSE, error=FALSE, warning=FALSE, comment = NA} cat("click here: [link1](#test 1)") ```  click here: [link2](#test 1)  \pagebreak  #test 3  \pagebreak  #test 2  \pagebreak  #test 1 
like image 465
rdatasculptor Avatar asked Nov 25 '15 10:11

rdatasculptor


People also ask

How do I create an internal link in markdown?

Markdown syntax for a hyperlink is square brackets followed by parentheses. The square brackets hold the text, the parentheses hold the link.

Why is my Rmarkdown not knitting?

No Knit HTML button This means that RStudio doesn't understand your document is supposed to be an RMarkdown document, often because your file extension is . txt . To fix this, go to the Files tab (lower right corner, same pane as Plots and Help) and select the checkbox next to your document's name.

Does Rmarkdown use pandoc?

The R package rmarkdown is a library which proceses and converts . Rmd files into a number of different formats. The core function is rmarkdown::render which stands on the shoulders of pandoc. This function 'renders the input file to the specified output format using pandoc.

What is knitr in Rmarkdown?

RMarkdown is an extension to markdown which includes the ability to embed code chunks and several other extensions useful for writing technical reports. The rmarkdown package extends the knitr package to, in one step, allow conversion between an RMarkdown file (.Rmd) into PDF, HTML, word document, amongst others.


1 Answers

You're not setting the anchors correctly.

Try the following:

# start  ```{r results="asis",tidy=FALSE,eval=TRUE} cat("click here: [link1](#test1)") ```  click here: [link2](#test1)  \pagebreak  # test 3 {#test3}  \pagebreak  #test 2 {#test2}  \pagebreak  #test 1 {#test1} 
like image 84
A5C1D2H2I1M1N2O1R2T1 Avatar answered Sep 23 '22 16:09

A5C1D2H2I1M1N2O1R2T1