# Adjust Spacing Between the Comma and Page Number in the Index

Consider the code,

\documentclass{article}
\usepackage{imakeidx}
\makeindex
\usepackage{idxlayout}
\usepackage{xcolor}

\begin{document}
\large

\noindent Some words.\index{How to adjust (i.e., increase) the space between the comma and page number} \\[10pt]
%Some words.\index{How to increase space between comma and page number \hskip 7pt}
\idxlayout{columns=1}
\printindex
\end{document}


which produces the index---

Question: (i) How may I (manually) adjust the space between the comma and the page number of a particular index entry such as the one displayed? (ii) If there were multiple entries, how may the spacing be specified for all of them in advance?

Thank you.

You can insert a special macro as part of the index entry at the end, which then inserts an appropriate space after the ,:

\documentclass{article}

\usepackage{imakeidx}
\makeindex
\usepackage{idxlayout}

\def\insertgap#1,{,\hspace*{#1}\ignorespaces}%

\begin{document}
\large

\noindent Some words.\adjustspaceindex{How to adjust (i.e., increase) the space between the comma and page number}

\noindent Some words.\adjustspaceindex[2ex]{How to adjust (i.e., increase) the space between the comma and page number}

\noindent Some words.\adjustspaceindex[4em]{How to adjust (i.e., increase) the space between the comma and page number}

\idxlayout{columns=1}
\printindex

\end{document}


You can adjust the default value so that it will be used by all entries. However, if you want a global effect for this, create/set a style file (.ist) to adjust the delim_1 string:

delim_1 ", \\hspace\{<len>\}"


where you decide on an appropriate <len>.

• Many thanks for this most helpful answer. Dec 23, 2021 at 14:51