寻找更改索引条目字体大小的最佳方法(不是标题或副标题)

寻找更改索引条目字体大小的最佳方法(不是标题或副标题)

这篇文章是对\indexsetup{othercode=\FONTSIZE} 不使用 Idxlayout 更改字体大小

idxlayout当使用如下方式指定索引字体大小时: \usepackage[font=normalsize]{idxlayout},标题、副标题和条目内容似乎都会相应调整。考虑一下,

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

输出索引:

在此处输入图片描述

我希望能够仅调整条目内容的字体大小,并保持标题和副标题按照\Large序言后的代码中指定的比例缩放。

但我还没有找到自动完成此操作的方法。

因此,我对代码进行了一些修改,没有在序言中指定字体大小,而是强制将条目内容的字体大小设为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}

现在给出了Large标题和副标题的缩放字体大小,以及normalsize条目内容的字体---但是---内容行之间的间距非常大,这在原始输出中是不存在的:

在此处输入图片描述

问题:有没有一种自动指定输入内容字体大小的方法仅有的,保持行间距与上面第一个输出中显示的相同?如果没有,是否有手动方法可以做到这一点(例如我在第二组代码中尝试过),但保持行间距与上面第一个索引中显示的相似?当然,最好采用自动方法;否则,我可能不得不在实际文档中进行大量手动调整。

谢谢。

答案1

这是保持idxlayout功能的另一种可能的解决方案。该命令\idxFont将设置字体大小和形状。

正常尺寸

A

脚注大小

b

大的

C

小斜体

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}

答案2

我不太清楚你想要什么字体,但是

在此处输入图片描述

mcl2.istmakindex 样式

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"

和主要文件

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

\item当然,另一种方法是在乳胶中重新定义、\subitem和进行所有的重新设计\subsubitem,但随后您需要与正在使用的也进行重新定义的包进行协调。

相关内容