Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

\Hy@DisableOption in \PDF@FinishDoc is local, hence do nothing

オープン
#97 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
latex, tex
領域
tooling

調査の方向性

\PDF@FinishDoc、\Hy@DisableOption、および keyval と atbegshi のキー定義を追跡して、ローカルスコープによってオプションハンドラーの置き換えが妨げられている箇所を特定します。issue の最小ドキュメントを使用して、最初の改ページの前後で \KV@Hyp@pdftitle を比較します。ハンドラーがグローバルに無効化され、その後 \Hy@WarnOptionDisabled が発生すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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@FinishDoc is executed inside commands of atbegshi package, and
  • the \define@key (provided by keyval package) used by \Hy@DisableOption only 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@pdftitle is not redefined after the first page break.
  • With the fix, \KV@Hyp@pdftitle is redefined as desired and warning \Hy@WarnOptionDisabled is 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.

主要言語
TeX
スター
210
フォーク
41
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

latex3/hyperref のほかの issue

latex3/hyperref の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。