How can I reference a section by number in org-mode export?

Sam Ritchie picture Sam Ritchie · May 2, 2013 · Viewed 9.3k times · Source

I'm working in org-mode and trying to generate a link to reference a section by its number, not its title.

* Section One
:PROPERTIES:
:CUSTOM_ID: sec:one
:END:

* Section Two
#+label: sec:two

I can reference Section One with  [[#sec:one]] and [[#sec:one][Section One]],
but I can't get the actual section number (1) to resolve.

I want to see

As you can see in Section 1

By writing something like

As you can see in Section [[sec:one]],

Any ideas?

Answer

Tom Regner picture Tom Regner · May 3, 2013

I use dedicated targets for this:

* Section One
  <<sec:one>>

* Section Two
  <<sec:two>>

I can reference Section One with  [[sec:one]] and [[sec:one][Section One]],
but I can get the actual section number (1) to resolve.

This works as expected; see the orgmode documentation on internal links for reference.