#+title: Org-mode Hyperlinks
#+date: <2022-09-22 Thu 20:15>
#+author: thebesttv

* URLs

** 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]]= \to see [[info:org][the Org manual]];
- To link to the "User Input" node of the Emacs manual: \\
  =see [[info:emacs#User Input][Kinds of User Input]]= \to see [[info:emacs#User Input][Kinds of User Input]].

* Headings
:PROPERTIES:
:CUSTOM_ID: hlinks
:END:

Use =C-c C-x p= to add =CUSTOM_ID= property to headings:
#+begin_src org
  ,* Headings
  :PROPERTIES:
  :CUSTOM_ID: hlinks
  :END:
#+end_src
Then you can use =[[#hlinks]]= to reference it.  For example,
#+begin_verse
=see Section [[#hlinks]]= \to see Section [[#hlinks]];
=see Section [[#hlinks][/Hyperlinks/]]= \to see Section [[#hlinks][/Hyperlinks/]].
#+end_verse

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.
#+begin_verse
=see Section [[* Named Elements]]= \to see Section [[* Named Elements]];
=see the [[* A sub-section][sub-section]]= \to see the [[* A sub-section][sub-section]].
#+end_verse

Use =C-c C-o= to nevigate to the target, and =C-c &= to go back.

* 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.

* Named Elements

Elements can be given a name:
#+begin_src org
  ,#+name: named source block
  ,#+caption: simple code
  ,#+begin_src elisp
    (let ((x 2))
      (coderef)
      (1+ x))
  ,#+end_src
#+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. [[named image]], Listing [[named source block]], and Table [[named table]].

Adding =#+caption: xxx= is highly recommended, for without it, caption
numbers like "Figure N" whould not show.
#+begin_quote
When targeting a ‘NAME’ keyword, the ‘CAPTION’ keyword is mandatory in
order to get proper numbering.
---​[[info:org#Internal Links][Org manual 4.2 Internal Links]]
#+end_quote

* Dedicated Targets

Dedicated targets can be used to refer to a paragraph or an item in a
list.
- paragraph: =[[target][prefixed sentence]]= \to [[target][prefixed sentence]]
- unordered list:  =the [[unordered target]]^th in the list= \to
  the [[unordered target]]^th in the list
- ordered list: =[[ordered target][lalala]]= \to [[ordered target][lalala]]

* Radio Targets

A radio target radiates its position.  It is enclosed in three angular
brackets, e.g. =<<<thebesttv>>>= and =<<<do re me>>>= in section
[[#example-section]].

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: [[https://orgmode.org/manual/Radio-Targets.html][4.3 Radio Targets]].
Again, thebesttv and do re me.
* Something to Refer to
:PROPERTIES:
:CUSTOM_ID: example-section
:END:

This section presents some example code and their exported results for
later use.

#+begin_src org
  <<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 [[https://en.wikipedia.org/wiki/Do-Re-Mi][song]].
#+end_src

<<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 [[https://en.wikipedia.org/wiki/Do-Re-Mi][song]].

** A sub-section

#+begin_src org
  {{{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 |
#+end_src

{{{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 |