Org-mode Hyperlinks
1. URLs
1.1. Info
Use the info
link type to link to an Info manual or a specific node.
Link format: info:manual-name#optional node name
.
- To link to the Org manual:
see [[info:org][the Org manual]]
→ see the Org manual; - To link to the "User Input" node of the Emacs manual:
see [[info:emacs#User Input][Kinds of User Input]]
→ see Kinds of User Input.
2. Headings
Use C-c C-x p
to add CUSTOM_ID
property to headings:
* Headings :PROPERTIES: :CUSTOM_ID: hlinks :END:
Then you can use [[#hlinks]]
to reference it. For example,
see Section [[#hlinks]]
→ see Section 2;
see Section [[#hlinks][/Hyperlinks/]]
→ see Section Hyperlinks.
Use [[* Headings]]
to directly refer to the name of a heading. Note
that there's only one asterisk (*
), no matter how deep the heading is.
see Section [[* Named Elements]]
→ see Section 4;
see the [[* A sub-section][sub-section]]
→ see the sub-section.
Use C-c C-o
to nevigate to the target, and C-c &
to go back.
3. Files
You can go to a specific line in a file with by appending ::N
at the
end of file name, e.g. [[./org-hyperlink.org::10]]
. However, this
can't be exported to HTML.
4. Named Elements
Elements can be given a name:
#+name: named source block #+caption: simple code #+begin_src elisp (let ((x 2)) (coderef) (1+ x)) #+end_src
Three main elements that can be named:
- image: exported as "Figure N"
- table: exported as "Table N"
- code block: exported as "Listing N" in HTML and "Figure N" in LaTeX.
- even a paragraph can be given a name
You can refer to named elements using [[named source block]]
, e.g.
Fig. 1, Listing 1, and Table 1.
Adding #+caption: xxx
is highly recommended, for without it, caption
numbers like "Figure N" whould not show.
When targeting a ‘NAME’ keyword, the ‘CAPTION’ keyword is mandatory in order to get proper numbering. —Org manual 4.2 Internal Links
5. Dedicated Targets
Dedicated targets can be used to refer to a paragraph or an item in a list.
- paragraph:
[[target][prefixed sentence]]
→ prefixed sentence - unordered list:
the [[unordered target]]^th in the list
→ the 3th in the list - ordered list:
[[ordered target][lalala]]
→ lalala
6. Radio Targets
A radio target radiates its position. It is enclosed in three angular
brackets, e.g. <<<thebesttv>>>
and <<<do re me>>>
in section
7.
When a radio target is defined, any occurence of that word (or the words) in the document, e.g. thebesttv, is automatically linked to the originating target. This can be used for linking all the occurences of a terminology with its definition. See the song of "do re me".
See the manual: 4.3 Radio Targets. Again, thebesttv and do re me.
7. Something to Refer to
This section presents some example code and their exported results for later use.
<<target>> This is a sentence prefixed with a /dedicated target/. - unordered list - some item - <<unordered target>> target in an unordered list 1. ordered list 2. <<ordered target>> target in an ordered list This word---<<<thebesttv>>>---is a radio target. <<<Do re me>>>, a radio target, also a song.
This is a sentence prefixed with a dedicated target.
This word—thebesttv—is a radio target. Do re me, a radio target, also a song.
7.1. A sub-section
{{{image(50)}}} #+name: named image #+caption: sample image ../daily/2021-05-20/lights-3.jpg #+name: named source block #+caption: sample code #+begin_src elisp (let ((x 2)) (coderef) (1+ x)) #+end_src #+name: named table #+caption: sample table | a | b | c | d | |---+---+---+---| | 1 | 2 | 3 | 4 |
(let ((x 2))
(coderef)
(1+ x))
a | b | c | d |
---|---|---|---|
1 | 2 | 3 | 4 |