Given the following example org-document:
* For Loops
This is a for loop in Python:
#+name: lst:src-ref
#+caption: This is an example for loop.
#+begin_src python
for i in range(0, 10):
print(i)
#+end_src
* References
Remember the for-loop example\nbsp{}[[lst:src-ref]].
The link lst:src-ref
is never actually (properly) set, at least for exports to
HTML and LaTeX (PDF). The only workaround I've found so far is to use the
double-bracket link <<lst:src-ref>>
above the source block, but that will
refer to the section, not the block itself.
What is the correct way to create internal links to source blocks such that they can be referenced in at least HTML and LaTeX export?
Notice that this is similar to this question, however, the answers are seemingly out of date, or just not working in many cases, hence a complete (and current) answer would be appreciated.