
이는 후속 조치입니다.각 색인 항목의 마지막 페이지 번호 뒤에 마침표를 자동으로 추가합니다.
MWE를 고려해보세요.
\begin{filecontents*}{style.ist}
delim_t "."
\end{filecontents*}
\documentclass[12pt]{article}
\usepackage{imakeidx}
%\makeindex
\makeindex[options=-s style.ist]
\newcommand\pagedot[1]{#1.} % Adds a period to a particular entry.
\usepackage[itemlayout=singlepar]{idxlayout}
\begin{document}
This is a sentence.\index{Index entry}
This is another sentence.\index{Yet another index entry}
\newpage
This is another sentence.\index{Yet another index entry!subentry}
\idxlayout{columns=1}
\printindex
\end{document}
그러면 Index 출력이 생성됩니다.
색인 항목은 단락 형식으로 표시되므로 각 항목의 마지막 페이지 번호에만 페이지 번호 뒤에 마침표가 있도록 하고 싶습니다. (따라서 이 경우 예를 들어 "아직 또 다른 색인 항목, 1.;"은 "아직 또 다른 색인 항목, 1;"로 표시됩니다.)
이를 달성하기 위해 위의 코드를 어떻게 수정할 수 있습니까?
감사합니다.
답변1
\checknextchar
페이지 번호 뒤에 subitem
또는 가 오는지 테스트 subsubitem
하고 마침표를 추가하지 않는 경우 새 명령을 정의합니다 . 그런 \\checknextchar
다음delim_t
\begin{filecontents*}[overwrite]{style.ist}
delim_t "\\checknextchar"
\end{filecontents*}
\documentclass[12pt]{article}
\newcommand{\checknextchar}[1]{%
\ifx\subitem#1\subitem\else\ifx\subsubitem#1\subsubitem\else.\fi\fi%
}
\usepackage{imakeidx}
\makeindex[options=-s style.ist]
\newcommand\pagedot[1]{#1.} % Adds a period to a particular entry.
\usepackage[itemlayout=singlepar]{idxlayout}
\begin{document}
This is a sentence.\index{Index entry}
This is another sentence.\index{Yet another index entry}
This is another sentence.\index{this is another index entry}
\newpage
This is another sentence.\index{this is another index entry!subentry}
This is another sentence.\index{Yet another index entry!subentry}
\newpage
This is another sentence.\index{Yet another index entry!subentry!subsubentry}
\idxlayout{columns=1}
\printindex
\end{document}