fontsize – Optimal Way to Change Font Size of Index Entries Only in LaTeX

fontsizeidxlayoutimakeidxindexingmakeindex

This post is a bit of an extension of the one posed in \indexsetup{othercode=\FONTSIZE} Not Changing Fontsize with Idxlayout

When one specifies an index font size with idxlayout as such: \usepackage[font=normalsize]{idxlayout}, the heading, subheading, and entry content all seem to get adjusted accordingly. Consider,

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\makeindex
\usepackage[font=normalsize]{idxlayout}
%\usepackage{idxlayout}
\usepackage{xcolor}

\begin{document}
\Large

A sentence.\index{GOETHE@\textbf{GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{Alack"! when a poor wight is so confined amid his books, shut up from all mankind, and sees the world scarce on a holiday, as through a telescope and far away---How may he hope, with nicely tempered skill, to bend the hearts he knows not to his will?}}

\idxlayout{columns=1}
\printindex
\end{document}

which outputs the Index:

enter image description here

I would like to be able to adjust the font size for the entry content only, keeping the Heading and Subheading scaled according to \Large which is specified in the code following the preamble.

But I have not found a way to do this automatically.

So, I manipulated the code a bit by not specifying the font size in the preamble and forcing the font size of the entry content to be normalsize

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\makeindex
%\usepackage[font=normalsize]{idxlayout}
\usepackage{idxlayout}
\usepackage{xcolor}

\begin{document}
\Large

A sentence.\index{GOETHE@\textbf{GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{\normalsize{Alack"! when a poor wight is so confined amid his books, shut up from all mankind, and sees the world scarce on a holiday, as through a telescope and far away---How may he hope, with nicely tempered skill, to bend the hearts he knows not to his will?}}}

\idxlayout{columns=1}
\printindex
\end{document}

which now gives scaled Large font sizes for the heading and subheading, and a normalsize font for the entry content—But—some very large spacing between the lines of the content, which was not present in the original output:

enter image description here

QUESTION: Is there an automatic way to specify the font size of the entry content only, keeping the spacing between the lines the same as that shown in the first output above? If not, is there a manual way to do this (such as I attempted with in second set of code) but keeping the spacing between the lines similar to that displayed in the first index above? Of course, an automatic approach is preferable; otherwise, I one would likely have to make numerous manual adjustments in an actual document.

Thank you.

Best Answer

This another possible solution keeping idxlayout capabilities. The command \idxFont will set the font size and shape.

normalsize

a

footnotesize

b

Large

c

small, italic shape

d

\documentclass{book}

\usepackage{xcolor}
\definecolor{denim}{rgb}{0.08, 0.38, 0.74}

\let\cleardoublepage\clearpage

\usepackage{imakeidx}   
\makeindex

\usepackage{idxlayout}

%**************************  added <<<<<<<<<<<<<<<
\newcommand{\idxFont}{} 
\makeatletter
\renewcommand\subsubitem{\@idxitem \hspace*{30\p@}\idxFont}
\makeatother
%**************************

\begin{document}

A sentence.\index{GOETHE@\textbf{GOETHE'S \textit{FAUST}}!1@\textbf{\color{red}{Wagner}}!{ Alack"! when a poor wight is so confined amid his books, shut up from all mankind, and sees the world scarce on a holiday, as through a telescope and far away---How may he hope, with nicely tempered skill, to bend the hearts he knows not to his will?}}

\idxlayout{columns=1}
\printindex

\renewcommand{\idxFont}{\footnotesize}
\printindex

\renewcommand{\idxFont}{\Large}
\printindex 

\renewcommand{\idxFont}{\sffamily \small \color{denim}}
\printindex 

\renewcommand{\idxFont}{\itshape \small} 
\printindex 


\end{document}