printindex 目录中的条目

printindex 目录中的条目

TOC我希望索引中的条目与章节条目对齐。我可以用 来实现这一点\addcontents\printindex还会在 中放置一个条目,TOC但它与节条目对齐。

所以我想要:

  1. 改变如何printindex进入TOC
  2. 以消除printindex进入。

梅威瑟:

\documentclass{book}
\usepackage{multind}        % create the indices
\makeindex{names}           
\makeindex{subject}
\newcommand{\Ndx}[1] { \index{names}{#1} }     % define the type of entry
\newcommand{\Sdx}[1] { \index{subject}{#1} }   % to the indices
\usepackage[headings]{fullpage}         % 8-1/2, 11 page with 1" margins
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\fancyhead{}
\fancyfoot{}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[RE,LO]{\thepage}
\tableofcontents        % put table of contents here

\chapter{\bf Logic, Plausibility, and Probability}
\label{Ch:Logic}
\section{Logical Arguments and Reasoning }
It is obvious that logical arguments are essential to the judicial system. The logic must be able to treat syllogisms\Sdx{syllogism} that range from deductive\Sdx{syllogism!deductive} to abductive\Sdx{syllogism!abductive}, that is from strong to weak syllogisms \Sdx{syllogism!weak}\Sdx{syllogism!strong} as illustrated in the table taken from Author \Ndx{Author}
\Ndx{Cohen}
\Sdx{Cohen on probability}
\clearpage
\addcontentsline{toc}{chapter}{Subject Index}
\printindex{subject}{Subject Index}
\addcontentsline{toc}{chapter}{Name Index}
\printindex{names}{Name Index}
\end{document}

答案1

您可以进行修补\printindex,以便将条目排版为章节条目而不是默认条目(作为章节条目):

\documentclass{book}
\usepackage{multind}  
\usepackage{etoolbox}  

\patchcmd{\printindex}
  {section}
  {chapter}
  {}
  {}
      % create the indices
\makeindex{names}           
\makeindex{subject}
\newcommand{\Ndx}[1] { \index{names}{#1} }     % define the type of entry
\newcommand{\Sdx}[1] { \index{subject}{#1} }   % to the indices
\usepackage[headings]{fullpage}         % 8-1/2, 11 page with 1" margins
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\fancyhead{}
\fancyfoot{}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhead[LE,RO]{\rightmark}
\fancyhead[RE,LO]{\thepage}
\tableofcontents        % put table of contents here

\chapter{\bf Logic, Plausibility, and Probability}
\label{Ch:Logic}
\section{Logical Arguments and Reasoning }
It is obvious that logical arguments are essential to the judicial system. The logic must be able to treat syllogisms\Sdx{syllogism} that range from deductive\Sdx{syllogism!deductive} to abductive\Sdx{syllogism!abductive}, that is from strong to weak syllogisms \Sdx{syllogism!weak}\Sdx{syllogism!strong} as illustrated in the table taken from Author \Ndx{Author}
\Ndx{Cohen}
\Sdx{Cohen on probability}
\clearpage
\printindex{subject}{Subject Index}
\printindex{names}{Name Index}
\end{document}

在此处输入图片描述

顺便说一句,\bf是一个旧的 TeX 命令,在现代 LaTeX 文档中不应再使用;请使用\bfseries。此外,在 的参数中使用\bf(或)不会产生任何影响,因为类章节标题已经是粗体;要更改部分单元标题的格式,您可以使用专用包,例如或。\bfseries\chapterbooksectstytitlesec

使用imakeidx包,不需要修补命令:

\documentclass{book}
\usepackage{imakeidx}  

\makeindex[name=names,title=Name Index,intoc=true]          
\makeindex[name=subject,title=Subject Index,intoc=true]

\begin{document}

\tableofcontents

\chapter{Logic, Plausibility, and Probability}
\section{Logical Arguments and Reasoning }

\index[names]{Cohen}
\index[subject]{Cohen on probability}
\printindex[subject]
\printindex[names]

\end{document}

在此处输入图片描述

答案2

如果etoolbox您无法使用这个包,或者这是您加载这个包的唯一原因,您实际上可以不用它。

代码的相关部分mutlind.sty可以修改为

\makeatletter
\def\printindex#1#2{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
  \columnseprule \z@ \columnsep 35pt
  \newpage \twocolumn[{\Large\bf #2 \vskip4ex}]
  \markright{\uppercase{#2}}
  \addcontentsline{toc}{chapter}{#2}%   <---- NEW BIT
  \@input{#1.ind}}

您所要做的就是更改sectionchapter

这是一个完整的 MWE,请注意,我已将arara指令,这样你只需要运行

arara myfile

你 就会 得到 一个 完整 的pdf

% arara: pdflatex
% arara: makeindex: {files: [names]}
% arara: makeindex: {files: [subject]}
% arara: pdflatex
% arara: pdflatex
\documentclass{book}
\usepackage{multind}        % create the indices
\makeindex{names}           
\makeindex{subject}
\newcommand{\Ndx}[1] { \index{names}{#1} }     % define the type of entry
\newcommand{\Sdx}[1] { \index{subject}{#1} }   % to the indices

\makeatletter
\def\printindex#1#2{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
  \columnseprule \z@ \columnsep 35pt
  \newpage \twocolumn[{\Large\bf #2 \vskip4ex}]
  \markright{\uppercase{#2}}
  \addcontentsline{toc}{chapter}{#2}
  \@input{#1.ind}}

\begin{document}
\tableofcontents        % put table of contents here

\chapter{Logic, Plausibility, and Probability}\label{Ch:Logic}
\section{Logical Arguments and Reasoning }
It is obvious that logical arguments are essential to the judicial system. The logic must be able to treat syllogisms\Sdx{syllogism} that range from deductive\Sdx{syllogism!deductive} to abductive\Sdx{syllogism!abductive}, that is from strong to weak syllogisms \Sdx{syllogism!weak}\Sdx{syllogism!strong} as illustrated in the table taken from Author \Ndx{Author}
\Ndx{Cohen}
\Sdx{Cohen on probability}
\clearpage
\printindex{subject}{Subject Index}
\printindex{names}{Name Index}
\end{document}

相关内容