0

I have a very long index and I'm using a layout which you can find here, with an MWE: Fix the layout of index with imakeidx: a new implementation.

It prints here and here unwanted white spaces between the entries: I tryied the method of this answer, but it doesn't work.

Is there a way to avoid unwanted vertical spaces between index entries?

Here is an MWE, but obviously the problem presents itself with a very long index, which is that of my book:

\begin{filecontents*}{\jobname.mst}
item_0 "\n\n \\item "
item_1 " \\firstlevel "
item_2 " \\secondlevel "
item_01 " \\firstlevel "
item_x1 " \\firstlevel "
item_12 " \\secondlevel "
item_x2 " \\secondlevel "
delim_0 ":~"
delim_1 ":~"
delim_2 ":~"
\end{filecontents*}

\documentclass[a4paper, 11pt, twoside, openright]{article}

\usepackage[top=49.5mm,bottom=52.5mm,inner=39mm,outer=39mm, headheight=4mm, headsep=6mm, marginparwidth=14mm, marginparsep=2mm, nofoot]{geometry}


\usepackage[no-math]{fontspec}
\defaultfontfeatures{Ligatures={TeX, NoCommon}}


\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage[variant=ancient]{greek}
\setotherlanguage{german}
\setotherlanguage{english}
\setotherlanguage{latin}

\widowpenalty=500 
\clubpenalty=100

\usepackage{microtype}
\usepackage{imakeidx}
\usepackage{xparse}
\usepackage{xpatch}
\usepackage{xpatch}
\usepackage[font=footnotesize]{idxlayout}


\ExplSyntaxOn
\seq_new:N \l_ale_index_item_seq
\seq_new:N \l_ale_index_subitem_seq
\tl_new:N \l_ale_index_author_tl
\tl_new:N \l_ale_index_work_tl
\dim_new:N \l_ale_index_indent_dim

