Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Well, I struggled to improve my index generated by Xindy. I tried to add several entries with bold page numbers by using \index{...|textbf} as classified in latex-loc-fmts.xdy, without any success.

When running Xindy (no matter which way, tex2xindy/texindy/xindy) together with texindy.xdy, the following errors are reported (Yes, they are errors because affected entries won't be passed to the generated .ind - IOW not displayed):

line X: multiple |'s
...
WARNING: unknown attribute `textbfhyperpage'! (ignored)

I've no idea how to handle this behavior and would be pleased, if somebody would share his experiences. BTW: I'm using Xindy-2.4 (TL2012)...

UPDATE:

\documentclass{article}
\usepackage{hyperref} % conflict!
\usepackage{makeidx}
\makeindex
\begin{document}
start
Nunc ligula faucibus \index{vel|textbf}. Nullarutrum porttitor...
\index{a}\index{b}\index{ä}\index{z}
end
\printindex
\end{document}

...compiled with:

latex <file> && xindy -M texindy <file> && latex <file>

...results:

It works without hyperref, but when it's been crawled it doesn't. Since hyperref is more or less a standard, it's necessary for me to get Xindy working together with hyperref. Any ideas?

share|improve this question
    
You're probably going to have to post a complete, but minimal, example file for others to test (and hopefully help debug). –  jon May 21 '12 at 19:57
    
here you are, topic has been updated. it seems hyperref and xindy are in conflict, but I didn't find the trick to get them working together yet... –  neptun May 21 '12 at 20:35
2  
I've only found this two year old discussion and no update –  egreg May 21 '12 at 20:53
2  
been there, done that... ^^ but i can not believe, in the matter of the ongoing development over the past years, that there's no solution for this (big) issue. –  neptun May 21 '12 at 21:27
add comment

2 Answers

You must use a separate style file for xindy. The following example results in:

enter image description here

As always I used imakeidx to simplify the process. However you have to compile with shell-escape.

The trick is to allow hyperref to provide a every feature for the index but the writing to the idx-file must be done without any influence by hyperref. This can be achieved by loading imakeidx after hyperref. The formating rules like textbf must be defined in the style file of xindy.

\documentclass{article}
\usepackage[utf8]{inputenc}


\usepackage[hyperindex=true]{hyperref}
\usepackage{imakeidx}
\makeindex[program=texindy,options=-M mystyle.xdy]

\usepackage{filecontents}
\begin{filecontents*}{mystyle.xdy}
;;; xindy style file
(markup-locclass-list :open "\dotfill" :sep "")

(define-attributes (( "textbf" "default" )) )
(markup-locref   :attr  "textbf"     :open "\textbf{\hyperpage{" :close "}}")
(markup-locref   :attr  "textit"     :open "\textit{\hyperpage{" :close "}}")
(markup-locref   :attr  "textttt"     :open "\textttt{\hyperpage{" :close "}}")
(markup-locref   :attr  "texttsc"     :open "\texttsc{\hyperpage{" :close "}}")
(markup-locref   :attr  "default"     :open "\hyperpage{" :close "}")



\end{filecontents*}

\begin{document}
start
Nunc ligula faucibus \index{vel|textbf}. Nullarutrum porttitor...
\index{a}\index{b}\index{ä}\index{z}
end
\printindex
\end{document}

Updated version with see and see also and inside the style file the modul makeindex is loaded.

\documentclass{article}
\usepackage[utf8]{inputenc}


\usepackage[hyperindex=true]{hyperref}
\usepackage{imakeidx}
\makeindex[program=texindy,options=-M mystyle.xdy]

\usepackage{filecontents}
\begin{filecontents*}{mystyle.xdy}
;;; xindy style file

;;; Load a predefined style:
(require "makeindex.xdy")


(markup-locclass-list :open "\dotfill" :sep "")

(define-attributes (( "textbf" "default" )) )
(markup-locref   :attr  "textbf"     :open "\textbf{\hyperpage{" :close "}}")
(markup-locref   :attr  "textit"     :open "\textit{\hyperpage{" :close "}}")
(markup-locref   :attr  "textttt"     :open "\textttt{\hyperpage{" :close "}}")
(markup-locref   :attr  "texttsc"     :open "\texttsc{\hyperpage{" :close "}}")
(markup-locref   :attr  "default"     :open "\hyperpage{" :close "}")



\end{filecontents*}

\begin{document}
start
Nunc ligula faucibus \index{vel|textbf}. Nullarutrum porttitor...
\index{a}\index{b}\index{ä}\index{z}
\index{Peter}
\index{Jenny}
\index{Pet|see{Peter}}
\index{Jen|seealso{Jenny}}

end
\printindex
\end{document}
share|improve this answer
3  
It's a step forward, but it's limited by the fact that you need to define all markup commands in the .xdy file. Of course this is way better than nothing! –  egreg Jun 6 '12 at 17:27
    
Should the \see and \seealso commands be redefined here as well? They do not seem to be well recognized by xindy. –  pluton Jul 6 '13 at 17:14
    
@pluton: You can also load modules which support this: (require "makeindex.xdy") –  Marco Daniel Jul 6 '13 at 17:52
    
Thanks but I have not been successful in mimicking the usual makeindex style with xindy. –  pluton Jul 6 '13 at 22:54
    
The seealso command is ignored and the see command adds the page, while it does not with the original makeindex engine/style. –  pluton Jul 6 '13 at 23:11
show 2 more comments

If we want sorting in index according to the Swedish sorting rules we usually pass -C utf8 -L swedish to xindy.

The key problem I found is that we are not able to pass multiple nested parentheses on the input side, the output side, e.g. markup-locref, is having no difficulties.

So the mentioned strategy is fine, to turn off generating of the second command, \hyperpage, a command used by the hyperref package, which is passed to xindy, otherwise we would need to handle it anyway by external tools.

Our problem splits into two parts: if we use one single command after the @ operator (typeset material) or after the | operator (index references).

  • After the @ operator I use a new single command where I can use any typeset material, in the following example I pass colors, mathematics, font styles, indentation and other material to the index entry. It is not used for sorting, so xindy passes it untouched.
  • However, if we use the | operator, we don't use backslash in the command and we must notify xindy what it is as it is becoming a part of merging, sorting, grouping, tagging etc. We create our own xdy file and we use define-attributes and markup-locref there. Thanks to the filecontents package it is easy to have these definitions in the main TeX file.

That solves our two-part problem for most indices. I enclose a simple example and a preview of the first page. I run these three commands to process the example.

lualatex xindyno1.tex
xindy -M texindy -M mal-style -C utf8 -L swedish -o xindyno1.ind xindyno1.idx
lualatex xindyno1.tex

%! lualatex xindyno1.tex
\documentclass{article}
\usepackage{luatextra} % Due to Swedish Ä letter, use inputenc (pdflatex) or fontspec (xelatex) instead.
\usepackage{xcolor}
\usepackage[hyperindex=false,colorlinks]{hyperref}
\usepackage{filecontents}
\usepackage{makeidx}
\makeindex

\begin{document}
\begin{filecontents*}{mal-style.xdy}
(define-attributes (("texttt" "textsc" "myown")) )
(markup-locref :attr "textbf" :open "\textbf{\hyperpage{" :close "}}")
(markup-locref :attr "textit" :open "\textit{\hyperpage{" :close "}}")
(markup-locref :attr "texttt" :open "\texttt{\hyperpage{" :close "}}")
(markup-locref :attr "textsc" :open "\textsc{\hyperpage{" :close "}}")
(markup-locref :attr "myown" :open "\myown{\hyperpage{" :close "}}")
(markup-locref :attr "hyperpage" :open "\hyperpage{" :close "}")
(markup-locref :attr "default" :open "\hyperpage{" :close "}")
\end{filecontents*}

\def\myshift#1{\makebox[0pt][r]{\texttt{--}}\texttt{#1}}
\def\myown#1{{\Huge#1}}
\def\mycommand#1{{\color{green}#1}}
\def\mydef#1{\texttt{\makebox[0pt][r]{\char"5C}#1}}
\def\mymath#1{{\color{blue}$#1$}}
\def\myfavorite#1{{\color{cyan}\makebox[0pt][r]{I $\heartsuit$\ }{\color{cyan}#1}}}

\begingroup % Print index without page number.
  \def\thispagestyle#1{}
  \pagestyle{empty}
  \printindex
\endgroup

\section{My section}\label{mysection}
I refer to my section~\ref{mysection}.
Start. Nunc ligula faucibus\index{xindy|textbf}. 
\index{vector@Vector}
\index{runme@\mycommand{runme}}
\index{asquared@\mymath{a^2}}
\index{bsquared@\mymath{b^2}}
\index{csquared@\mymath{c^2}}
\index{roof|myown}
\index{mal@\myshift{mal}}
\index{nature@\textbf{Nature}}
\index{home!my own 1}
\index{home!my own 2}
\index{definition@\mydef{definition}}
\index{Velocity}
Nullarutrum porttitor...
\index{alcohol}\index{beauty}\index{älf}\index{zero}
\newpage
\index{vectors@\myfavorite{vectors}}
\index{roof|myown}
\index{roof}
End.
\end{document}

Minimum working example


Next examples of indices

An index is just regular typeset material as any other, usually generated from the idx file containing many \indexentry commands to the ind file, it consists of the theindex environment with a bunch of commands, typically with many \item, \indexspace, \lettergroup and \lettergroupDefault, which we can redefine, if needed.

I enclose snapshots of my work. The first example contains glyphs of the specific font which we are referring to (picture on left), the second example contains CJKV glyphs, to be more specific, those are kanjis used in Japanese (picture on right).

Two snapshots from my work

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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