如何在索引页中添加说明性文字而不受页码困扰?

如何在索引页中添加说明性文字而不受页码困扰?

我喜欢在索引开始后添加介绍文字(与命名法相同)。

将包添加imakeidx到这里使用的makeidx包中并另外写入\indexprologue{\noindent text}将破坏目录中的页码。(正如我尝试过的如何在索引页中添加说明性文字?

这可能吗?

\synctex=-1
\documentclass[a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc,DIV=15]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
  \pagestyle{scrheadings}
  \clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
  \automark[chapter]{chapter}
   \renewcommand*\chaptermarkformat{}% uncomment if you don't want chapter numbers in the headers
  \ihead[]{\headmark}
  \ohead[\pagemark]{\pagemark}
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}

\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{makeidx}

% I need an introducing text before the index
% ......

\makeindex
\makeatletter % needed because I need separation between different items of the same starting character
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \def\indexspace{}
  \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

% write a text before the glossar!
\renewcommand{\nompreamble}{Beachte: Es gibt verschiedene Schokoladen.}
\makenomenclature

\begin{document}
\begin{titlepage}% because I need a custom layout
  \centering
  \vspace*{10cm}
  titlepage
\end{titlepage}

\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}

\chapter{Einleitung}
\lipsum[1]
\newpage
\lipsum[2]
\newpage
\lipsum[3]

\chapter{Nahrung im Sommer}

\lipsum[4]

\nomenclature{Banane}{Frucht}
\nomenclature{Schokolade}{Suessigkeit \\ meistens 100 g schwer}

\index{book}
\index{summer!sun}
\index{summer!Supersonnenschirm/Supersonnenbad/ \newline Supersandstrum/Supersieg}
\index{summer!heat!sweat}
\index{sound}
\index{tower}
\count255=0
\loop\ifnum\count255<30
\advance\count255 1
\expandafter\index\expandafter{\romannumeral\count255}
\repeat

\newpage{}
\thispagestyle{empty}
\vspace*{\fill}\begin{center}  \begin{Huge} Anhang \end{Huge}   \vspace*{\fill}\end{center} 
\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{empty line}}\protect\par}
\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{empty line}}\protect\par}
\addtocontents{toc}{\textbf{\sffamily Anhang}\protect\par}

\printnomenclature[2.5 cm]

\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex

\end{document}

重要的是:

  • 目录中的页码应该保持不变
  • 目录中的标记应保持不变
  • 文档中的标题(如您在第一章中看到的)应该保持不变

这道题接着前面的密集代码工作进行: 如何解决页码问题(在目录、hyperref、scrheadings、命名法中)? 如何设置两个具有相同字符的索引条目之间的空格 如何在命名法标题开始后添加 tex 特定区域?


这是我从以下@egreg 的答案中尝试并成功的代码:

\documentclass[a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc,DIV=15]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
\pagestyle{scrheadings}
\clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
\automark[chapter]{chapter}
\renewcommand*\chaptermarkformat{}% uncomment if you don't want chapter numbers in the headers
\ihead[]{\headmark}
\ohead[\pagemark]{\pagemark}
\renewcommand*\partpagestyle{empty}
\usepackage{imakeidx} % load always before the hyperref package, otherwise it can result in problems!
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}

\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{makeidx}

\makeindex[intoc,title=Stichwortverzeichnis] % no redefining is needed with \renewcommand{\indexname}{Stichwortverzeichnis} before \printindex
\makeatletter % needed because I need separation between different items of the same starting character
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \def\indexspace{}
  \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

% write a text before the glossar!
\renewcommand{\nompreamble}{Whatever you want at the beginning of the nomenclature}
\makenomenclature

\begin{document}
\begin{titlepage}% because I need a custom layout
  \centering
  \vspace*{10cm}
  titlepage
\end{titlepage}

\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}

\chapter{Einleitung}
\lipsum[1]
\newpage
\lipsum[2]
\newpage
\lipsum[3]

\chapter{Nahrung im Sommer}

\lipsum[4]

\nomenclature{Banane}{Frucht}
\nomenclature{Schokolade}{Suessigkeit \\ meistens 100 g schwer}

\index{book}
\index{summer!sun}
\index{summer!Supersonnenschirm/Supersonnenbad/ \newline Supersandstrum/Supersieg}
\index{summer!heat!sweat}
\index{sound}
\index{tower}
\count255=0
\loop\ifnum\count255<30
\advance\count255 1
\expandafter\index\expandafter{\romannumeral\count255}
\repeat

\cleardoublepage
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
    \Huge Anhang
    \addtocontents{toc}{%
        \protect\addvspace{0.5pc}% <------------- adjust to suit
        \textbf{\sffamily Anhang}\protect\par
    }
\end{center}
\vspace*{\fill}
\clearpage

\printnomenclature[2.5 cm]

\indexprologue{Whatever you want at the beginning of the index}
\printindex

\end{document}

答案1

一定有更好的方式来编写目录行,但是仍然......

\documentclass[a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc,DIV=15]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
  \pagestyle{scrheadings}
  \clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
  \automark[chapter]{chapter}
   \renewcommand*\chaptermarkformat{}% uncomment if you don't want chapter numbers in the headers
  \ihead[]{\headmark}
  \ohead[\pagemark]{\pagemark}
  \renewcommand*\partpagestyle{empty}
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}

\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{makeidx}

% I need an introducing text before the index
\setindexpreamble{some text for the preamble of the index}

\makeindex
\makeatletter % needed because I need separation between different items of the same starting character
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \def\indexspace{}
  \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

% write a text before the glossar!
\renewcommand{\nompreamble}{Beachte: Es gibt verschiedene Schokoladen.}
\makenomenclature

\begin{document}
\begin{titlepage}% because I need a custom layout
  \centering
  \vspace*{10cm}
  titlepage
\end{titlepage}

\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}

\chapter{Einleitung}
\lipsum[1]
\newpage
\lipsum[2]
\newpage
\lipsum[3]

\chapter{Nahrung im Sommer}

\lipsum[4]

\nomenclature{Banane}{Frucht}
\nomenclature{Schokolade}{Suessigkeit \\ meistens 100 g schwer}

\index{book}
\index{summer!sun}
\index{summer!Supersonnenschirm/Supersonnenbad/ \newline Supersandstrum/Supersieg}
\index{summer!heat!sweat}
\index{sound}
\index{tower}
\count255=0
\loop\ifnum\count255<30
\advance\count255 1
\expandafter\index\expandafter{\romannumeral\count255}
\repeat

\part*{Anhang}
\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{empty line}}\protect\par}
\addtocontents{toc}{\textbf{\sffamily \textcolor{white}{empty line}}\protect\par}
\addtocontents{toc}{\textbf{\sffamily Anhang}\protect\par}

\printnomenclature[2.5 cm]

\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex

\end{document}

带序言的索引

答案2

imakeidx应该加载该包 hyperref

那么你只需要

\makeindex[intoc,title=Stichwortverzeichnis]

以及您想要打印索引的位置,

\indexprologue{Whatever you want at the beginning of the index}
\printindex

\renewcommand{\indexname}由于有title=选项,所以不需要)。

对文档进行这些更改后,目录页将

在此处输入图片描述

虽然索引页是

在此处输入图片描述

笔记

不要像以前那样在“Anhang”前面加空格,而是使用

\cleardoublepage
\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
\Huge Anhang
\addtocontents{toc}{%
  \protect\addvspace{2pc}% <------------- adjust to suit
  \textbf{\sffamily Anhang}\protect\par
}
\end{center}
\vspace*{\fill}
\clearpage

相关内容