3

I have some trouble formatting my index with idxlayout.

As my MWE demonstrates, the vertical spacing between the entries is inconsistent. For example the vertical spacing among the entries of entrygroup A is larger than in D. The group themselves are spaced varaibly: D and E are spaced ok, A and B are not.

My real example (which is too large) is even worse. Sometimes the middle column is filled only with 6 lines spread erratically over the column whereas the other lines are filled with more entries.

How do I prevent the rubber spacing and use a fixed one?

Optionally: How do I set a penalty which prevents only the group heading from apperaring alone?

Your help is greatly appreciated!

This is the vertically inconsistent index

% !TEX encoding = UTF-8 Unicode
% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]

\documentclass[%
    12pt,a4paper,twoside,parskip=never,ngerman,headings=normal,]{scrbook} 

\setlength\parindent{0pt}
\usepackage[english,main=ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}
\begin{filecontents*}{xindystyle.xdy}
(define-location-class "Roman-page-numbers"  ("roman-numbers-uppercase"))
(define-location-class "arabic-page-numbers" ("arabic-numbers")             
                    :min-range-length 1)                        

(define-attributes (("definition" "usage" "default" "hyperpage")))

(define-crossref-class "see")
(markup-crossref-list :class "see" :open "\seelinkk{" :sep "; " :close "}{}")

(define-crossref-class "seealso")
(markup-crossref-layer-list :sep ", ")
(markup-crossref-list :class "seealso" :open "\seealsolinkk{" :sep "; " :close "}{}")

(markup-range :class "arabic-page-numbers" :close "\,f."  :length 1 :ignore-end)
(markup-range :class "arabic-page-numbers" :close "\,ff." :length 2 :ignore-end)
(markup-range :class "arabic-page-numbers" :sep "--")

(define-crossref-class "hyperindexformat")
(markup-crossref-list :class "hyperindexformat" :open
       "\hyperindexformat{" :sep "; " :close "}{}")


(define-location-class-order (
            "Roman-page-numbers"
              "arabic-page-numbers"
              "see"
              "seealso"))

(sort-rule "-" "")

(markup-index :open  "~n\begin{theindex}
                    \providecommand*\lettergroupDefault[1]{}
                    \providecommand*\lettergroup[1]{%
                        \par\textbf{#1}\par
                        \nopagebreak
                    }
                    \newcommand{\targetindexentryy}[1]{\hypertarget{index:#1}{#1}}
                    \newcommand{\seelinkk}[1]{\see{\hyperlink{index:#1}{#1}}}
                    \newcommand{\seealsolinkk}[1]{\seealso{\hyperlink{index:#1}{#1}}}
                ~n"     
    :close "~n~n\end{theindex}~n"
    :tree)

(markup-indexentry :open "~n \item "            :depth 0)
(markup-indexentry :open "~n    \subitem "      :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

(markup-locref-list :sep ", ")
(markup-locclass-list :open "\dotfill " :close "" :sep ", ")
(markup-locref :open "\hyperpage{" :close "}")
(markup-locref :open "\hyperpage{" :close "}" :attr "hyperpage")   

(markup-keyword-list :open "\targetindexentryy{" :close "}" )
\end(filecontents)
\usepackage[
]{imakeidx}
    \makeindex[
        columns=3,
        name=person,
        title={Personenverzeichnis},
        program=truexindy,
        options=-M texindy -M page-ranges -M xindystyle -C utf8 -L german-duden,
        ]
\usepackage[%
    totoc=true,
    columns=3,
    itemlayout=abshang,
    unbalanced=true,
    indentunit=0.5cm,
]{idxlayout} % Index layout

\newcommand{\person}[2][]{%
    \ifstrempty{#1}{%
        \textsc{#2\index[person]{#2}}}{%
        \textsc{#2\index[person]{#1}}{}}%
}

\usepackage[%
    hyperindex=false,hypertexnames=true,plainpages=false,breaklinks=true,hidelinks,pageanchor=true,
]{hyperref}

\begin{document}
\raggedbottom
    \person{A} \person{Aa} \person{Ab} \person{Ae} \person{B} \person{ba} \person{bbA} \person{bcA} \person{dc} \person{d} \person{ce} \person{dee} \person{fe} \person{ff} \person{few} \person{z} \person{h} \person{eh} \person{erhy} \person{jr} \person{rty} \person{gh} \person{bn} \person{sh} \person{shs} \person{ert} \person{ll} \person{l} \person{fyu} \person{io} \person{erys} \person{syh} \person{yy} \person{ty} \person{jl} \person{ui} \person{pi} \person{oi} \person{m} \person{mn} \person{ji} \person{fh} \person{nn} \person{A} \person{A} \person{A} \person{ttt} \person{tA} \person{eyA} \person{hA} \person{mA} \person{gnA} \person{nnA} \person{nnnA} \person{Amm} \person{Adf} \person{Azds} \person{ssdfA} \person{sdfA} \person{dfghA} \person{dhA} \person{asdas} \person{dsf} \person{d} \person{asdaA} \person{dddaA} \person{asdas} \person{a} \person{asdA} \person{A2} \person{A23} \person{A1} \person{A123} \person{eAf32} \person{A323} \person{A123} \person{A12f3} \person{A123f} \person{A12f3} \person{eA112}\person{etA} \person{ewewA} \person{eeeweA} \person{werA} \person{erwA} \person{eeeA} \person{Asaa} \person{nnnA}  \person{iA} \person{iiA} \person{iiiA} \person{iuA} \person{yiA} \person{dd2A} \person{adA} \person{guA224} 

    \backmatter
    \idxlayout{columns=3}
    \printindex[person]
\end{document}

Using a real world example the problem becomes more apparent. I've marked the erratic spaces in red: real world index example

2

The idxlayout you are using set \parskip to a value with some stretch. You could patch \theindex with (after loading idxlayout)

\usepackage{xpatch}

\makeatletter
\xpatchcmd\theindex{\z@ \@plus 0.3\p@}{0pt}{}{\fail}
\makeatother

The general space between the letter groups are set by \indexspace which you could redefine if you want. But the large spaces between the letter groups are triggered by the hypertargets which seems to suppress pagebreaks. Insert a \leavevmode in the definition of \targetindexentryy:

 \newcommand{\targetindexentryy}[1]{\leavevmode\hypertarget{index:#1}{#1}}
  • Thanks a lot! Your answer fixed the rubber spacing between the entries. I've added the missing xindystyle.xdy. Do you see any styling inside the .xdy file that influences the spacing before the \lettergroup? I see \indexspace preceeding \lettergroup – kabauter Jun 21 '17 at 8:14
  • You didn't try your example. Don't use filecontents for this, it adds text at the begin that confuse xindy, use filecontents* instead. Beside this: you document doesn't show a problem with the headers or the letter groups. Without a real failing document I can't help you. – Ulrike Fischer Jun 21 '17 at 8:23
  • Sorry. That was a typo. I included the .xdy file without filecontents. Maybe the real world example I added makes the problem clear. – kabauter Jun 21 '17 at 11:02
  • Ah, you have spaces before the headings. You will have to provide the code of the real world example. – Ulrike Fischer Jun 21 '17 at 11:46
  • Still you can see the spaces before the headings in the MWE, albeit not to the same extreme extent. How do I prevent this 'holes'? – kabauter Jul 3 '17 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.