
Este é um acompanhamentoAdicionar automaticamente um ponto final após o último número de página em cada entrada do índice
Considere o 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}
Isso produz a saída do índice:
Como as entradas do Índice são exibidas em forma de parágrafo, gostaria que apenas o número da última página de cada entrada tivesse um ponto após o número da página. (Portanto, neste caso, por exemplo, "Mais outra entrada de índice, 1.;" seria exibido como "Mais outra entrada de índice, 1;")
Como o código acima pode ser modificado para conseguir isso?
Obrigado.
Responder1
Defina um novo comando \checknextchar
para testar se o número da página é seguido por subitem
ou subsubitem
, se não, adicione um ponto final. Em seguida, use \\checknextchar
como valor-chave paradelim_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}