
Este es un seguimiento deAgregar automáticamente un período después del último número de página en cada entrada del índice
Considere el 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}
Esto produce la salida del índice:
Dado que las entradas del índice se muestran en forma de párrafo, me gustaría que solo el último número de página de cada entrada tenga un punto después del número de página. (Entonces, en este caso, por ejemplo, "Otra entrada de índice más, 1;" se mostraría en su lugar como "Otra entrada de índice más, 1;")
¿Cómo se puede modificar el código anterior para lograr esto?
Gracias.
Respuesta1
Defina un nuevo comando \checknextchar
para probar si el número de página va seguido de subitem
o subsubitem
, si no, agregue un punto. Luego utilícelo \\checknextchar
como valor clave 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}