2

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---

enter image description here

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.

1 Answer 1

1

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

enter image description here

\documentclass{article}

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

\newcommand{\adjustspaceindex}[2][1ex]{\index{#2\protect\insertgap{#1}}}
\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>.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.