如何控制索引中条目的垂直间距

如何控制索引中条目的垂直间距
%
%--------------------------------------------------------------------------------------------------------- %
\documentclass{book} %
%--------------------------------------------------------------------------------------------------------- %
%
\usepackage{amsthm,amssymb} %
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} %\usepackage[nottoc]{tocbibind}
\usepackage[english]{babel} %
\usepackage{tikz} % tikz - essential
\usepackage[T1]{fontenc} % no apparent effect
\usepackage[utf8,latin1]{inputenx} %
\usepackage{txfonts} % 
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage[paperwidth=170mm,paperheight=240mm,textwidth=120mm,verbose,driver=none,showcrop, showframe]{geometry} % verbose,showcrop,showframe
\usepackage[a4,frame,center]{crop} %
\usepackage{ifpdf}
\usepackage[unbalanced,indentunit=12pt]{idxlayout}
\usepackage{imakeidx}

%
\setlength{\unitlength}{1mm} %
%
\indexsetup{othercode=\normalsize}
%
\makeindex[program=makeindex,title=Index - poor vertical spacing,columns=2,options={-s my_index_book.ist}]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTENT OF THE .ist file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% headings_flag 1

% heading_prefix "\\vspace*{0.4cm}\\nopagebreak\n\\tikz\\node at (0pt,0pt)
% [rounded corners=3pt,draw=ThemeColor,fill=ThemeGrey,line width=1pt,inner sep=5pt]
% {\\parbox{\\linewidth-2\\fboxsep-2\\fboxrule-2pt}{\\hspace{3pt}\\large\\sffamily\\bfseries\\textcolor{black}
% {" heading_suffix "}}};\\vspace*{0.1cm}\\nopagebreak\n"

% delim_0 "\\dotfill"

% delim_1 "\\dotfill"

% delim_2 "\\dotfill"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\definecolor{ThemeColor}{rgb}{0.45,0.00,0.45} %
\definecolor{ThemeGrey}{rgb}{0.93,0.93,0.93}

\begin{document}

% Sorry, don't know where the -2-2pt in heading of the index is coming from.
\noindent In the index that follows, I would like more space above word "apricot".

\index{apples!aaaaaaaaaaaaaa}
\index{apples!aaaaaaaaaaaaab}
\index{apples!aaaaaaaaaaaaac}
\index{apples!aaaaaaaaaaaaad}
\index{apricots!aaaaaaaaaaad}
\index{apricots!aaaaaaaaaaaae}
\index{apricots!aaaaaaaaaaaaf}
\index{apricots!aaaaaaaaaaaag}
\index{oranges!aaaaaaaaaaaag}
\index{oranges!aaaaaaaaaaaah}
\index{oranges!aaaaaaaaaaaak}
\index{oranges!aaaaaaaaaaaaz}
\index{oranges!aaaaaaaaaaaaz}
\index{oranges!aaaaaaaaaaaay}
\index{oranges!aaaaaaaaaaaay}
\index{oranges!aaaaaaaaaaaay}
\index{oranges!aaaaaaaaaaaar}
\index{oranges!aaaaaaaaaaaas}
\index{oranges!aaaaaaaaaaaad}
\index{oranges!aaaaaaaaaaaae}

\vspace{12pt}
\noindent Would like to control the vertical spacing (increase) above the word "apricot" in the index.

\printindex %

\end{document}

答案1

最干净的方法是使用包含以下内容的makeindex索引样式文件( ):.ist

item_0 "\n\\vspace{10pt}\\item "

另一种方法是使用以下命令修补环境theindex

\usepackage{etoolbox}
\patchcmd{\theindex}{\let\item\@idxitem}{\def\item{\vspace{10pt}\@idxitem}}{}{ERROR}

当然,你可以10pt根据自己的口味进行调整。

相关内容