I am trying to customise my index, based on this initial question. As i later found out, hyperref and xindy do not play nice if cross references are involved. Which is why I tried to follow this question which disables hyperref for indexin, and builds the links itself from the style file.

While I have some issues with the stylefile and links not working that is another question.

I am interested in why my formatting breaks: I would like pagenumbers to be right aligned, which they are except for the last entry of every lettergroup where the line extends slighlty more to the right.

enter image description here

Why is that/how do I fix this? (I assume i might do things incorrectly in the markup-letter-group at the bottom of the xindy file, as that is the homebrew part)

%xindy index.idx -M indexStyle -L english -C utf8


(define-location-class "arabic-page-numbers" ("arabic-numbers")             
:min-range-length 2)                            

(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 "}{}")

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

(define-location-class-order (

(markup-index :open  "~n\begin{theindex}

            index:\tedIDXlvlZero, #1%
            %           \ifx\tedLevel\tedIDXlvlTwo %implicit%
            index:\tedIDXlvlZero, \tedIDXlvlOne, #1%
    :close "~n~n\end{theindex}~n"

(markup-indexentry :open "~n \def\tedLevel{0} \item "            :depth 0)
(markup-indexentry :open "~n \def\tedLevel{1}    \subitem "      :depth 1)
(markup-indexentry :open "~n \def\tedLevel{2}      \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 "}" )

;;;(require "lang/english/utf8.xdy")

(markup-letter-group :open-head "~n~n \vspace{1cm} {\hfill\bf " :close-head "\hfill}" :capitalize)

\usepackage[xindy, nonewpage]{imakeidx} %nonewpage needed for index entries after \printindex

\makeindex[program=truexindy, intoc, options={-M indexStyle -L english -C utf8}]

Hello some useless text.\clearpage
\index{hash join|see{join, hash}}


1 Answer 1


Actually the last line is right, the other lines are too short: The code xindy generates in the .ind file ends up like this:

 \vspace{1cm} {\hfill\bf F\hfill}
 \def\tedLevel{0} \item \targetindexentryy{foo}\dotfill \hyperpage{2}
 \def\tedLevel{1}    \subitem \targetindexentryy{bar}\dotfill \hyperpage{2}

When reading this code, TeX replaces each end of line by a space, so at the end of every item there is a space. The end of line character for the last item is interpreted differently because it is followed by an empty line, so it just ends the paragraph instead of inserting a space. This explains why the last line appears a little bit longer: All the other lines have a space character at the right side. To avoid this, you can use the TeX macro trick of ending lines with a % to suppress this space: Just replace

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


(markup-indexentry :open "%~n \def\tedLevel{0} \item "            :depth 0)
(markup-indexentry :open "%~n \def\tedLevel{1}    \subitem "      :depth 1)
(markup-indexentry :open "%~n \def\tedLevel{2}      \subsubitem " :depth 2)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .