本文介绍了rmarkdown 中的内部链接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 rmarkdown 来渲染 pdf 文档.现在我想在文本中添加内部链接.
I use rmarkdown to render pdf documents. Now I want to add internal links in the texts.
在rmarkdown的帮助页面中,它说内部链接定义为:
In the helping pages of rmarkdown, it says an internal link is defined as:
See the [Introduction](#introduction).
当我使用例如接下来的代码应该有两个内部链接:link1 和link2.两者都不链接.有什么明显的我做错了吗?非常感谢!
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
推荐答案
您没有正确设置锚点.
尝试以下操作:
# 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}
这篇关于rmarkdown 中的内部链接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!