olsak / OpTeX

OpTeX - LuaTeX format with extended Plain TeX macros
http://petr.olsak.net/optex/
35 stars 13 forks source link

Improve/fix `hyperlinks.opm` #72

Closed vlasakm closed 2 years ago

vlasakm commented 2 years ago

I am in the process of updating the pdfextra package to OpTeX v1.04 and I noticed a few things about hyperlinks, that are not critical, but should probably be fixed in the next release:

Two and three are debatable. What do you think @olsak?

Illustration of \_linkdimens:

2021-08-27-140358

\fontfam[lm]
\typosize[8/12]
\hyperlinks \Blue \Blue
\def \_urlborder {1 0 0}
\lipsum[0]

\def\test{%
    \xlink{url}{https://www.lipsum.com/}{\Magenta}{\_lipsumtext[1]}
}

\test

\bigskip

\def\_linkdimens{height.75\_baselineskip depth.25\_baselineskip}
\test

\bye

The pdfextra logic for lining links uses \_baselineskip, but only for \hlink (package namespace). I am thinking about unconditionally replacing \xlink with \hlink when pdfextra is loaded, so unifying everything that makes sense will prevent surprises. (The link coloring and borders will be the same in the next release, unfortunately the PDF actions logic cannot be shared.)

olsak commented 2 years ago
  1. \hyperlinks{}{} should work. The fix can look like:

    \_let\_ilinkcolor=#1\_relax
    \_let\_elinkcolor=#2\_relax

    (lines 100, 101 of hyperlinks.opm).

  2. I keep the default setting of \_linkdimens in OpTeX. You can re-define \_linkdimens in pdfextra and/or merge \xlink with \hlink. Note, that \baselineskip unit in \_linkdimens is not 100 % solution of described problem: suppose that \baselineskip is changed just before \par but after paragraph text (with links) is typeset already.

vlasakm commented 2 years ago

Ad 2: I went with \_empty so that colors can be expandable if right macros are redefined.

Ad 3: OK. I know it's not perfect either, but certainly not worse and it is as far as one can get with the pdfTeX model.