abenori / jlreq

Other
125 stars 18 forks source link

目次と索引の見出し命令は固有名になっていたほうがよい? #92

Closed kmuto closed 1 year ago

kmuto commented 2 years ago

現状で目次見出しは\tableofcontents 定義内で \chapter*{\contentsname}、索引見出しは \theindex 定義内で \section*{\indexname} となっているのですが、本文用にchapterやsectionの見た目をたとえばRenewTobiraHeadingなどに変更したときに目次や索引の表現も変わることになります。

本文側で\chapter じゃない独自のものを使えばいいという話ではあるのですが、目次や索引の見出しのほうを\chapter\sectionではない固有の名前にするのはいかがでしょうか。

abenori commented 2 years ago

標準クラスファイルに合わせたものだと思います.うーん,ちょっと悩んでみます.一応,一時的に変更するという抜け道はあります.

\documentclass{jlreq}
% フックを使う.それなりに新しいLaTeXが必要.
\AddToHook{cmd/tableofcontents/before}{
  \SaveHeading{section}{\savesection}% 現在の\sectionを保存
  \ModifyHeading{section}{font=\normalfont}% \section変更
}
\AddToHook{cmd/tableofcontents/after}{
  \savesection% 復帰
}
% もちろんこうしてもよい
%\makeatletter
%\let\orig@tableofcontents=\tableofcontents
%\def\tableofcontents{%
%  \SaveHeading{section}{\savesection}% 現在の\sectionを保存
%  \ModifyHeading{section}{font=\normalfont}% \section変更
%  \orig@tableofcontents
%  \savesection% 復帰
%}
%\makeatother
\begin{document}
\tableofcontents
\section{あ}
\end{document}
abenori commented 2 years ago

試しに

\jlreqsetup{
  tableofcontents_heading = {\mysection{\contentsname}},
  theindex_heading = {\mysection{\contentsname}},
}

とできるようにしてみました.(もちろん\mysectionは別途定義しておく必要があります.) df2d437