
acro와 함께 index를 사용하고 싶습니다. 약어를 사용할 때마다 자동으로 index에 포함되기를 원합니다. 단, 약칭이 아닌 긴 이름!
내가 한 일: 새 명령을 만들었습니다.
\newcommand{\acidx}[1]{\ac{#1}\index{\acl*{#1}}}
이것은 작동합니다. 그러나 라텍스는 acl 매크로를 확장하지 않습니다.~ 전에ind 파일을 작성 중입니다! Mixing index
and acidx` idx 파일의 내용은 다음과 같습니다.
\begin{theindex}
\item \texttt {\acl *{ABC}}, \hyperpage{2}
\item \texttt {\acl *{DEF}}, \hyperpage{1, 2}
\indexspace
\item consetetur, \hyperpage{1}
\end{theindex}
의 요소가 acidx
함께 그룹화되어 있음을 알 수 있습니다. \acl
확장되지 않았기 때문에 가정합니다 . 그랬다면 제대로 정리됐을 것이다.
문제를 완화하기 위해 시도했습니다.
\newcommand{\acidx}[1]{\ac{#1}\index{#1@\acl*{#1}}}
그러나 이것은 (내 이해로는) 인덱스가 이제 전체 이름이 아닌 약어에 따라 정렬되기 때문에 매우 깨끗하지 않습니다. 예를 들어 PHP의 경우 "하이퍼텍스트 전처리기"가 아닌 PHP에 따라 정렬됩니다. 게다가 이렇게 하면 모든 항목이 분리되어 \indexspace
올바르지 않습니다.
ind 파일을 작성하기 전에 인덱스가 매크로를 확장하도록 강제하는 방법이 있습니까?
문제를 해결하는 다른 방법이 있나요?
나는 xindy와 같은 다른 인덱스 프로세서를 사용하는 것을 피하고 싶습니다!
답변1
패키지acronym
의 내부 확장형 버전 \acl
은 입니다 \AC@acl
. 그런 다음 \index
매크로 내부에 \acidx
약어의 확장된 긴 버전이 작성됩니다.
\documentclass{article}
\usepackage{acronym}
\usepackage{makeidx}
\makeindex
\makeatletter
\newcommand*{\acidx}[1]{%
\ac{#1}\index{\AC@acl{#1}}%
}
\makeatother
\acrodef{ABC}{alphabet}
\acrodef{DEF}{definition}
\begin{document}
The \acidx{ABC} contains all\index{all} letters. The \acidx{DEF}
is written with the help of the \acidx{ABC}.
\printindex
\end{document}
그리고 인덱스는 다음과 같습니다.
파일 .idx
:
\indexentry{alphabet}{1}
\indexentry{all}{1}
\indexentry{definition}{1}
\indexentry{alphabet}{1}
패키지acro
acro
LaTeX3를 기반으로 하는 package 와 동일합니다 . 약어 id에 대한 데이터 목록에서 \prop_get:NnNF
속성을 가져오고 결과를 에 저장합니다 . ) 의 정의를 참조하세요 . 그런 다음 결과 토큰 목록 변수를 다음 에서 사용할 수 있습니다 .\l__acro_long_prop
#1
\l__acro_long_tl
\acro_get:n
\l__acro_long_tl
\index
\documentclass{article}
\usepackage{acro}
\usepackage{makeidx}
\makeindex
\ExplSyntaxOn
\newcommand*{\acidx}[1]{%
\ac{#1}%
\prop_get:NnNF \l__acro_long_prop {#1} \l__acro_long_tl {}
\index{\l__acro_long_tl}%
}
\ExplSyntaxOff
\DeclareAcronym{ABC}{short=ABC, long=alphabet}
\DeclareAcronym{DEF}{short=DEF, long=definition}
\begin{document}
The \acidx{ABC} contains all\index{all} letters. The \acidx{DEF}
is written with the help of the \acidx{ABC}.
\printindex
\end{document}