如何添加未编号的\chapter
( \chapter*
) 或\section
( \section*
),并将其包含在目录 (TOC) 和 PDF 书签中?理想情况下,适用于标准类和 Koma 类。
- 这个问题显然是重复的,看这里就是例子。
- 但我刚刚帮助一位聪明的朋友完成他的博士论文,他很难解决这个问题(找到正确的答案)。
- 因此,我尝试在此提供更清晰、更完整的问题和答案,以便未来的 LaTeX 用户更容易找到解决方案。
不起作用的示例
\documentclass{article}
\usepackage{hyperref} % or bookmark
\begin{document}
\tableofcontents
\section*{Thanks}
Text.
\section{Introduction}
Text.
\end{document}
答案1
如果我犯了错误或没有遵循最佳实践,请发表评论或编辑答案。
article
课堂解决方案
谢谢@UlrikeFischer 的提示。
\documentclass{article}
% Small pages for demo purposes.
\usepackage[a6paper]{geometry}
\usepackage{blindtext}
% "bookmarksnumbered" is optional: It adds the heading number to the bookmark.
\usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package
\begin{document}
\tableofcontents
% Start
% --- ---
\setcounter{secnumdepth}{-1}
\section{Thanks} % <-- Replace "Thanks" with your heading title.
\sectionmark{Thanks} % <-- Replace "Thanks" with your heading title.
\setcounter{secnumdepth}{2}
% --- ---
% End
\blindtext
\section{Introduction}
\subsection{SubSection}
\blindtext
\end{document}
book
或report
类的解决方案
谢谢@UlrikeFischer 的提示。
\documentclass{book} % or "report"
% Small pages for demo purposes.
\usepackage[a6paper]{geometry}
\usepackage{blindtext}
% "bookmarksnumbered" is optional: It adds the heading number to the bookmark.
\usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package
\begin{document}
\tableofcontents
% Start
% --- ---
\setcounter{secnumdepth}{-1}
\chapter{Thanks} % <-- Replace "Thanks" with your heading title.
\chaptermark{Thanks} % <-- Replace "Thanks" with your heading title.
\setcounter{secnumdepth}{2}
% --- ---
% End
\blindtext
\chapter{Introduction}
\section{Section}
\blindtext
\end{document}
scrartcl
KOMA 类解决方案
\documentclass{scrartcl}
% Small pages for demo purposes.
\usepackage[a6paper]{geometry}
\usepackage{blindtext}
% "bookmarksnumbered" is optional: It adds the heading number to the bookmark.
\usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package
\begin{document}
\tableofcontents
% Start
% --- ---
\addsec{Thanks} % <-- Replace "Thanks" with your heading title.
% --- ---
% End
\blindtext
\section{Introduction}
\subsection{SubSection}
\blindtext
\end{document}
scrbook
或scrreport
KOMA 类的解决方案
\documentclass{scrbook} % or "scrreport"
% Small pages for demo purposes.
\usepackage[a6paper]{geometry}
\usepackage{blindtext}
% "bookmarksnumbered" is optional: It adds the heading number to the bookmark.
\usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package
\begin{document}
\tableofcontents
% Start
% --- ---
\addchap{Thanks} % <-- Replace "Thanks" with your heading title.
% --- ---
% End
\blindtext
\chapter{Introduction}
\section{Section}
\blindtext
\end{document}