Fábio Salles
Fábio Salles

Reputation: 365

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?

Upvotes: 5

Views: 4827

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30114

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.

Upvotes: 4

Related Questions