You must use a separate style file for xindy. The following example results in:
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}
The fundamental difference here is that ifacconf
updates the way sections are formatted/presented by introducing a new internal argument aimed at distinguishing between certain headings. Specifically, "headings at a level lower than 1" are formatted one way, while "headings at a level of 1 or higher" are formatted differently. And, since hyperref
loads nameref
in order to grab sectional unit titles, there is some confusion between the usual way and the ifacconf
way.
A more direct explanation: LaTeX handles \section*
via the macro \@ssect
:
\def\@ssect#1#2#3#4#5{%
\@tempskipa #3\relax
\ifdim \@tempskipa>\z@
\begingroup
#4{%
\@hangfrom{\hskip #1}%
\interlinepenalty \@M #5\@@par}%
\endgroup
\else
\def\@svsechd{#4{\hskip #1\relax #5}}%
\fi
\@xsect{#3}}
Note that it has/takes 5 arguments. ifacconf
redefines \@ssect
to take 6 arguments:
\def\@ssect#1#2#3#4#5#6{%
\@tempskipa #4\relax
\ifdim \@tempskipa>\z@
\begingroup
#5{%
\@hangfrom{\hskip #2}%
\interlinepenalty \@M \head@format{#1}{#6}\@@par}%
\endgroup
\else
\def\@svsechd{#5{\hskip #2\relax \head@format{#1}{#6}}}%
\fi
\@xsect{#4}}
hyperref
doesn't know that this, since it assumes the regular protocol (5 argument) exists even though packages/classes could (re)define their own sectional unit styles. It would be an unattainable task to accommodate for all possible versions of function (re)definitions.
The following approach stores \@ssect
before hyperref
redefines it. Then it's restored after hyperref
is loaded, together with an insertion to accommodate for nameref
's title gab:
\documentclass{ifacconf}
\usepackage{filecontents}
\begin{filecontents*}{refs-test-delete.bib}
@Article{bibref1,
author = {Firstname M. Lastname},
title = {PaperTitle},
journal = {Journal of Journals},
year = {2009},
volume = {32},
number = {3},
pages = {1039--1045},
month = {5},
publisher = {Publisher},
}
\end{filecontents*}
\makeatletter
\let\old@ssect\@ssect % Store how ifacconf defines \@ssect
\makeatother
\usepackage{natbib}
\usepackage{hyperref}
\makeatletter
\def\@ssect#1#2#3#4#5#6{%
\NR@gettitle{#6}% Insert key \nameref title grab
\old@ssect{#1}{#2}{#3}{#4}{#5}{#6}% Restore ifacconf's \@ssect
}
\makeatother
\begin{document}
\begin{frontmatter}
\title{Paper Title\thanksref{titlenote}}
\thanks[titlenote]{
Titlenote.
}
\author[First]{First Author}
\address[First]{First Author contact info.}
\begin{abstract}
The abstract.
\end{abstract}
\begin{keyword}
Keyword
\end{keyword}
\end{frontmatter}
\section{Introduction}
\label{sec:introduction}
Introduction.
This is based on the work of \citet{bibref1}.
\begin{ack}
Acknowledgement.
\end{ack}
\bibliography{refs-test-delete}
\end{document}
Best Answer
This works: