是否可以将章节、节等显示在目录中,但不作为文档中的实际标题?基本上,我只想告诉目录“在此处做个章节标记”,但不做实际的章节标题。我想在实习报告中的附录中这样做,该报告包含相当多的 NMR 光谱。
\documentclass[11pt,a4paper]{scrreprt}
\begin{document}
\tableofcontents
\setcounter{chapter}{0}
\renewcommand{\thechapter}{\Alph{chapter}}
\chapter{Spectra}
\section{Compounds for Teaching Purposes}
\includepdf[angle=90]{./spectra/DHcompd197_1}
\end{document}
目录应如下所示:
但我这里不想有标题:
答案1
问题
\cleardoublepage
\addcontentsline{toc}{chapter}{<chapter title>}% Add fake chapter to ToC
\includepdf[..]{...}
\cleardoublepage
让你进入常规的正确(右页)页面\chapter
。你可以对 s 和其他分部单位执行相同操作\section
,例如
\addcontentsline{toc}{chapter}{\numberline{A}Spectra}
\addcontentsline{toc}{section}{\numberline{A.1}Compounds for Teaching Purposes}
如果你使用hyperref
此外,\phantomsection
每次使用任意符号之前,您都需要添加一个\addcontentsline
,以便超链接能够正确跳转。更具体地说,
\usepackage{hyperref}
...
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\numberline{A}Spectra}
\phantomsection
\addcontentsline{toc}{section}{\numberline{A.1}Compounds for Teaching Purposes}
答案2
对于 KOMA-Script 类,我会使用
\cleardoubleoddpage
\refstepcounter{chapter}
\addchaptertocentry{\thechapter}{<chapter title>}
例子:
\documentclass[
%11pt,a4paper,% default
numbers=enddot% <- added
]{scrreprt}
\usepackage{pdfpages}%<- added
\usepackage{hyperref}
\newcommand\chapteronlytocentry[1]{%
\cleardoubleoddpage
\refstepcounter{chapter}%
\addchaptertocentry{\thechapter}{#1}%
}
\newcommand\sectiononlytocentry[1]{%
\cleardoubleoddpage
\refstepcounter{section}%
\addsectiontocentry{\thesection}{#1}%
}
\begin{document}
\tableofcontents
\clearpage
See appendix \ref{sec:asec} (page \pageref{sec:asec}).
\appendix
\chapteronlytocentry{Spectra}
\sectiononlytocentry{Compounds for Teaching Purposes}
\includepdf[angle=90,pages=1,pagecommand={}]{dummy-l.pdf}
\sectiononlytocentry{Another Section}\label{sec:asec}%
\includepdf[angle=90,pages=2]{dummy-l.pdf}
\end{document}
结果: