ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] named destinations in /GoToR
@ 2023-11-13 16:25 Pablo Rodriguez via ntg-context
  2023-11-13 22:30 ` [NTG-context] " Michal Vlasák
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-11-13 16:25 UTC (permalink / raw)
  To: ConTeXt users; +Cc: Pablo Rodriguez

Dear list,

imagine I have a PDF document (named "whatever.pdf") such as the one
generated from this source:

  \setupinteraction[state=start,
    focus=standard]
  \starttext
  \dorecurse{5}
    {\chapter[\recurselevel]{Chapter}
      \section[sec-\recurselevel]{Section}}
  \stoptext

This source only samples PDF documents not generated with ConTeXt. This
means that no .tuc file may be available and named destinations may
contain only digits.

Then I need to access some named destinations from a document such as:

  \setupinteraction[state=start,
    focus=standard]
  \starttext
  \dorecurse{5}
    {\goto{Chapter \recurselevel}[whatever.pdf::\recurselevel],
      \goto{section \recurselevel}[whatever.pdf::sec-\recurselevel]\par}
  \stoptext

Sorry, but after reading again lpdf-ano.mkxl I’m not sure whether I can
get named destinations (such as "/D (4)" or "/D (sec-3)") and how I
could get them.

With the previous code, the only destination reads in the PDF source:

  5 0 obj
  <<
    /D [ 0 /Fit ]
    /F (whatever.pdf)
    /S /GoToR
  >>
  endobj

Many thanks for your help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: named destinations in /GoToR
  2023-11-13 16:25 [NTG-context] named destinations in /GoToR Pablo Rodriguez via ntg-context
@ 2023-11-13 22:30 ` Michal Vlasák
  2023-11-14 17:28   ` Pablo Rodriguez via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Vlasák @ 2023-11-13 22:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Pablo Rodriguez

Hello Pablo,

On Mon Nov 13, 2023 at 5:25 PM CET, Pablo Rodriguez via ntg-context wrote:
> Dear list,
>
> imagine I have a PDF document (named "whatever.pdf") such as the one
> generated from this source:
>
>   \setupinteraction[state=start,
>     focus=standard]
>   \starttext
>   \dorecurse{5}
>     {\chapter[\recurselevel]{Chapter}
>       \section[sec-\recurselevel]{Section}}
>   \stoptext
>
> This source only samples PDF documents not generated with ConTeXt. This
> means that no .tuc file may be available and named destinations may
> contain only digits.
>
> Then I need to access some named destinations from a document such as:
>
>   \setupinteraction[state=start,
>     focus=standard]
>   \starttext
>   \dorecurse{5}
>     {\goto{Chapter \recurselevel}[whatever.pdf::\recurselevel],
>       \goto{section \recurselevel}[whatever.pdf::sec-\recurselevel]\par}
>   \stoptext
>
> Sorry, but after reading again lpdf-ano.mkxl I’m not sure whether I can
> get named destinations (such as "/D (4)" or "/D (sec-3)") and how I
> could get them.
>
> With the previous code, the only destination reads in the PDF source:
>
>   5 0 obj
>   <<
>     /D [ 0 /Fit ]
>     /F (whatever.pdf)
>     /S /GoToR
>   >>
>   endobj

It seems that the default mode for outer (external file) references is
the "auto" mode. This one seems to load the whatever.pdf file, check the
named destinations and decide based on that.

I am not exactly sure why your example fails, because it seems desirable
that the auto mode detects the named destination and refers to it
instead, or at least refers to the page number the destination is
actually at.

In any case, you can try the "name" mode, which forces the use of
destination names (i.e. "/D (...)"):

    % both inner and outer references in name mode
    \setupinteraction[page=name]

    % inner default (auto mode) and outer name mode
    \setupinteraction[page={auto,name}]

Unfortunately, the second one doesn't work due to a typo in
strc-ref.lmt:

    --- a/tex/context/base/mkxl/strc-ref.lmt
    +++ b/tex/context/base/mkxl/strc-ref.lmt
         end
         if toboolean(outer) or outer == v_page or outer == v_yes then
             outermethod = v_page
    -    elseif inner == v_name then
    +    elseif outer == v_name then
             outermethod = v_name
         else
             outermethod = v_auto


Other thing you can try Pablo, is to not actually have the destination
file (whatever.pdf) present when running context. This works, because if
ConTeXt can't find the file, the auto mode fails and you get named
destinations unless in page mode (`page=page`).

Whether something better can be done (and in a backwards compatible way)
at the ConTeXt side I am not sure, I didn't go that deep.

Michal

PS: Sorry if this message finds its way onto the list twice, I got
blocked by automoderation by initially also including the full
strc-ref.lmt file, which is too big.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: named destinations in /GoToR
  2023-11-13 22:30 ` [NTG-context] " Michal Vlasák
@ 2023-11-14 17:28   ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-11-14 17:28 UTC (permalink / raw)
  To: ntg-context; +Cc: Pablo Rodriguez

On 11/13/23 23:30, Michal Vlasák wrote:
>> […]
>> With the previous code, the only destination reads in the PDF source:
>>
>>   5 0 obj
>>   <<
>>     /D [ 0 /Fit ]
>>     /F (whatever.pdf)
>>     /S /GoToR
>>   >>
>>   endobj
>
> It seems that the default mode for outer (external file) references is
> the "auto" mode. This one seems to load the whatever.pdf file, check the
> named destinations and decide based on that.

Many thanks for your explanation, Michal.

I was totally ignorant of the page key in \setupinteraction.

It works fine now, with both the options you provided (and the patch,
many thanks for both).

I have accidentally discovered an issue in which users may run in an
uninteded ways.

If many destinations have the same identifier, only the first one is
generated.

Using the following sample:

  \setupinteraction[state=start,
    focus=standard]
  \starttext
  \dorecurse{5}{\dorecurse{5}
    {\chapter[\recurselevel]{Chapter}
      \section[sec-\recurselevel]{Section}}}
  \stoptext

Of course, this kind of identifiers have to be unique to be useful, but
I wonder whether they may be created adding something like:

  identifier
  identifier-1
  identifier-2
  identifier-3
  …
  identifier-n

This way (or a similar one) all named destinations are created.

Of course, when linking with \goto, \in, \at, \about, the right
identifier should be chosen.

With links within the same document, correcting the identifier (or the
link destination) is a trivial matter.

With links from external documents, there may be no option to generate
the external files again. If destinations are there, inspecting the
external document is an option.

Would it be possible that already given destination identifiers could
automatically have another indentifier to generate a new destination?

I hope my explanation is clear. Let me know if it isn’t and I try to
ellaborate it further (in a clearer way 😅).

Many thanks for your help again,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-11-14 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 16:25 [NTG-context] named destinations in /GoToR Pablo Rodriguez via ntg-context
2023-11-13 22:30 ` [NTG-context] " Michal Vlasák
2023-11-14 17:28   ` Pablo Rodriguez via ntg-context

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 NNTP newsgroup(s).