\cs_set_protected:cpn { @idxitem } #1 \par
 {
  \tl_if_in:nnTF { #1 } { \firstlevel }
   {
    \tl_if_in:nnTF { #1 } { \secondlevel }
     {
      \ale_index_secondlevel:n  { #1 } \par
     }
     {
      \ale_index_firstlevel:n  { #1 } \par
     }
   }
   {
    \ale_index_nolevel:n  { #1 } \par
   }
 }

\cs_new_protected:Npn \ale_index_nolevel:n #1
 {
  \seq_set_split:NVn \l_ale_index_item_seq \c_colon_str { #1 }
  \seq_pop_left:NN \l_ale_index_item_seq \l_ale_index_author_tl
  \hbox_set:Nn \l_tmpa_box { \l_ale_index_author_tl, }
  \dim_set:Nn \l_ale_index_indent_dim { \box_wd:N \l_tmpa_box }
  \par\hangindent\l_ale_index_indent_dim
  \l_ale_index_author_tl, \seq_use:Nn \l_ale_index_item_seq { }
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { NV }

\cs_new_protected:Npn \ale_index_secondlevel:n #1
 {
  \seq_set_split:Nnn \l_ale_index_item_seq { \firstlevel } { #1 }
  \seq_pop_left:NN \l_ale_index_item_seq \l_ale_index_author_tl 
  \l_ale_index_author_tl\par
  \seq_map_function:NN \l_ale_index_item_seq \ale_index_subitem:n
 }
\cs_new_protected:Npn \ale_index_subitem:n #1
 {
  \seq_set_split:Nnn \l_ale_index_subitem_seq { \secondlevel } { #1 }
  \seq_pop_left:NN \l_ale_index_subitem_seq \l_ale_index_work_tl
  \hbox_set:Nn \l_tmpa_box { \l_ale_index_work_tl,~ }
  \dim_set:Nn \l_ale_index_indent_dim { \box_wd:N \l_tmpa_box }
  \par\hangindent=2em
  \quad\l_ale_index_work_tl,~\seq_use:Nn \l_ale_index_subitem_seq { ;\hspace{.3em plus 3em  minus 1em} }
 }

\cs_new_protected:Npn \ale_index_firstlevel:n #1
 {
  \seq_set_split:Nnn \l_ale_index_item_seq { \firstlevel } { #1 }
  \seq_pop_left:NN \l_ale_index_item_seq \l_ale_index_author_tl
  \hbox_set:Nn \l_tmpa_box { \l_ale_index_author_tl,~ }
  \dim_set:Nn \l_ale_index_indent_dim { \box_wd:N \l_tmpa_box }
 \par\hangindent=1em
  \l_ale_index_author_tl,~\seq_use:Nn \l_ale_index_item_seq { ;\hspace{.3em plus 3em minus 1em} }
 }

\ExplSyntaxOff




\makeindex[name=1,options=-s \jobname.mst]
\makeindex[name=2,options=-s \jobname.mst]
\makeindex[name=3,options=-s \jobname.mst]
\makeindex[name=4,options=-s \jobname.mst]

\newcommand*{\cose}[1]{\index[1]{#1}\ignorespaces}
\newcommand*{\parole}[1]{\index[2]{#1}\ignorespaces}
\newcommand*{\autori}[1]{\index[4]{#1}\ignorespaces}

\begin{document}

text



\autori{Author!Work1!1,15} 
\autori{Author!Work1!9,32}
\autori{Author!Work1!1,12} 
\autori{Author!Work1!9,22}
\autori{Author!Work1!1,25} 
\autori{Author!Work1!9,31}
\autori{Author!Work2!2,24} 
\autori{Author!Work2!5,11}
\autori{Author!Work2!2,25} 
\autori{Author!Work2!5,12}
\autori{Author!Work1!11,42}

\autori{Author2!4,34}
\autori{Author3!6,12} 
\autori{Author3!9,4}
\autori{Author4!9,4}
\autori{Author4!9,5}
\autori{Author4!2,6}
\autori{Author5!2,34}
\autori{Author6!2,4}
\autori{Author7!2,4}
\autori{Author8!2,12} 
\autori{Author 123456!2,12} 
\autori{Author 123456!2,13} 
\autori{Author 123456!2,14} 
\autori{Author 123456!2,15} 

\autori{Author123 (ed. Author10)!Op. XYZ!2,45} 
\autori{Author123 (ed. Author10)!Op. XYZ!2,46} 
\autori{Author123 (ed. Author10)!Op. XYZ!2,47} 
\autori{Author323 (ed. Author10)!Op. XYZ!2,48} 
\autori{Author232 (ed. Author10)!Op. XYZ!2,49} 
\autori{Author933 (ed. Author10)!Op. XYZ!2,50} 

\autori{Author9 (ed. Author10)!Op. XYZ!2,45} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,46} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,47} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,48} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,49} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,52} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,42} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,4446} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,465} 
\autori{Author9 (ed. Author10)!Op. XYZ!2,443343} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,423433} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,534341} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,4446} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,465} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,443} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,423} 
\autori{Author9 (ed. Author10)!Op. XYZ!3,51} 

\printindex[4]

\end{document}

Here an example:

enter image description here

qwertxyz
  • 542
  • Why do you expect us to go searching around for bits of code? Please show what you have tried. --- GOM – Peter Wilson Apr 22 '20 at 18:55
  • @PeterWilson I added an MWE, but obviously the problem presents itself with a very long index, which is that of my book – qwertxyz Apr 22 '20 at 19:42
  • Is the vertical space between entries consistent within a column (just different in different columns), or does it vary between different entries in the same column? If consistent within a column, the only way to make it consistent seems to me to be to use \raggedbottom, which is definitely inelegant. Better to try to break entries, as you suggested earlier. (It's not easy for me to test, but I'll try.) – barbara beeton Apr 22 '20 at 21:34
  • It occurs here and here just after an entry, as you can see in the image I added in my question – qwertxyz Apr 22 '20 at 21:44
  • Aha! although the image is blurry, it seems that these large gaps are between groups where the initial letter changes. Is this correct? If so, that is an easy fix. It is a dimension set by the command \indexspace. And that can be reset. (I haven't yet managed to find where it is set.) – barbara beeton Apr 22 '20 at 22:26
  • Yes! I'm sorry, I hadn't noticed! How could I do? – qwertxyz Apr 22 '20 at 22:31
  • In article.cls, this is the definition of \indexspace: \newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}. If you want to eliminate it entirely, then \renewcommand{\indexspace}{\par}. – barbara beeton Apr 22 '20 at 22:40
  • Thank you very much. I managed to solve it. Could you write it as an answer? – qwertxyz Apr 22 '20 at 22:48

0 Answers0