emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Exporting Hyperlinks ?
@ 2023-11-01  4:24 David Masterson
  2023-11-01 16:36 ` Max Nikulin
  0 siblings, 1 reply; 20+ messages in thread
From: David Masterson @ 2023-11-01  4:24 UTC (permalink / raw)
  To: emacs-orgmode

In the Org Mode documentation, I see how hyperlinks are handled in HTML
export and how images are handled in Latex export, but is there a clear
description of how hyperlinks are handled across export engines
(particularly the standard ones)?  I see that the PDF viewer is seeing
file links from exported PDFs from Latex as links, but it seems
incomplete (ie. link to a file, but not to a particular CUSTOM_ID in the
file). What about Beamer or ascii or Texinfo?

-- 
David Masterson


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-01  4:24 Exporting Hyperlinks ? David Masterson
@ 2023-11-01 16:36 ` Max Nikulin
  2023-11-02  2:11   ` David Masterson
  0 siblings, 1 reply; 20+ messages in thread
From: Max Nikulin @ 2023-11-01 16:36 UTC (permalink / raw)
  To: emacs-orgmode

On 01/11/2023 11:24, David Masterson wrote:
> In the Org Mode documentation, I see how hyperlinks are handled in HTML
> export and how images are handled in Latex export, but is there a clear
> description of how hyperlinks are handled across export engines
> (particularly the standard ones)?

Only the code may be more complete reference than backend-specific 
sections in the manual. There are some issues (e.g. cross-file id 
links), but in general links should work.

> I see that the PDF viewer is seeing
> file links from exported PDFs from Latex as links, but it seems
> incomplete (ie. link to a file, but not to a particular CUSTOM_ID in the
> file).

It seems ::search part is stripped. Perhaps ::#anchor should be exported 
as #anchor, however it is more tricky with line numbers or text search 
variants.

I have tried

Par <<label>> and [[#cust][link]]

* H1
:PROPERTIES:
:CUSTOM_ID: cust
:END:

[[file:t2.org::#anchor]] stripped.
[[file:t2.org#anchor]] retained.

[[label][link]]

and I get

Par \label{org59ae2bf} and \hyperref[sec:orgd12b09a]{link}
\section{H1}
\label{sec:orgd12b09a}
\url{t2.org} stripped.
\url{t2.org\#anchor} retained.

\hyperref[org59ae2bf]{link}

> What about Beamer or ascii or Texinfo?

Beamer is derived from LaTeX. In ascii links to headings are supported, 
but <<anchors>> have no obvious way for export. As to formatting, see 
the following recent thread:

Max Nikulin. [PATCH] ox-ascii.el: Consistently add brackets around links 
(was: Re: [RFC][PATCH] Allow to export to ascii custom link types as 
notes) Tue, 24 Oct 2023 22:06:05 +0700.
https://list.orgmode.org/uh8mgt$lpo$1@ciao.gmane.io



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-01 16:36 ` Max Nikulin
@ 2023-11-02  2:11   ` David Masterson
  2023-11-02 15:24     ` Max Nikulin
  0 siblings, 1 reply; 20+ messages in thread
From: David Masterson @ 2023-11-02  2:11 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 01/11/2023 11:24, David Masterson wrote:
>> In the Org Mode documentation, I see how hyperlinks are handled in HTML
>> export and how images are handled in Latex export, but is there a clear
>> description of how hyperlinks are handled across export engines
>> (particularly the standard ones)?
>
> Only the code may be more complete reference than backend-specific
> sections in the manual. There are some issues (e.g. cross-file id 
> links), but in general links should work.

Hmm. I'm using CUSTOM_ID links to make a rudimentary Contact DB.

>> I see that the PDF viewer is seeing
>> file links from exported PDFs from Latex as links, but it seems
>> incomplete (ie. link to a file, but not to a particular CUSTOM_ID in the
>> file).
>
> It seems ::search part is stripped. Perhaps ::#anchor should be
> exported as #anchor, however it is more tricky with line numbers or
> text search variants.

If I understand what you mean by "anchor", does Org create an anchor in
exporting to Latex when it sees a CUSTOM_ID property in an item?  Then,
would the search in the hyperlink reference the anchor?  Your examples
weren't precise enough for me to follow.

