自定义索引,在前面添加点填充

自定义索引,在前面添加点填充

我想自定义我的索引,所以我使用了latex makeindex -s myfile.ist texfile.idx latex汇编。

myfile.ist 包含:

% 
heading_prefix "{\\bfseries\\hfil "
heading_suffix "\\hfil}\\nopagebreak\n"
headings_flag 1

% 
delim_0 "\\dotfill"
delim_1 "\\dotfill"
delim_2 "\\dotfill"

我的 TeX 文件包含:

% arara: pdflatex: { synctex: on }
% arara: makeindex
% arara: pdflatex: { synctex: on }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[l2tabu, orthodox]{nag}  %
\documentclass[11pt,a4paper,openright]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{makeidx}
\usepackage{lipsum}


\makeindex

\author{Romain}
\title{Index Book}

\begin{document}

\maketitle
\frontmatter        

\chapter{Preface}
    \lipsum \index{preface}

\mainmatter         

\chapter{Intro}
    \lipsum \index{intro}

\appendix

\chapter{balala}
    \lipsum \index{annxes}


\chapter{balba}
    \lipsum \index{annxes} 

\backmatter
\chapter{epilogue}\index{epilogue}
    toto. 

    \printindex \label{index} 


\end{document}

我收到错误信息: Undefined control sequence. \item preface \dotfill

我尝试删除delim_* "\\dotfill"\index{preface},两种情况均有效。那么frontmatter和中的索引delim_* "\\dotfill"兼容吗?

答案1

当我尝试您的代码时,LaTeX 抱怨\dotfillii未定义。因此我得出结论,ii前言中的页码是在添加后直接添加的delim_0

我查看了生成的.ind文件并发现

\begin{theindex}
{\bfseries\hfil A\hfil}\nopagebreak

  \item annxes\dotfill4, 6

  \indexspace
{\bfseries\hfil E\hfil}\nopagebreak

  \item epilogue\dotfill7

  \indexspace
{\bfseries\hfil I\hfil}\nopagebreak

  \item intro\dotfill2

  \indexspace
{\bfseries\hfil P\hfil}\nopagebreak

  \item preface\dotfillii

\end{theindex}

不是预期的

\begin{theindex}
{\bfseries\hfil A\hfil}\nopagebreak

  \item annxes\dotfill 4, 6

  \indexspace
{\bfseries\hfil E\hfil}\nopagebreak

  \item epilogue\dotfill 7

  \indexspace
{\bfseries\hfil I\hfil}\nopagebreak

  \item intro\dotfill 2

  \indexspace
{\bfseries\hfil P\hfil}\nopagebreak

  \item preface\dotfill ii

\end{theindex}

添加空间是合乎逻辑的结论。

相关内容