Markdown unnumbered section but needs anchor

£可爱£侵袭症+ 提交于 2021-02-20 18:59:40

问题


I am working with a Markdown document where I would like to have some sections not be numbered. But I also want to create anchors for these sections. Here is an example:

# Appendix A: Methodology {-} {#methodology}

I want to have Appendix A not be numbered but I still want to link to it using the anchor.

Ideally, the solution would work for both LaTeX PDF and HTML. I have figured out how to turn off the numbered section thing for LaTeX but it's not working for HTML.


回答1:


If you want to specify both a target name (#...) and a class (like .unnumbered) for a heading you have to use a single set of braces and the correct order. The following works for me for both HTML and PDF output:

---
output:
  html_document:
    number_sections: yes
  pdf_document: default
---


# R Markdown

See the appendix on [methodology](#methodology).


# Appendix A: Methodology {#methodology -}


来源:https://stackoverflow.com/questions/53378848/markdown-unnumbered-section-but-needs-anchor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!