
memoir
私はとパッケージに基づく cls を使用していますlistings
。すべてのリスト (表のリスト、図のリスト、リストのリスト) を含む付録の章が必要です。これらのリストのタイトル スタイルは、タイトルのようになりますsection
。
表と図の場合は次のように実行できます。
\makeatletter
\renewcommand\@lofmaketitle{%
\section*{\listfigurename}%
\tocmark%
\@afterheading}
\makeatother
\makeatletter
\renewcommand\@lotmaketitle{%
\section*{\listtablename}%
\tocmark%
\@afterheading}
\makeatother
したがって、リストにも機能するはずだと考えましたが、次のコードは効果がありません。
\makeatletter
\renewcommand\@lolmaketitle{%
\section*{\lstlistlistingname}%
\tocmark%
\@afterheading}
\makeatother
私はそれを使用する\lstlistoflistings*
ので、TOC に表示されたくありません。
これどうやってするの?
答え1
これでいいはずだ
\documentclass[a4paper]{memoir}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[caption=Hest]
a
\end{lstlisting}
\begingroup
\makeatletter
\renewcommand\@tocmaketitle{%
\section*{\contentsname}%
\markboth{\contentsname}{\contentsname}
\@afterheading}
\makeatother
% adding a star to \lstlistoflistings does not work, the inner
% \tableofcontents never sees it. Locally use \KeepFromToc
% to emulate the *
\KeepFromToc
\lstlistoflistings
\endgroup
\end{document}
変更は にも影響するため、実際にはプリアンブル内で行うことはできないことに注意してください\tableofcontents
。
関連するコードlistings
は
\lst@UserCommand\lstlistoflistings{\bgroup
\let\contentsname\lstlistlistingname
\let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
\tableofcontents \egroup}
\contentsname
ここで、リセットされ、どのファイル\@starttoc
が使用されるかがわかります。\tableofcontents
通常は実行される\@starttoc
ので、単に実行されます\tableofcontents
。