2

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.

3
  • 1
    \normalsize{..} font sizes never take an argument, and should have end of paragraph in scope to set the line spacing, so {\normalsize ...\par} (but you shouldn't have font sizes in the index entries Nov 23, 2021 at 16:34
  • @David Carlisle Thank you for your comment and the \par suggestion. If it's not too much trouble, would you elaborate a little as to why I shouldn't have font sizes in the index? Many thanks again for your helpful comment. Nov 23, 2021 at 18:50
  • @David Carlisle I have noticed the \par insertion takes care of the interline spacing problem, but it causes the page number to be displayed below the content. Nov 23, 2021 at 18:59

2 Answers 2

3

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}
3
  • Thank you for posting these answers. I noticed that you defined a color burntorange . Is there a reason why you chose this specific color or was it arbitrary? I noticed, however, that you did not make use of it. It might be a coincidence that is not obvious to users on this site, but I figured I'd ask anyway. In any case, thank you for your answers. Nov 23, 2021 at 20:43
  • @mlchristians I was trying several colors but I ended up without putting the figures in the answer. I will correct the code so as not to confuse. Thank you for the feedback. Nov 23, 2021 at 20:50
  • No problem. I asked because I am using that exact color in the document I am working on and which is the basis for the question I posted. Nov 23, 2021 at 20:59
2

I'm not sure quite what fonts you want but

enter image description here

mcl2.ist makindex style

item_0 "\n\\Large\\item"
item_1 "\n\\large\\subitem"
item_x1 "\n\\large\\subitem"
item_2 "\n\\normalsize\\subsubitem"
item_x2 "\n\\normalsize\\subsubitem"

and main document

\documentclass{book}
\usepackage{imakeidx}
\let\cleardoublepage\clearpage
\makeindex[options=-s mcl2.ist]
\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?}}


\printindex
\end{document}

An alternative of course is to do all the restyling in latex redefining \item, \subitem and \subsubitem, but then you need to coordinate with the packages you are using that are also making redefinitions.

4
  • Thank you for you answer. This looks like it might be what I am looking for, but aside from you Main Document code, I don't know how to incorporate the mcl2.ist and the list of five item_ s. I tried sandwiching the list between \RequirePackage{filecontents} \begin{filecontents*}{\mcl2.ist} and \end{filecontents*} before \documentclass{book} but that does not work. May I ask that you display how to incorporate mcl2.ist and the list of item_s in one set of workable code please? Many thanks. Nov 23, 2021 at 19:54
  • @mlchristians why do you need to make it written by the tex file? if you want that you can use filecontents as you show but with {mcl2.ist} not {\mcl2.ist} but you can just save the file as a why put it in filecontents ? Nov 23, 2021 at 19:56
  • I think I would need to specify it in the Tex file, for aren't they changeable font sizes you specify in the list of items? Isn't mcl2.ist a name you gave for this solution and thus needs to be incorporated somehow in the Tex file? At least that's what I thought. If it's the name of a preexisting file then I can see how you can call it in with options; otherwise, I'm confused as to how the list of item specifications is called in if all I need to do is run your Main Document code. Please forgive my confusion. Nov 23, 2021 at 20:28
  • it's the same as the last answer I posted, it's a style for makindex and the imakeindex package calls makeindex with that style if you specify it as I show here, look at the generated .ind file to see the effect of the style. Just save the file along with your tex file, there is no point in writing out the same fixed file every time Nov 23, 2021 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .