![hyperref 包 - 更改书签的样式 - 添加文本标签](https://linux22.com/image/343405/hyperref%20%E5%8C%85%20-%20%E6%9B%B4%E6%94%B9%E4%B9%A6%E7%AD%BE%E7%9A%84%E6%A0%B7%E5%BC%8F%20-%20%E6%B7%BB%E5%8A%A0%E6%96%87%E6%9C%AC%E6%A0%87%E7%AD%BE.png)
使用\hyperref
包我想添加这个词章节在章节号之前,如下图所示。例如,我想用“第 1 章:希望它”来代替“1 希望它”。这可能吗?我在下面添加了我的起始代码。
启动代码:
\documentclass[]{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[]{hyperref}
\hypersetup
{
hidelinks, % Remove red boxes
bookmarksnumbered=true,
pdfauthor={Brian Griffin},
pdftitle={Wish it, Want it, Do it},
pdfsubject={Self help},
pdfkeywords={therapy,healing,chicken soup},
pdfproducer={Penguin Publishing}
}
\begin{document}
\chapter{Wish It}
What are all the things you want most in the world?
Use the following pages to write down all of your dreams and desires.
\blindtext
\chapter{Want It}
\blindtext
\chapter{Do It}
\blindtext
\end{document}
答案1
以下技巧重新定义\thechapter
输出书签的前缀:
\renewcommand*{\thechapter}{%
\texorpdfstring{}{\chaptername\space}\arabic{chapter}%
\texorpdfstring{}{: }%
}
\texorpdfstring
仅当字符串准备好用于书签(PDF 字符串)时,才会处理第二个参数。
完整示例:
\documentclass[]{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[]{hyperref}
\hypersetup
{
hidelinks, % Remove red boxes
bookmarksnumbered=true,
pdfauthor={Brian Griffin},
pdftitle={Wish it, Want it, Do it},
pdfsubject={Self help},
pdfkeywords={therapy,healing,chicken soup},
pdfproducer={Penguin Publishing}
}
\renewcommand*{\thechapter}{%
\texorpdfstring{}{\chaptername\space}\arabic{chapter}%
\texorpdfstring{}{: }%
}
% Section numbers without prefix or the place for adding a prefix
% "Section".
\renewcommand*{\thesection}{%
\arabic{chapter}.\arabic{section}%
}
\begin{document}
\tableofcontents
\chapter{Wish It}
What are all the things you want most in the world?
\section{Test section}
Use the following pages to write down all of your dreams and desires.
\blindtext
\chapter{Want It}
\blindtext
\chapter{Do It}
\blindtext
\end{document}