Thanks
-- 
David Masterson


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-02  2:11   ` David Masterson
@ 2023-11-02 15:24     ` Max Nikulin
  2023-11-03  6:29       ` David Masterson
  0 siblings, 1 reply; 20+ messages in thread
From: Max Nikulin @ 2023-11-02 15:24 UTC (permalink / raw)
  To: emacs-orgmode

On 02/11/2023 09:11, David Masterson wrote:
> If I understand what you mean by "anchor", does Org create an anchor in
> exporting to Latex when it sees a CUSTOM_ID property in an item?  Then,
> would the search in the hyperlink reference the anchor?  Your examples
> weren't precise enough for me to follow.

You are right. Despite `org-latex-prefer-user-labels' exists, it 
currently affects LaTeX label names only, so it is possible to reference 
them as #page.2, #section.3, but not as #custom_id. ox-beamer however 
adds \hypertarget{anchor}... for Org <<anchor>>, so in PDF it can be 
referenced as #anchor.

So ox-latex should be improved to add \hypertarget commands for CUSTOM_ID.

Originally I suspected only issues with links.

To get links between HTML documents where CUSTOM_ID are not used, it is 
necessary to rely on org-publish to track autogenerated anchors. I am 
unsure if publish works for LaTeX.

By the way, does Chrome support #anchor within PDF files? I have tried 
to add various variants of #fragement to file:///tmp/test.pdf, but 
without success. Bookmarks (table of contents) sidebar and clicking on 
internal links works however. For the same file xpdf-3 (xpopple) works 
correctly

xpdf test.pdf +page.2
xpdf test.pdf +section.2
xpdf test.pdf +anchor

(The last one is added using explicit \hypertarget)

P.S.
https://en.wikibooks.org/wiki/LaTeX/Hyperlinks



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-02 15:24     ` Max Nikulin
@ 2023-11-03  6:29       ` David Masterson
  2023-11-03 10:44         ` Max Nikulin
  0 siblings, 1 reply; 20+ messages in thread
From: David Masterson @ 2023-11-03  6:29 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 02/11/2023 09:11, David Masterson wrote:
>> If I understand what you mean by "anchor", does Org create an anchor in
>> exporting to Latex when it sees a CUSTOM_ID property in an item?  Then,
>> would the search in the hyperlink reference the anchor?  Your examples
>> weren't precise enough for me to follow.
>
> You are right. Despite `org-latex-prefer-user-labels' exists, it
> currently affects LaTeX label names only, so it is possible to
> reference them as #page.2, #section.3, but not as
> #custom_id. ox-beamer however adds \hypertarget{anchor}... for Org
> <<anchor>>, so in PDF it can be referenced as #anchor.
>
> So ox-latex should be improved to add \hypertarget commands for CUSTOM_ID.

