使用\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}