一列和两列组合的索引

一列和两列组合的索引

我正在使用以下内容来创建我的索引文件。

heading_prefix "{\n\\bfseries\\color{black} "      % insert in front of letter
heading_suffix "\\hfil}\\nopagebreak\n"  % append after letter
headings_flag  1                 % turn on headings(uppercase)

delim_0 "\\dotfill"

索引条目出现在一列中,这样就没问题了。我想知道是否有办法让子索引条目出现在多列中,因为它们的长度较短?

以下为一个 MWE 说明:

\documentclass{article}
\usepackage{fontspec,lipsum}
\defaultfontfeatures{Ligatures=TeX}

\setromanfont{Georgia}

\usepackage{index}\makeindex

\makeatletter
\renewenvironment{theindex}
   {%\section*{\indexname}%
    \setlength\parindent{0pt}%
    \setlength\parskip{0pt plus .3pt}%
    \let\item\@idxitem
%    \vspace*{-25mm}
    }
\makeatother 


\begin{document}

\section{Introduction}

Lorem \index{ipsum dolor sit amet, consectetuer} \index{adipiscing elit. Ut purus} elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, \index{consectetuer id}, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi \index{tristique senectus} et ne-
tus et \index{form!malesuada} \index{form!fames} \index{form!ac} turpis egestas. Mauris ut leo. Cras viverra metus
rhoncus sem. Nulla et lectus vestibulum urna \index{form!fringilla} \index{form!ultrices}. Phasellus eu
tellus sit amet tortor gravida placerat. \index{form!Integer} sapien est, iaculis in, pretium
quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, \index{form!mollis} \index{form!ac}, nulla. Cur-
abitur \index{form!auctor} semper \index{form!nulla}. \index{form!Donec} varius \index{form!orci} eget risus. \index{form!Duis} \index{form!nibh} mi, congue
eu, \index{form!accumsan} \index{form!eleifend}, \index{form!sagittis} \index{form!quis}, \index{form!diam}. \index{form!Duis} \index{form!eget} \index{form!orci} \index{form!sit} \index{form!amet} \index{form!orci} \index{form!dignissim}.
rutrum.

\bigskip

\printindex

\end{document}

我已使用以下说明来创建索引文件。

xelatex tst.tex

makeindex -s MyIST.ist tst.idx

xelatex tst.tex

evince tst.pdf

MyIST.ist 的内容如下。

heading_prefix "{\n\\bfseries\\ "      % insert in front of letter
heading_suffix "\\hfil}\\nopagebreak\n"  % append after letter
headings_flag  1                 % turn on headings(uppercase)

delim_0 "\\dotfill"

从输出中可以看出,“form”下的所有条目都很短。我想将这些条目排列成 2 列甚至 3 列,而不是像现在这样排列成 1 列。

答案1

计划A设为一段:

在此处输入图片描述

\renewcommand\subitem{\unskip\hspace{0pt plus .7\textwidth}\linebreak[3]\hspace{1em plus -.4\textwidth minus .2em}}
\printindex

或者...

计划 B:设置 3 列:

在此处输入图片描述

不要重新\subitem定义

heading_prefix "{\n\\bfseries\\ "      % insert in front of letter
heading_suffix "\\hfil}\\nopagebreak\n"  % append after letter
headings_flag  1                 % turn on headings(uppercase)

delim_0 "\\dotfill"

item_x1 "\n\\begin{multicols}{3}\n\\subitem "
group_skip "\n\\ifdim\\columnwidth<\\textwidth\\end{multicols}\\fi\n\n \\indexspace\n"

添加

\usepackage{multicol}

答案2

David 计划 A 的变体:使用我的idxlayout包。(注意:使用 MakeIndex 编译以下 MWE没有任何-s選擇。

\documentclass{article}

\usepackage{index}
\makeindex

\usepackage[columns=1,itemlayout=singlepar]{idxlayout}

\usepackage{filecontents}

\begin{filecontents}{\jobname.mst}
heading_prefix "{\n\\bfseries\\ "
heading_suffix "\\hfil}\\nopagebreak\n"
headings_flag  1
delim_0 "\\dotfill"
\end{filecontents}

\begin{document}

\section{Introduction}

Lorem \index{ipsum dolor sit amet, consectetuer} \index{adipiscing elit. Ut purus} elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, \index{consectetuer id}, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi \index{tristique senectus} et ne-
tus et \index{form!malesuada} \index{form!fames} \index{form!ac} turpis egestas. Mauris ut leo. Cras viverra metus
rhoncus sem. Nulla et lectus vestibulum urna \index{form!fringilla} \index{form!ultrices}. Phasellus eu
tellus sit amet tortor gravida placerat. \index{form!Integer} sapien est, iaculis in, pretium
quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, \index{form!mollis} \index{form!ac}, nulla. Cur-
abitur \index{form!auctor} semper \index{form!nulla}. \index{form!Donec} varius \index{form!orci} eget risus. \index{form!Duis} \index{form!nibh} mi, congue
eu, \index{form!accumsan} \index{form!eleifend}, \index{form!sagittis} \index{form!quis}, \index{form!diam}. \index{form!Duis} \index{form!eget} \index{form!orci} \index{form!sit} \index{form!amet} \index{form!orci} \index{form!dignissim}.
rutrum.

\printindex

\end{document}

在此处输入图片描述

相关内容