Re: Is it possible to create named links?
Gavin Smith <[email protected]>
| Newsgroups | gmane.comp.tex.texinfo.general |
|---|---|
| Message-ID | <Y9/u7jhN68ve7MGr@starmint> |
On Sun, Feb 05, 2023 at 01:44:22PM +0100, Andreas Falkenhahn wrote:
> Hi,
>
> I'm wondering if it's possible to create named links in Texinfo documents. I want to define the text and the target node for the link. E.g. I want to define a link which appears as "Click here" in the PDF and when it is clicked, it jumps to a specified node. Is that possible?
>
> The only way to create links I've found is to use the @xref directive but this always generates additional pre-defined text so it's not possible to specify a custom label for the link, e.g.
>
> @xref{node,,Click here}
>
> appears as
>
> See Section XX [Click here], page XX, for details.
>
> in the PDF. So it's not possible to just have "Click here" or any other custom text as the link text. It'll always appear as the whole "See Section...." shebang in the PDF.
>
> Is it possible to embed custom-named links without that pre-defined "See Section..." in the PDF in any way?
The best I can work out is the following:
@set txiomitxrefpg
@ref{node,, Click here}
'txiomitxrefpg' is an undocumented flag to omit the "page XX" part,
and using @ref instead of @xref omits the leading "See". So what you
get is
Section XX [Click here] for details.
instead.
I'm sure you're aware this this would be no use if this part of the
manual were printed on paper.
I'm open to the idea of adding a "plain cross-reference" command as
it is a frequently-requested feature:
"If you really want a plain link in HTML output without affecting
other output formats, you could create a macro with conditional
definitions for each output format."
(https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Info-Format-FAQ.html)
However, it doesn't appear to be possible for PDF as you found,
and people don't like writing Texinfo @macro's (using @macro's is
not particularly recommended, either).
I imagine the new command would be something have the same syntax as @ref
and do nothing for Info output where *note markers are needed.
Some ideas for the name:
@rf - like @ref but shorter (but looks like a font command)
@x - short for cross-reference
@plainref - self-explanatory, but name is too long
@pref - stands for "plain reference", but would be confused with @pxref
@link - purpose is immediately obvious but unlike other ref commands
I'm favouring @x or @link but think @link would be better as manual
sources strewn with @x (or some other very short command) would be
forbidding for language newcomers.