I agree.  For a link of:

  [[file:contacts.org::#custom_id][My text]]

the generated LaTeX href looks like

  \href{contacts.tex}{My text}

which looks wrong.

> Originally I suspected only issues with links.
>
> To get links between HTML documents where CUSTOM_ID are not used, it
> is necessary to rely on org-publish to track autogenerated anchors. I
> am unsure if publish works for LaTeX.

I use publish for LaTex (org-latex-publish-to-pdf)

-- 
David Masterson


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-03  6:29       ` David Masterson
@ 2023-11-03 10:44         ` Max Nikulin
  2023-11-03 21:55           ` Samuel Wales
  0 siblings, 1 reply; 20+ messages in thread
From: Max Nikulin @ 2023-11-03 10:44 UTC (permalink / raw)
  To: emacs-orgmode

On 03/11/2023 13:29, David Masterson wrote:
> the generated LaTeX href looks like
> 
>    \href{contacts.tex}{My text}
> 
> which looks wrong.

Search part definitely should be retained.

I have realized that in the LaTeX world inter-document cross-linking 
works differently. With the xr-hyper package, labels from another 
document may be used directly or with a prefix:
https://texfaq.org/FAQ-extref
It may be implemented for Org random labels.

However I would strongly prefer PDF files having stable anchors based on 
CUSTOM_ID, not ones derived from section, figure, etc. counters. I am 
unsure if there is a package that allows to get such anchors out of the box.

When I looked into the code for link targets resolution in the context 
of ox-html, I found it rather complicated.

> I use publish for LaTex (org-latex-publish-to-pdf)

Depending on your requirements, it might be possible to export to HTML 
files and then print them to PDF as a workaround. Chromium supports 
headless printing, so it should be scriptable. However to improve 
quality of formatting almost certainly heavy customization of CSS.

I have realized that Chomium scrolls to proper position in PDF when it 
opens a file URI with #anchor part, but it does not update tab address 
bar when an internal link is clicked and it does not react when URL is 
edited to change #anchor part.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-03 10:44         ` Max Nikulin
@ 2023-11-03 21:55           ` Samuel Wales
  2023-11-03 22:06             ` Samuel Wales
  2023-11-04  7:10             ` Max Nikulin
  0 siblings, 2 replies; 20+ messages in thread
From: Samuel Wales @ 2023-11-03 21:55 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

to throw a cat among the pigeons, [[file:contacts.org::#custom_id][My
text]] made me think of the need for global custom id in addition to a
file-specific one like this.  idk what a good ui for it would be given
all the options we have considered over the years and recently.  just
thought to bring it up.

one thing i dislike is having to specify a file name in #+include or
links.  too brittle for my taste.  you change the file name and the
inclusion [transclusion package also?] or link is broken.  i'm ok with
org id most of the time but suepect global human-readable would be
really really useful.

imo huge value here.  in fact, i think we should allow human-readable
id's [/and/ org id's] in non-org files, such as .el.

oref seems to do this, but is not part of org and does not use org id
db yet, and some might or might not want a different syntax [no
opinion].

good concept.  as something similar, i found myself using
org-link-minor mode all the time for linking together, in comments,
parts of .el files, such as comments with distant code or code in
another file, or format statements with something that parses them but
is for whatever reason not nearby them.  and i also linked org with
.el so that org would do org things.  it made tses and links
clickable.  id markers [not implemented] would be even better as they
would allow instar and outstar formations and unbreakable bidir links
and tours/cycles and arbitrary graphs if those turn out to be desired.
if desired and not too complex, it could even hook up with the org
link insertion and editing mechanism in principle.

i did look at hyperbole both old and new, and found almost nothing
that i needed there.  just personal experience.

also, given especially the org-id stuff and other org aspects, i
actually think this kind of thing should NOT be a
separately-maintained package like oref, but should be a minor mode
that is part of the org-maintained codebase.  we do already have at
least one org minor mode for operating on non-org files.

of course, maintainers would have to be on board with it being part of
org-maintained code.  i just think org should branch out to this minor
mode.


On 11/3/23, Max Nikulin <manikulin@gmail.com> wrote:
> On 03/11/2023 13:29, David Masterson wrote:
>> the generated LaTeX href looks like
>>
>>    \href{contacts.tex}{My text}
>>
>> which looks wrong.
>
> Search part definitely should be retained.
>
> I have realized that in the LaTeX world inter-document cross-linking
> works differently. With the xr-hyper package, labels from another
> document may be used directly or with a prefix:
> https://texfaq.org/FAQ-extref
> It may be implemented for Org random labels.
>
> However I would strongly prefer PDF files having stable anchors based on
> CUSTOM_ID, not ones derived from section, figure, etc. counters. I am
> unsure if there is a package that allows to get such anchors out of the
> box.
>
> When I looked into the code for link targets resolution in the context
> of ox-html, I found it rather complicated.
>
>> I use publish for LaTex (org-latex-publish-to-pdf)
>
> Depending on your requirements, it might be possible to export to HTML
> files and then print them to PDF as a workaround. Chromium supports
> headless printing, so it should be scriptable. However to improve
> quality of formatting almost certainly heavy customization of CSS.
>
> I have realized that Chomium scrolls to proper position in PDF when it
> opens a file URI with #anchor part, but it does not update tab address
> bar when an internal link is clicked and it does not react when URL is
> edited to change #anchor part.
>
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-03 21:55           ` Samuel Wales
@ 2023-11-03 22:06             ` Samuel Wales
  2023-11-03 22:07               ` Samuel Wales
  2023-11-04  7:10             ` Max Nikulin
  1 sibling, 1 reply; 20+ messages in thread
From: Samuel Wales @ 2023-11-03 22:06 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

[in case not obvious,  i used org-link-minor-mode to implement the
equivalent of global custom id's, including non-org.  i'd say, like,
";; mypackage-whatever-parsing-thingie".  that is a kludge if we can
do it right with an oref-concept-ish org minor mode, but it was hugely
useful.]


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-03 22:06             ` Samuel Wales
@ 2023-11-03 22:07               ` Samuel Wales
  0 siblings, 0 replies; 20+ messages in thread
From: Samuel Wales @ 2023-11-03 22:07 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

[again, the specific implementation or syntax isn't the issue for me
here, just hte ability to have global custom id in addition to
existing .org local custom id]


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-03 21:55           ` Samuel Wales
  2023-11-03 22:06             ` Samuel Wales
@ 2023-11-04  7:10             ` Max Nikulin
  2023-11-05 12:38               ` Ihor Radchenko
  1 sibling, 1 reply; 20+ messages in thread
From: Max Nikulin @ 2023-11-04  7:10 UTC (permalink / raw)
  To: emacs-orgmode

On 04/11/2023 04:55, Samuel Wales wrote:
> [[file:contacts.org::#custom_id][My
> text]] made me think of the need for global custom id in addition to a
> file-specific one like this.

Taking into account that there is another active thread on user-global 
links, I am not going to discuss that feature here.

Human-readable link targets are susceptible to collisions. So ox-latex 
should support links to particular locations in the specified files, 
either an Org one or inside external PDF files. Code from ox-html should 
be adapted for ox-latex.

[[file:test.pdf::#anchor][Another document]]
   -> \href{test.pdf\#anchor}{Another document}

[[file:test.org::#anchor][Another document]]
Either for xr-hyper
  -> Another document \ref{f1-orgabc123}
with \label{orgabc123} in test.tex
or with redefined \label to generate additional \hypertarget
  -> \href{test.pdf\#anchor}{Another document}



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-04  7:10             ` Max Nikulin
@ 2023-11-05 12:38               ` Ihor Radchenko
  2023-11-05 22:28                 ` David Masterson
  0 siblings, 1 reply; 20+ messages in thread
From: Ihor Radchenko @ 2023-11-05 12:38 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> Human-readable link targets are susceptible to collisions. So ox-latex 
> should support links to particular locations in the specified files, 
> either an Org one or inside external PDF files. Code from ox-html should 
> be adapted for ox-latex.
>
> [[file:test.pdf::#anchor][Another document]]
>    -> \href{test.pdf\#anchor}{Another document}

AFAIK, this kind of URL cannot be opened except when opening pdf in
browser.

> [[file:test.org::#anchor][Another document]]
> Either for xr-hyper
>   -> Another document \ref{f1-orgabc123}
> with \label{orgabc123} in test.tex
> or with redefined \label to generate additional \hypertarget
>   -> \href{test.pdf\#anchor}{Another document}

And this does not fit into single-document exports. We must export
multiple files via ox-publish. ...and ox-publish does not support pdf
export.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-05 12:38               ` Ihor Radchenko
@ 2023-11-05 22:28                 ` David Masterson
  2023-11-06  9:37                   ` Ihor Radchenko
  0 siblings, 1 reply; 20+ messages in thread
From: David Masterson @ 2023-11-05 22:28 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Max Nikulin <manikulin@gmail.com> writes:
>
>> Human-readable link targets are susceptible to collisions. So ox-latex 
>> should support links to particular locations in the specified files, 
>> either an Org one or inside external PDF files. Code from ox-html should 
>> be adapted for ox-latex.
>>
>> [[file:test.pdf::#anchor][Another document]]
>>    -> \href{test.pdf\#anchor}{Another document}
>
> AFAIK, this kind of URL cannot be opened except when opening pdf in
> browser.

What else is there?  PDFviewer?  What is the standard for Latex?

>> [[file:test.org::#anchor][Another document]]
>> Either for xr-hyper
>>   -> Another document \ref{f1-orgabc123}
>> with \label{orgabc123} in test.tex
>> or with redefined \label to generate additional \hypertarget
>>   -> \href{test.pdf\#anchor}{Another document}
>
> And this does not fit into single-document exports. We must export
> multiple files via ox-publish. ...and ox-publish does not support pdf
> export.

org-latex-publish-to-pdf ??  Oh, you mean that it has to go through
Latex to get to PDF. 

-- 
David Masterson


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-05 22:28                 ` David Masterson
@ 2023-11-06  9:37                   ` Ihor Radchenko
  2023-11-07 12:06                     ` Max Nikulin
  0 siblings, 1 reply; 20+ messages in thread
From: Ihor Radchenko @ 2023-11-06  9:37 UTC (permalink / raw)
  To: David Masterson; +Cc: Max Nikulin, emacs-orgmode

David Masterson <dsmasterson@gmail.com> writes:

>>> [[file:test.pdf::#anchor][Another document]]
>>>    -> \href{test.pdf\#anchor}{Another document}
>>
>> AFAIK, this kind of URL cannot be opened except when opening pdf in
>> browser.
>
> What else is there?  PDFviewer?  What is the standard for Latex?

Yes, PDFviewer.
AFAIU, it is only possible to refer to a specific page:
\href[page=X]{test.pdf}
https://tex.stackexchange.com/questions/675130/open-an-external-pdf-file-on-a-specific-page

>>> [[file:test.org::#anchor][Another document]]
>>> Either for xr-hyper
>>>   -> Another document \ref{f1-orgabc123}
>>> with \label{orgabc123} in test.tex
>>> or with redefined \label to generate additional \hypertarget
>>>   -> \href{test.pdf\#anchor}{Another document}
>>
>> And this does not fit into single-document exports. We must export
>> multiple files via ox-publish. ...and ox-publish does not support pdf
>> export.
>
> org-latex-publish-to-pdf ??  Oh, you mean that it has to go through
> Latex to get to PDF. 

I mean that ox-publish is mostly polished for html publishing.
While it is technically possible to publish with other export backends,
I expect many rough edges there.

In particular, `org-latex-publish-to-pdf' in ox-latex has no special
arrangement to support pdf cross-references. There is even no conversion
from .org references to .pdf references as .org -> .html in ox-html.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-06  9:37                   ` Ihor Radchenko
@ 2023-11-07 12:06                     ` Max Nikulin
  2023-11-07 12:36                       ` Ihor Radchenko
  0 siblings, 1 reply; 20+ messages in thread
From: Max Nikulin @ 2023-11-07 12:06 UTC (permalink / raw)
  To: David Masterson; +Cc: emacs-orgmode

On 06/11/2023 16:37, Ihor Radchenko wrote:
> David Masterson writes:
> 
>>>> [[file:test.pdf::#anchor][Another document]]
>>>>     -> \href{test.pdf\#anchor}{Another document}
>>>
>>> AFAIK, this kind of URL cannot be opened except when opening pdf in
>>> browser.
>>
>> What else is there?  PDFviewer?  What is the standard for Latex?
> 
> Yes, PDFviewer.
> AFAIU, it is only possible to refer to a specific page:
> \href[page=X]{test.pdf}
> https://tex.stackexchange.com/questions/675130/open-an-external-pdf-file-on-a-specific-page

Ihor, sorry, but your point is not clear for me. I am unaware of 
portable way to open PDF file at specific page or create a link namely 
to a page, but links to anchors work e.g. in xpdf-3 (xpopple) and okular.

https://list.orgmode.org/tevj61$17d8$1@ciao.gmane.io/
Re: Org mode links: Open a PDF file at a given page and highlight a 
given string. Sat, 3 Sep 2022 20:00:47 +0700

(Side note: I have no idea what "standard for LaTeX" may mean, there are 
plenty of PDF viewers, browsers are usually installed any way, so no 
additional applications required.)

I just have tried

file-a.tex:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
A 1

\href{file-b.pdf#b-2}{b-2 in file b}
\newpage
\section{Section in A}
\hypertarget{a-2}{}A 2
\end{document}

file-b.tex:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
B 1

\href{file-a.pdf#a-2}{a-2 in file a}
\newpage
\section{Section in B}
\hypertarget{b-2}{}B 2
\end{document}

Cross-links between files work.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-07 12:06                     ` Max Nikulin
@ 2023-11-07 12:36                       ` Ihor Radchenko
  2023-11-07 16:38                         ` Max Nikulin
  0 siblings, 1 reply; 20+ messages in thread
From: Ihor Radchenko @ 2023-11-07 12:36 UTC (permalink / raw)
  To: Max Nikulin; +Cc: David Masterson, emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> I just have tried
>
> file-a.tex:
>
> \documentclass{article}
> \usepackage{hyperref}
> \begin{document}
> A 1
>
> \href{file-b.pdf#b-2}{b-2 in file b}
> \newpage
> \section{Section in A}
> \hypertarget{a-2}{}A 2
> \end{document}
>
> file-b.tex:
>
> \documentclass{article}
> \usepackage{hyperref}
> \begin{document}
> B 1
>
> \href{file-a.pdf#a-2}{a-2 in file a}
> \newpage
> \section{Section in B}
> \hypertarget{b-2}{}B 2
> \end{document}
>
> Cross-links between files work.

This is interesting. I am wondering if it is document (it should...).

If \href{file.pdf#anchor} can work, we should indeed use it when
publishing org->pdf.

In particular, we can introduce something similar to
`org-html-link-org-files-as-html', but for pdf export.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-07 12:36                       ` Ihor Radchenko
@ 2023-11-07 16:38                         ` Max Nikulin
  2023-11-08  8:02                           ` David Masterson
  2023-11-08  9:37                           ` Ihor Radchenko
  0 siblings, 2 replies; 20+ messages in thread
From: Max Nikulin @ 2023-11-07 16:38 UTC (permalink / raw)
  To: emacs-orgmode

On 07/11/2023 19:36, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>> Cross-links between files work.
> 
> This is interesting. I am wondering if it is document (it should...).

file:///usr/share/doc/texlive-doc/latex/hyperref/hyperref-doc.pdf#section.6
or
file:///usr/share/doc/texlive-doc/latex/hyperref/hyperref-doc.pdf#page.23
with default counter-based LaTeX anchors or browser-specific
file:///usr/share/doc/texlive-doc/latex/hyperref/hyperref-doc.pdf#page=23

> If \href{file.pdf#anchor} can work, we should indeed use it when
> publishing org->pdf.

It would be nice to have a LaTeX package that redefines \label to 
generated \hypertarget from its argument.

Ideally, xr-hyper workflow should be supported as well. A downside is 
anchors are not stable and unrelated to labels.

P.S. (info "(org) Publishing")
declares that conversion to PDF is supported.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-07 16:38                         ` Max Nikulin
@ 2023-11-08  8:02                           ` David Masterson
  2023-11-08 10:39                             ` Max Nikulin
  2023-11-08  9:37                           ` Ihor Radchenko
  1 sibling, 1 reply; 20+ messages in thread
From: David Masterson @ 2023-11-08  8:02 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 07/11/2023 19:36, Ihor Radchenko wrote:
>> If \href{file.pdf#anchor} can work, we should indeed use it when
>> publishing org->pdf.
>
> It would be nice to have a LaTeX package that redefines \label to
> generated \hypertarget from its argument.

This would make it easy to create a PDF "website" that doesn't depend on
a webserver like HTML.  A PDF website could easily be put on a USB key
to take with you and access via a mobile phone.  This would be secure
because no network interaction.  This is the use case I've been working
toward for years.

> Ideally, xr-hyper workflow should be supported as well. A downside is
> anchors are not stable and unrelated to labels.

Stable in the sense that the CUSTOM_ID could be moved to new file?
Could IDs play a roll here?

-- 
David Masterson


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-07 16:38                         ` Max Nikulin
  2023-11-08  8:02                           ` David Masterson
@ 2023-11-08  9:37                           ` Ihor Radchenko
  2023-11-08 10:50                             ` Max Nikulin
  1 sibling, 1 reply; 20+ messages in thread
From: Ihor Radchenko @ 2023-11-08  9:37 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>> If \href{file.pdf#anchor} can work, we should indeed use it when
>> publishing org->pdf.
>
> It would be nice to have a LaTeX package that redefines \label to 
> generated \hypertarget from its argument.

Can't we simply generate a pair of \label + \hypertarget when generating
.tex files in ox-latex? This way, we can make sure that labels in
Org-generated pdfs will be linkable from outside world.

> Ideally, xr-hyper workflow should be supported as well. A downside is 
> anchors are not stable and unrelated to labels.

I think that generating \hypertarget + converting .org file links to
.pdf links will already be a good improvement.

Using xr-hyper requires knowledge of external files we link to and thus
can only be used during publishing, where we have all the information
about multiple exported Org documents available.

> P.S. (info "(org) Publishing")
> declares that conversion to PDF is supported.

It is indeed supported. But not with all the features HTML export
provides. Cross-references is one of the missing features in PDF
publishing.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-08  8:02                           ` David Masterson
@ 2023-11-08 10:39                             ` Max Nikulin
  0 siblings, 0 replies; 20+ messages in thread
From: Max Nikulin @ 2023-11-08 10:39 UTC (permalink / raw)
  To: emacs-orgmode

On 08/11/2023 15:02, David Masterson wrote:
> Max Nikulin writes:
> 
>> On 07/11/2023 19:36, Ihor Radchenko wrote:
>>> If \href{file.pdf#anchor} can work, we should indeed use it when
>>> publishing org->pdf.
>>
>> It would be nice to have a LaTeX package that redefines \label to
>> generated \hypertarget from its argument.
> 
> This would make it easy to create a PDF "website" that doesn't depend on
> a webserver like HTML.  A PDF website could easily be put on a USB key
> to take with you and access via a mobile phone.  This would be secure
> because no network interaction.  This is the use case I've been working
> toward for years.

I do not see clear advantages over a set of HTML files with relative 
links <a href="another.html#relative-links">relative links</a>. I am 
unsure concerning permissions to open sibling files for mobile 
applications (both HTML and PDF ones).

I expect that LaTeX still has issues with generation of PDF files 
suitable for reflow. With proper CSS styles, HTML are are more flexible 
in respect to adapting for particular screen size. ePUB is an HTML-based 
format, but links to other files may be prohibited.

>> Ideally, xr-hyper workflow should be supported as well. A downside is
>> anchors are not stable and unrelated to labels.
> 
> Stable in the sense that the CUSTOM_ID could be moved to new file?
> Could IDs play a roll here?

No, I have in mind another case. LaTeX generates anchors like 
#section.6. If you insert another section, this one becomes #section.7. 
So all files having doc.pdf#section.6 links must be regenerated. Links 
based on CUSTOM_ID doc.pdf#export_note continue working even after 
rearranging structure of the target file. This is especially painful if 
target file is out of your control.

I consider the following link as a stable one:
https://www.gnu.org/software/grub/manual/grub/grub.pdf#true

When a heading with ID is moved to another file then anyway all files 
referencing it must be regenerated.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Exporting Hyperlinks ?
  2023-11-08  9:37                           ` Ihor Radchenko
@ 2023-11-08 10:50                             ` Max Nikulin
  0 siblings, 0 replies; 20+ messages in thread
From: Max Nikulin @ 2023-11-08 10:50 UTC (permalink / raw)
  To: emacs-orgmode

On 08/11/2023 16:37, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>> It would be nice to have a LaTeX package that redefines \label to
>> generated \hypertarget from its argument.
> 
> Can't we simply generate a pair of \label + \hypertarget when generating
> .tex files in ox-latex? This way, we can make sure that labels in
> Org-generated pdfs will be linkable from outside world.

I still have a hope that somebody can point us how to leverage hyperref 
facilities. Adding \hypertarget is a step forward, but ideally internal 
links generated by \ref, links in table of contents, PDF bookmarks 
(table of contents side bar) should consistently use #custom_id anchors 
as well. Usual #section.5 should be a fallback for cases with no user 
supplied labels.

> I think that generating \hypertarget + converting .org file links to
> .pdf links will already be a good improvement.
> 
> Using xr-hyper requires knowledge of external files we link to and thus
> can only be used during publishing, where we have all the information
> about multiple exported Org documents available.

I agree that some complications exist. Just like with HTML files for Org 
ones with <file:another.org::*heading> links. Several iterations of tex 
files compilation are required. .aux files for all .tex files must be 
available to get cross-file links working.




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-11-08 10:51 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-01  4:24 Exporting Hyperlinks ? David Masterson
2023-11-01 16:36 ` Max Nikulin
2023-11-02  2:11   ` David Masterson
2023-11-02 15:24     ` Max Nikulin
2023-11-03  6:29       ` David Masterson
2023-11-03 10:44         ` Max Nikulin
2023-11-03 21:55           ` Samuel Wales
2023-11-03 22:06             ` Samuel Wales
2023-11-03 22:07               ` Samuel Wales
2023-11-04  7:10             ` Max Nikulin
2023-11-05 12:38               ` Ihor Radchenko
2023-11-05 22:28                 ` David Masterson
2023-11-06  9:37                   ` Ihor Radchenko
2023-11-07 12:06                     ` Max Nikulin
2023-11-07 12:36                       ` Ihor Radchenko
2023-11-07 16:38                         ` Max Nikulin
2023-11-08  8:02                           ` David Masterson
2023-11-08 10:39                             ` Max Nikulin
2023-11-08  9:37                           ` Ihor Radchenko
2023-11-08 10:50                             ` Max Nikulin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).