\Hy@DisableOption in \PDF@FinishDoc is local, hence do nothing
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 205
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
Currently, hyperref, at the time of first page break, uses \PDF@FinishDoc to set PDF info fields like pdftitle and make related options disable. After that, any key-val setting to options like pdftitle will not influence the corresponding field in the output PDF, and should raise warning \Hy@WarnOptionDisabled.
But, since
- the
\PDF@FinishDocis executed inside commands ofatbegshipackage, and - the
\define@key(provided bykeyvalpackage) used by\Hy@DisableOptiononly locally (re)defines key,
options like pdftitle are never disabled, hence usages after first page break won't raise any warning.
Following is a quick fix (with test by showing the meaning of \KV@Hyp@pdftitle) by providing global variant of \define@key and using it inside \PDF@FinishDoc.
- Without fix,
\KV@Hyp@pdftitleis not redefined after the first page break. - With the fix,
\KV@Hyp@pdftitleis redefined as desired and warning\Hy@WarnOptionDisabledis raised after the first page break.
\documentclass{article}
\usepackage{hyperref}
\hypersetup{pdftitle={preamble}}
\makeatletter
%% redifined to use \define@key@g
\def\Hy@DisableOption#1{%
\ltx@ifundefined{KV@Hyp@#1@default}{%
\define@key@g{Hyp}{#1}%
}{%
\define@key@g{Hyp}{#1}[]%
}%
{\Hy@WarnOptionDisabled{#1}}%
}
%% add \global version of \defin@key
\def\define@key@g#1#2{%
\@ifnextchar[{\KV@def@g{#1}{#2}}{\global\long\@namedef{KV@#1@#2}####1}}
%% add \global version of \KV@def
\def\KV@def@g#1#2[#3]{%
\global\long\@namedef{KV@#1@#2@default\expandafter}\expandafter
{\csname KV@#1@#2\endcsname{#3}}%
\global\long\@namedef{KV@#1@#2}##1}
\makeatother
\listfiles
\begin{document}
%% this one succeeds in changing the Title field
\hypersetup{pdftitle={before first newpage}}
a
\newpage
%% with fix, this one raises warning
\hypersetup{pdftitle={after first newpage}}
%% check meaing of \KV@Hyp@pdftitle
\makeatletter
\ttfamily
\meaning\KV@Hyp@pdftitle
\makeatother
\end{document}
This issue is first reported, in Chinese, in https://github.com/CTeX-org/forum/issues/42.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace \PDF@FinishDoc, \Hy@DisableOption, and the key definitions from keyval and atbegshi to identify where local scoping prevents the option handler from being replaced. Use the minimal document in the issue to compare \KV@Hyp@pdftitle before and after the first page break; done means the handler is disabled globally and \Hy@WarnOptionDisabled is raised afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- latex, tex
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100