有没有办法修改bookmarksnumbered
hyperref 选项,为章节编号添加前缀和/或后缀?该选项目前将书签更改Introduction
为1 Introduction
,但我希望实现类似C1 - Introduction
\documentclass{book}
\usepackage[bookmarksnumbered]{hyperref}
\begin{document}
\chapter{Introduction}
\end{document}
答案1
\thechapter
在书签写入操作之前插入修改后的命令即可(至少对于小文档而言)。
(很可能 \let...` 语句是必要的。我稍后会检查)
\documentclass{book}
\usepackage[bookmarksnumbered]{hyperref}
\usepackage{xpatch}
\let\origthechapter\thechapter
\makeatletter
\xpatchcmd{\addcontentsline}{%
\Hy@writebookmark{\csname the#2\endcsname}%
{#3}%
{\@currentHref}%
{\Hy@toclevel}%
{#1}%
}{%
\begingroup
\renewcommand{\thechapter}{C\origthechapter}
\Hy@writebookmark{\csname the#2\endcsname}%
{#3}%
{\@currentHref}%
{\Hy@toclevel}%
{#1}%
\endgroup
}{\typeout{Success}}{}
\makeatother
\begin{document}
\chapter{Introduction}
\section{Other One}
\chapter{Two}
\end{document}