Xindy 및 사용자 정의 Hyperref 색인 항목

Xindy 및 사용자 정의 Hyperref 색인 항목

내 목표는 xindy. 이것은 다음과 같습니다이전 질문; 해당 질문에는 makeindex. 다음과 같은 항목이 포함된 파일을 생성합니다 .idx.

\indexentry {First example|indexanchor{example:2}}{1(2)}
\indexentry {Second example|indexanchor{example:3}}{1(3)}
\indexentry {Third example|indexanchor{example:4}}{1(4)}

이러한 .idx파일 을 실행하면 입력을 상호 참조로 해석 xindy하므로 다음과 같은 오류가 발생합니다 .xindy

WARNING: unknown cross-reference-class `indexanchor'! (ignored)

이러한 파일을 어떻게 xindy처리할 수 있나요?

답변1

제가 생각해낸 해결책은 xindy하이퍼링크 명령을 페이지 참조 유형으로 인식하도록 가르치는 것입니다. (다음 코드는 페이지 범위 참조를 할 수 없지만 내 애플리케이션과 관련이 없기 때문에 포함하지 않았습니다.)

코드는 .idx페이지 참조의 일부로 포함된 하이퍼링크 명령을 사용하여 이와 같은 파일을 생성합니다. ( \indexanchor아래에 정의되어 있습니다. "표시는 에 대한 이스케이프일 뿐입니다 {.

\indexentry{First example}{\indexanchor{example:1"}{1(1)"}}
\indexentry{Second example}{\indexanchor{example:2"}{1(2)"}}
\indexentry{Third example}{\indexanchor{example:3"}{1(3)"}}

xindy단지 이 페이지 범위가 어떻게 보이는지 알려면 됩니다. 이것은 xindy-hyperref.xdy:

(define-location-class "page-example-hyperref" ( :sep "\indexanchor{example:" "arabic-numbers" :sep "}{" "arabic-numbers" :sep "(" "arabic-numbers" :sep ")}" ))

적절한 형식으로 제작하려면 .idx나만의 출력 구조를 만들어야 했습니다. (누군가 인덱싱 패키지에서 매크로를 재정의하는 보다 우아한 방법이 있다면 관심이 있을 것입니다. 문제가 발생했을 때 내 자신의 인덱싱 코드를 작성하는 것이 얼마나 간단한지 놀랐습니다.)xindy-hyperref.tex:

\documentclass{book}
\usepackage{expex,hyperref,lipsum}
% open the index file
\newwrite\outputstream
\immediate\openout\outputstream=xindy-hyperref.idx
% Index references like 2(3)
\newcommand{\PageExample}{\thepage (\the\excnt)}
% Write the index entries to a file
\def\xindex#1#2#3{%
    \immediate\write#3{\string\indexentry {#2}{\string\indexanchor{example:\the\excnt"}{\PageExample"}}}
    }
\def\indexanchor#1#2{\hyperlink{#1}{#2}}
% clean output
\def\iex#1{%
    \xindex{my-index}{#1}{\outputstream}%
    \ex %
    \raisebox{\baselineskip}{\hypertarget{example:\the\excnt}{}}\ignorespaces}

\begin{document}
\iex{First example} \lipsum[1] \xe

\iex{Second example} \lipsum[2] \xe

\iex{Third example} \lipsum[3] \xe

\iex{Fourth example} \lipsum[4] \xe

\iex{Fifth example} \lipsum[5] \xe

\iex{Sixth example} \lipsum[6] \xe

\iex{Seventh example} \lipsum[7] \xe

\InputIfFileExists{xindy-hyperref.ind}{}{}

\end{document}

예제를 컴파일하려면 다음을 수행하십시오.

xelatex xindy-hyperref.tex
texindy -L english xindy-hyperref.idx -o xindy-hyperref.ind -M xindy-hyperref
xelatex xindy-hyperref.tex

관련 정보