将索引条目拆分为两行

将索引条目拆分为两行

是否可以在两行之间拆分条目(一行中是参考资料,另一行中是页码)?我有一个包含长条目的索引,我发现这种情况从未发生过,这会导致出现大片空白。

以下是 MWE:

\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[font=footnotesize, columnsep=15pt]{idxlayout}

\renewcommand{\indexspace}{\par}

\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} }
 }

\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{.1em plus 3em} }
 }

\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}

相关内容