Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-referencing Chapter numbers or names by rmarkdown

In trying to find a way in Rmarkdown for cross-referencing chapters which were auto-numbering and/or by its named to do something like

"As I explained hundred pages ago in \ref{ch:Chapter_Label}....."

and then the generated pdf document produced has something like:

"As I explained hundred pages ago in Chapter 3....."

or

"As I explained hundred pages ago in <Chapter Name> ....."

I was thinking in some mechanism like:

\chapter{My_Title} \label{ch:1}

And then everywhere inside the text I use \ref{ch:1} I would get either the "My_Title" or the "Chapter 1" (or whatever auto-numbering it got) embedded by the text.

Seemed the hyperref package is not working by Rmarkdown or I'm missing something.

Does anybody can help me?

like image 429
Fábio Salles Avatar asked Oct 19 '22 21:10

Fábio Salles


1 Answers

This issue has been solved in bookdown and documented in Section 2.5. Basically you use the syntax \@ref(label), and label is your chapter identifier.

like image 56
Yihui Xie Avatar answered Oct 27 '22 08:10

Yihui Xie